private void updateChannelByBandwidth(int bandwidthIndex) { if (bandwidthIndex == BANDWIDTH_INDEX_40) { mChannel.removeBw40mUnsupported2dot4GChannels(mChannelAdapter); mChannel.remove5GChannels(mChannelAdapter); mChannel.insertBw40MChannels(mChannelAdapter); } }
void joinChannel(Channel channel) { Connection con = null; try { con = pool.getConnection(timeout); PreparedStatement s = con.prepareStatement("INSERT INTO `channels` (`channel`) VALUES (?)"); s.setString(1, channel.getName().toLowerCase()); s.executeUpdate(); s.close(); if (!this.channel_data.containsKey(channel.getName().toLowerCase())) { ChannelInfo new_channel = new ChannelInfo(channel.getName().toLowerCase()); new_channel.setDefaultOptions(); this.channel_data.put(channel.getName().toLowerCase(), new_channel); } this.saveChannelSettings(this.channel_data.get(channel.getName().toLowerCase())); } catch (SQLException ex) { Logger.getLogger(DBAccess.class.getName()).log(Level.SEVERE, null, ex); } finally { try { if (con != null) { con.close(); } } catch (SQLException ex) { Logger.getLogger(DBAccess.class.getName()).log(Level.SEVERE, null, ex); } } }
private void stepTimeout() { boolean updated = false; synchronized (channels) { Iterator<ChannelInfo> it = channels.values().iterator(); while (it.hasNext()) { ChannelInfo channel = it.next(); Iterator<UserInfo> removed = channel.stepTimeout(getTimeoutLimit()); if (removed != null) { updated = true; String channelName = channel.getChannelName(); while (removed.hasNext()) { UserInfo user = removed.next(); ServerLogger.getInstance() .channelLeaved(channelName, user.getUserName(), user.getInetSocketAddress()); } if (channel.isEmpty()) { it.remove(); ServerLogger.getInstance().channelRemoved(channelName); } } } if (updated) { updateChannelsCache(); } } }
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Xlog.e( TAG, "arg0.getId(): " + arg1.getId() + " " + R.id.WiFi_RX_Channel_Spinner + " " + R.id.WiFi_Bandwidth_Spinner); if (arg0.getId() == R.id.WiFi_RX_Channel_Spinner) { if (EMWifi.sIsInitialed) { mChannel.mChannelSelect = mChannelAdapter.getItem(arg2); EMWifi.setChannel(mChannel.getChannelFreq()); } else { showDialog(DIALOG_WIFI_ERROR); } } else if (arg0.getId() == R.id.WiFi_Bandwidth_Spinner) { mBandwidthIndex = arg2 < mBandwidth.length ? arg2 : mBandwidthIndex; if (mBandwidth[BW_INDX_ADVANCED].equals( mBandwidthSpinner.getSelectedItem().toString())) { mBandwidthIndex = BW_INDX_ADVANCED; } if (mBandwidthIndex == BW_INDX_ADVANCED) { onAdvancedBandwidthSelected(); } else { updateChannels(); findViewById(R.id.wifi_bandwidth_advanced_ll).setVisibility(View.GONE); } } }
/** Releases the channels. */ private void freeChannels() { for (ChannelInfo info : channels.values()) { freePacket(info.getReadPacket()); freePacket(info.getWritePacket()); } channels.clear(); }
/** * Setter for last read packet. * * @param channelId Channel id * @param packet Packet */ public void setLastReadPacket(int channelId, Packet packet) { final ChannelInfo info = getChannelInfo(channelId); // grab last packet Packet prevPacket = info.getReadPacket(); // set new one info.setReadPacket(packet); // free the previous packet freePacket(prevPacket); }
private void updateChannelByAdvancedSetting(int cbw, int dbw, int primCh) { if (cbw == 1) { // BW40 mChannel.remove5GChannels(mChannelAdapter); mChannel.insertBw40MChannels(mChannelAdapter); } else if (cbw == 2) { // BW80 // mChannel.remove2dot4GChannels(mChannelAdapter); // mChannel.remove5GChannels(mChannelAdapter); mChannelAdapter.clear(); mChannel.insertBw80MChannels(mChannelAdapter); } }
public IChannelInfo channelData( String channelName, String userName, InetSocketAddress userAddress) { // System.out.println("channelName channel:"+channelName+" user:"******" // addr:"+userAddress); ChannelInfo channel = channelsCache.get(channelName); if (channel == null) { synchronized (channels) { channel = channels.get(channelName); if (channel == null) { channel = new ChannelInfo(channelName); channels.put(channelName, channel); updateChannelsCache(); ServerLogger.getInstance().channelCreated(channelName); } } } boolean updated = channel.userData(userName, userAddress); if (updated) { ServerLogger.getInstance().channelJoined(channelName, userName, userAddress); } return channel; }
private void updateChannels() { mChannel.resetSupportedChannels(mChannelAdapter); updateChannelByBandwidth(mBandwidthIndex); if (mBandwidthIndex == BW_INDX_ADVANCED) { updateChannelByAdvancedSetting(mChannelBandwidth, mDataBandwidth, mPrimarySetting); } boolean bUpdateWifiChannel = true; if (mChannelAdapter.getCount() == 0) { mBtnGo.setEnabled(false); bUpdateWifiChannel = false; } else { mBtnGo.setEnabled(true); } if (bUpdateWifiChannel) { updateWifiChannel(mChannel, mChannelAdapter, mChannelSpinner); } }
private static String getDisplayText(ChannelInfo channelInfo) { Log.v(TAG, "getDisplayText..."); String displayText = null; if (channelInfo.error) { displayText = String.format("#%-6d !:%s", channelInfo.deviceNumber, channelInfo.getErrorString()); } else { if (channelInfo.isMaster) { displayText = String.format( "#%-6d Tx:[%2d]", channelInfo.deviceNumber, channelInfo.broadcastData[0] & 0xFF); } else { displayText = String.format( "#%-6d Rx:[%2d]", channelInfo.deviceNumber, channelInfo.broadcastData[0] & 0xFF); } } Log.v(TAG, "...getDisplayText"); return displayText; }
private void getChannelList() { Connection con = null; ChannelInfo ci; this.channel_data.clear(); try { con = pool.getConnection(timeout); ResultSet rs; try (Statement s = con.createStatement()) { rs = s.executeQuery("SELECT * FROM `channels`"); PreparedStatement s2; ResultSet rs2; while (rs.next()) { ci = new ChannelInfo(rs.getString("channel")); ci.setDefaultOptions(); ci.setReactiveChatter( rs.getInt("reactive_chatter_level"), rs.getInt("chatter_name_multiplier")); ci.setRandomChatter(rs.getInt("random_chatter_level")); ci.setTwitterTimers( rs.getFloat("tweet_bucket_max"), rs.getFloat("tweet_bucket_charge_rate")); ci.setWarAutoMuzzle(rs.getBoolean("auto_muzzle_wars")); ci.velociraptorSightings = rs.getInt("velociraptor_sightings"); ci.activeVelociraptors = rs.getInt("active_velociraptors"); ci.deadVelociraptors = rs.getInt("dead_velociraptors"); ci.killedVelociraptors = rs.getInt("killed_velociraptors"); if (rs.getDate("last_sighting_date") != null) { long time = rs.getDate("last_sighting_date").getTime(); ci.lastSighting = new java.util.Date(time); } s2 = con.prepareStatement( "SELECT `setting`, `value` FROM `channel_chatter_settings` WHERE `channel` = ?"); s2.setString(1, rs.getString("channel")); s2.executeQuery(); rs2 = s2.getResultSet(); while (rs2.next()) { ci.addChatterSetting(rs2.getString("setting"), rs2.getBoolean("value")); } s2.close(); rs2.close(); s2 = con.prepareStatement( "SELECT `setting`, `value` FROM `channel_command_settings` WHERE `channel` = ?"); s2.setString(1, rs.getString("channel")); s2.executeQuery(); rs2 = s2.getResultSet(); while (rs2.next()) { ci.addCommandSetting(rs2.getString("setting"), rs2.getBoolean("value")); } s2.close(); rs2.close(); s2 = con.prepareStatement( "SELECT `account` FROM `channel_twitter_feeds` WHERE `channel` = ?"); s2.setString(1, rs.getString("channel")); s2.executeQuery(); rs2 = s2.getResultSet(); while (rs2.next()) { ci.addTwitterAccount(rs2.getString("account")); } s2.close(); rs2.close(); this.channel_data.put(ci.channel, ci); this.saveChannelSettings(ci); } } rs.close(); } catch (SQLException ex) { Logger.getLogger(DBAccess.class.getName()).log(Level.SEVERE, null, ex); } finally { try { if (con != null) { con.close(); } } catch (SQLException ex) { Logger.getLogger(DBAccess.class.getName()).log(Level.SEVERE, null, ex); } } }