void EditMode::slotRemoveChannelClicked() { QLCChannel* ch = currentChannel(); if (ch != NULL) { QListViewItem* item = NULL; QString select; // Pick the item above or below to be selected next item = m_channelList->currentItem()->itemAbove(); if (item == NULL) item = m_channelList->currentItem()->itemBelow(); if (item != NULL) select = item->text(KChannelsColumnName); // Remove the channel and the listview item m_mode->removeChannel(ch); delete m_channelList->currentItem(); // Easier to refresh the whole list than to decrement all // channel numbers after the inserted item refreshChannelList(); // Select another channel selectChannel(select); } }
/** Constructor */ GxsChannelDialog::GxsChannelDialog(QWidget *parent) : RsGxsUpdateBroadcastPage(rsGxsChannels, parent), GxsServiceDialog(dynamic_cast<GxsCommentContainer *>(parent)) { /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); /* Setup UI helper */ mStateHelper = new UIStateHelper(this); mStateHelper->addWidget(TOKEN_TYPE_POSTS, ui.progressBar, UISTATE_LOADING_VISIBLE); mStateHelper->addWidget(TOKEN_TYPE_POSTS, ui.progressLabel, UISTATE_LOADING_VISIBLE); mStateHelper->addLoadPlaceholder(TOKEN_TYPE_GROUP_DATA, ui.nameLabel); mStateHelper->addWidget(TOKEN_TYPE_GROUP_DATA, ui.postButton); mStateHelper->addWidget(TOKEN_TYPE_GROUP_DATA, ui.logoLabel); mChannelQueue = new TokenQueue(rsGxsChannels->getTokenService(), this); connect(ui.postButton, SIGNAL(clicked()), this, SLOT(createMsg())); // connect(NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int))); /*************** Setup Left Hand Side (List of Channels) ****************/ connect(ui.treeWidget, SIGNAL(treeCustomContextMenuRequested(QPoint)), this, SLOT(channelListCustomPopupMenu(QPoint))); connect(ui.treeWidget, SIGNAL(treeCurrentItemChanged(QString)), this, SLOT(selectChannel(QString))); connect(ui.todoPushButton, SIGNAL(clicked()), this, SLOT(todo())); mChannelId.clear(); /* Set initial size the splitter */ QList<int> sizes; sizes << 300 << width(); // Qt calculates the right sizes ui.splitter->setSizes(sizes); /* Initialize group tree */ QToolButton *newChannelButton = new QToolButton(this); newChannelButton->setIcon(QIcon(":/images/add_channel24.png")); newChannelButton->setToolTip(tr("Create Channel")); connect(newChannelButton, SIGNAL(clicked()), this, SLOT(createChannel())); ui.treeWidget->addToolButton(newChannelButton); ownChannels = ui.treeWidget->addCategoryItem(tr("My Channels"), QIcon(IMAGE_CHANNELBLUE), true); subcribedChannels = ui.treeWidget->addCategoryItem(tr("Subscribed Channels"), QIcon(IMAGE_CHANNELRED), true); popularChannels = ui.treeWidget->addCategoryItem(tr("Popular Channels"), QIcon(IMAGE_CHANNELGREEN), false); otherChannels = ui.treeWidget->addCategoryItem(tr("Other Channels"), QIcon(IMAGE_CHANNELYELLOW), false); ui.progressLabel->hide(); ui.progressBar->hide(); ui.nameLabel->setMinimumWidth(20); /* load settings */ processSettings(true); /* Initialize empty GUI */ requestGroupData(mChannelId); }
void EditMode::slotAddChannelClicked() { QPtrListIterator<QLCChannel> it(*m_mode->fixtureDef()->channels()); QLCChannel* ch = NULL; QStringList list; bool ok = false; QString name; int index = 0; /* Create a list of channels that have not been added to this mode yet */ while ( (ch = it.current()) != 0 ) { ++it; if (m_mode->searchChannel(ch->name()) != NULL) continue; else list.append(ch->name()); } name = QInputDialog::getItem("Add channel to mode", "Select a channel to add", list, 0, false, &ok, this); if (ok == true && name.isEmpty() == false) { QListViewItem* item = NULL; int insertat = 0; ch = m_mode->fixtureDef()->channel(name); // Find out the current channel number item = m_channelList->currentItem(); if (item != NULL) insertat = item->text(KChannelsColumnNumber).toInt() - 1; else insertat = 0; // Insert the item at current selection m_mode->insertChannel(ch, insertat); // Easier to refresh the whole list than to increment all // channel numbers after the inserted item refreshChannelList(); // Select the new channel selectChannel(ch->name()); } }
/** Constructor */ ChannelFeed::ChannelFeed(QWidget *parent) : RsAutoUpdatePage(1000,parent) { /* Invoke the Qt Designer generated object setup routine */ setupUi(this); connect(newChannelButton, SIGNAL(clicked()), this, SLOT(createChannel())); connect(postButton, SIGNAL(clicked()), this, SLOT(createMsg())); connect(NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int))); /*************** Setup Left Hand Side (List of Channels) ****************/ connect(treeWidget, SIGNAL(treeCustomContextMenuRequested(QPoint)), this, SLOT( channelListCustomPopupMenu( QPoint ) ) ); connect(treeWidget, SIGNAL(treeCurrentItemChanged(QString)), this, SLOT(selectChannel(QString))); mChannelId.clear(); /* Set initial size the splitter */ QList<int> sizes; sizes << 300 << width(); // Qt calculates the right sizes splitter->setSizes(sizes); /* Initialize group tree */ treeWidget->initDisplayMenu(displayButton); ownChannels = treeWidget->addCategoryItem(tr("My Channels"), QIcon(IMAGE_CHANNELBLUE), true); subcribedChannels = treeWidget->addCategoryItem(tr("Subscribed Channels"), QIcon(IMAGE_CHANNELRED), true); popularChannels = treeWidget->addCategoryItem(tr("Popular Channels"), QIcon(IMAGE_CHANNELGREEN ), false); otherChannels = treeWidget->addCategoryItem(tr("Other Channels"), QIcon(IMAGE_CHANNELYELLOW), false); progressLabel->hide(); progressBar->hide(); fillThread = NULL; //added from ahead updateChannelList(); nameLabel->setMinimumWidth(20); /* load settings */ processSettings(true); updateChannelMsgs(); }
void EditMode::slotAddChannelClicked() { QLCChannel* ch; /* Create a list of channels that haven't been added to this mode yet */ QStringList chlist; QListIterator <QLCChannel*> it(m_mode->fixtureDef()->channels()); while (it.hasNext() == true) { ch = it.next(); if (m_mode->channel(ch->name()) != NULL) continue; else chlist << ch->name(); } if (chlist.size() > 0) { bool ok = false; QString name = QInputDialog::getItem(this, tr("Add channel to mode"), tr("Select a channel to add"), chlist, 0, false, &ok); if (ok == true && name.isEmpty() == false) { ch = m_mode->fixtureDef()->channel(name); // Append the channel m_mode->insertChannel(ch, m_mode->channels().size()); // Easier to refresh the whole list refreshChannelList(); // Select the new channel selectChannel(ch->name()); } } else { QMessageBox::information(this, tr("No more available channels"), tr("All available channels are present in the mode.")); } }
void EditMode::slotLowerChannelClicked() { QLCChannel* ch = currentChannel(); int index = 0; if (ch == NULL) return; index = m_mode->channelNumber(ch) + 1; // Don't move beyond the end of the list if (index >= m_mode->channels()) return; m_mode->removeChannel(ch); m_mode->insertChannel(ch, index); refreshChannelList(); selectChannel(ch->name()); }
int processChannelControlMessage( INOUT SESSION_INFO *sessionInfoPtr, INOUT STREAM *stream ) { SSH_INFO *sshInfo = sessionInfoPtr->sessionSSH; const long prevChannelNo = \ getCurrentChannelNo( sessionInfoPtr, CHANNEL_READ ); long channelNo; int status; assert( isWritePtr( sessionInfoPtr, sizeof( SESSION_INFO ) ) ); assert( isWritePtr( stream, sizeof( STREAM ) ) ); /* See what we've got. SSH has a whole pile of no-op equivalents that we have to handle as well as the obvious no-ops. We can also get global and channel requests for assorted reasons and a constant stream of window adjusts to implement the SSH performance handbrake */ switch( sshInfo->packetType ) { case SSH2_MSG_GLOBAL_REQUEST: status = processChannelRequest( sessionInfoPtr, stream, CRYPT_UNUSED ); if( cryptStatusError( status ) && status != OK_SPECIAL ) return( status ); return( OK_SPECIAL ); case SSH2_MSG_CHANNEL_OPEN: /* Process the channel-open request. In theory we could immediately reject any attempts by the server to open a channel to the client at this point, but unfortunately we have to process a considerable portion of the channel-open request in order to use the information in it to send a request-denied response back to the server */ status = processChannelOpen( sessionInfoPtr, stream ); if( cryptStatusError( status ) ) return( status ); /* Tell the caller that they have to process the new channel information before they can continue */ return( CRYPT_ENVELOPE_RESOURCE ); case SSH2_MSG_IGNORE: case SSH2_MSG_DEBUG: /* Nothing to see here, move along, move along: byte SSH2_MSG_IGNORE string data byte SSH2_MSG_DEBUG boolean always_display string message string language_tag */ return( OK_SPECIAL ); case SSH2_MSG_DISCONNECT: /* This only really seems to be used during the handshake phase, once a channel is open it (and the session as a whole) is disconnected with a channel EOF/close, but we handle it here anyway just in case */ return( getDisconnectInfo( sessionInfoPtr, stream ) ); #ifdef KPYM_HACK case SSH2_MSG_KEXDH_INIT/*SSH2_MSG_KEXDH_GEX_REQUEST_OLD*/: case SSH2_MSG_KEXDH_GEX_INIT: case SSH2_MSG_KEXDH_GEX_REQUEST_NEW: case SSH2_MSG_KEXINIT: case SSH2_MSG_NEWKEYS: { int status = ke_DH_ROUTER(sessionInfoPtr, stream, sshInfo->packetType); if( status == CRYPT_OK )return( OK_SPECIAL ); else return status; } #else case SSH2_MSG_KEXINIT: #endif /* The SSH spec is extremely vague about the sequencing of operations during a rehandshake. Unlike SSL there's no real indication of what happens to the connection-layer transfers while a transport-layer rehandshake is in progress. Also unlike SSL we can't refuse a rehandshake by ignoring the request, so once we've fallen we can't get up any more. This is most obvious with ssh.com's server, which starting with version 2.3.0 would do a rehandshake every hour (for a basic encrypted telnet session, while a high-volume IPsec link can run for hours before it feels the need to do this). To make things even messier, neither side can block for too long waiting for the rehandshake to complete before sending new data because the lack of WINDOW_ADJUSTs (in an implementation that sends these with almost every packet, as most do) will screw up flow control and lead to deadlock. This problem got so bad that as of 2.4.0 the ssh.com implementation would detect OpenSSH (the other main implementation at the time) and disable the rehandshake when it was talking to it, but it may not do this for other implementations. To avoid falling into this hole, or at least to fail obviously when the two sides can't agree on how to handle the layering mismatch problem, we report a rehandshake request as an error. Trying to handle it properly results in hard-to- diagnose errors (it depends on what the layers are doing at the time of the problem), typically some bad-packet error when the other side tries to interpret a connection-layer packet as part of the rehandshake, or when the two sides disagree on when to switch keys and one of the two decrypts with the wrong keys and gets a garbled packet type */ retExt( CRYPT_ERROR_BADDATA, ( CRYPT_ERROR_BADDATA, SESSION_ERRINFO, "Unexpected KEXINIT request received" ) ); case SSH2_MSG_CHANNEL_DATA: case SSH2_MSG_CHANNEL_EXTENDED_DATA: case SSH2_MSG_CHANNEL_REQUEST: case SSH2_MSG_CHANNEL_WINDOW_ADJUST: case SSH2_MSG_CHANNEL_EOF: case SSH2_MSG_CHANNEL_CLOSE: /* All channel-specific messages end up here */ channelNo = readUint32( stream ); if( cryptStatusError( channelNo ) ) { /* We can't send an error response to a channel request at this point both because we haven't got to the response- required flag yet and because SSH doesn't provide a mechanism for returning an error response without an accompanying channel number. The best that we can do is to quietly ignore the packet */ retExt( CRYPT_ERROR_BADDATA, ( CRYPT_ERROR_BADDATA, SESSION_ERRINFO, "Invalid channel number in channel-specific packet " "type %d", sshInfo->packetType ) ); } if( channelNo != getCurrentChannelNo( sessionInfoPtr, \ CHANNEL_READ ) ) { /* It's a request on something other than the current channel, try and select the new channel */ status = selectChannel( sessionInfoPtr, channelNo, CHANNEL_READ ); if( cryptStatusError( status ) ) { /* As before for error handling */ retExt( CRYPT_ERROR_BADDATA, ( CRYPT_ERROR_BADDATA, SESSION_ERRINFO, "Invalid channel number %lX in " "channel-specific packet type %d, current " "channel is %lX", channelNo, sshInfo->packetType, prevChannelNo ) ); } } break; default: { BYTE buffer[ 16 + 8 ]; int length; /* We got something unexpected, throw an exception in the debug version and let the caller know the details */ DEBUG_DIAG(( "Unexpected control packet %d", sshInfo->packetType )); assert( DEBUG_WARN ); status = length = sread( stream, buffer, 8 ); if( cryptStatusError( status ) || length < 8 ) { /* There's not enough data present to dump the start of the packet, provide a more generic response */ retExt( CRYPT_ERROR_BADDATA, ( CRYPT_ERROR_BADDATA, SESSION_ERRINFO, "Unexpected control packet type %d received", sshInfo->packetType ) ); } retExt( CRYPT_ERROR_BADDATA, ( CRYPT_ERROR_BADDATA, SESSION_ERRINFO, "Unexpected control packet type %d received, " "beginning %02X %02X %02X %02X %02X %02X %02X %02X", sshInfo->packetType, buffer[ 0 ], buffer[ 1 ], buffer[ 2 ], buffer[ 3 ], buffer[ 4 ], buffer[ 5 ], buffer[ 6 ], buffer[ 7 ] ) ); } } /* From here on we're processing a channel-specific message that applies to the currently selected channel */ switch( sshInfo->packetType ) { case SSH2_MSG_CHANNEL_DATA: case SSH2_MSG_CHANNEL_EXTENDED_DATA: { int length; /* Get the payload length and make sure that it's (approximately) valid, more exact checking has already been done by the caller so we don't need to return extended error information as this is just a backup check */ status = length = readUint32( stream ); if( cryptStatusError( status ) || \ length < 0 || length > sessionInfoPtr->receiveBufSize ) return( CRYPT_ERROR_BADDATA ); /* These are messages that consume window space, adjust the data window and communicate changes to the other side if necessary */ status = handleWindowAdjust( sessionInfoPtr, channelNo, length ); if( cryptStatusError( status ) ) return( status ); /* If it's a standard data packet, we're done */ if( sshInfo->packetType == SSH2_MSG_CHANNEL_DATA ) return( CRYPT_OK ); /* The extended data message is used for out-of-band data sent over a channel, specifically output sent to stderr from a shell command. What to do with this is somewhat uncertain, the only possible action that we could take apart from just ignoring it is to convert it back to in-band data. However, something running a shell command may not expect to get anything returned in this manner (see the comment for the port-forwarding channel open in the client-side channel-open code for more on this) so for now we just ignore it and assume that the user will rely on results sent as in-band data. This should be fairly safe since this message type seems to be rarely (if ever) used, so apps will function without it */ return( OK_SPECIAL ); } case SSH2_MSG_CHANNEL_REQUEST: status = processChannelRequest( sessionInfoPtr, stream, prevChannelNo ); if( cryptStatusError( status ) && status != OK_SPECIAL ) return( status ); return( OK_SPECIAL ); case SSH2_MSG_CHANNEL_WINDOW_ADJUST: /* Another noop-equivalent (but a very performance-affecting one) */ return( OK_SPECIAL ); case SSH2_MSG_CHANNEL_EOF: /* According to the SSH docs the EOF packet is mostly a courtesy notification, however many implementations seem to use a channel EOF in place of a close before sending a disconnect message */ #ifdef KPYM_HACK #else return( OK_SPECIAL ); #endif case SSH2_MSG_CHANNEL_CLOSE: /* The peer has closed their side of the channel, if our side isn't already closed (in other words if this message isn't a response to a close that we sent), close our side as well */ if( getChannelStatusByChannelNo( sessionInfoPtr, channelNo ) == CHANNEL_BOTH ) { #ifdef KPYM_HACK status = sendChannelClose( sessionInfoPtr, channelNo, CHANNEL_BOTH, TRUE ); /* We've already closed our side of the channel, delete it */ status = deleteChannel( sessionInfoPtr, channelNo, CHANNEL_BOTH, TRUE ); #else status = sendChannelClose( sessionInfoPtr, channelNo, CHANNEL_BOTH, TRUE ); #endif } else { /* We've already closed our side of the channel, delete it */ status = deleteChannel( sessionInfoPtr, channelNo, CHANNEL_BOTH, TRUE ); } /* If this wasn't the last channel, we're done */ if( status != OK_SPECIAL ) return( OK_SPECIAL ); /* We've closed the last channel, indicate that the overall connection is now closed. This behaviour isn't mentioned in the spec but it seems to be the standard way of handling things, particularly for the most common case where channel == session */ sessionInfoPtr->flags |= SESSION_SENDCLOSED; retExt( CRYPT_ERROR_COMPLETE, ( CRYPT_ERROR_COMPLETE, SESSION_ERRINFO, "Remote system closed last remaining SSH channel" ) ); } retIntError(); }
void Hub::tileToAntennaProcess() { if (reset.read()) { for (unsigned int i =0 ;i<txChannels.size();i++) { int channel = txChannels[i]; flag[channel]->write(HOLD_CHANNEL); } for (int i = 0; i < num_ports; i++) { ack_rx[i]->write(0); current_level_rx[i] = 0; } return; } for (unsigned int i =0 ;i<txChannels.size();i++) { int channel = txChannels[i]; string macPolicy = token_ring->getPolicy(channel).first; if (macPolicy == TOKEN_PACKET) txRadioProcessTokenPacket(channel); else if (macPolicy == TOKEN_HOLD) txRadioProcessTokenHold(channel); else if (macPolicy == TOKEN_MAX_HOLD) txRadioProcessTokenMaxHold(channel); else assert(false); } int * r_from_tile = new int[num_ports]; // 1st phase: Reservation for (int j = 0; j < num_ports; j++) { int i = (start_from_port + j) % (num_ports); if (!buffer_from_tile[i].IsEmpty()) { //LOG << "Reservation: buffer_from_tile not empty on port " << i << endl; Flit flit = buffer_from_tile[i].Front(); power.bufferFromTileFront(); r_from_tile[i] = route(flit); if (flit.flit_type == FLIT_TYPE_HEAD) { assert(r_from_tile[i]==DIRECTION_WIRELESS); int channel = selectChannel(local_id,tile2Hub(flit.dst_id)); assert(channel!=NOT_VALID && "hubs are connected by any channel"); if (tile2antenna_reservation_table.isAvailable(channel)) { tile2antenna_reservation_table.reserve(i, channel); } else { //LOG << "Reservation: wireless channel " << channel << " not available ..." << endl; } } } } start_from_port++; // 2nd phase: Forwarding for (int i = 0; i < num_ports; i++) { if (!buffer_from_tile[i].IsEmpty()) { Flit flit = buffer_from_tile[i].Front(); // powerFront already accounted in 1st phase assert(r_from_tile[i] == DIRECTION_WIRELESS); int channel = tile2antenna_reservation_table.getOutputPort(i); if (channel != NOT_RESERVED) { if (!(init[channel]->buffer_tx.IsFull()) ) { LOG << "Flit moved from buffer_from_tile["<<i<<"] to buffer_tx["<<channel<<"] " << endl; buffer_from_tile[i].Pop(); power.bufferFromTilePop(); init[channel]->buffer_tx.Push(flit); power.antennaBufferPush(); if (flit.flit_type == FLIT_TYPE_TAIL) tile2antenna_reservation_table.release(channel); } } else { //LOG << "Forwarding: No channel reserved for port direction " << i << endl; } } }// for all the ports for (int i = 0; i < num_ports; i++) { /* if (!buffer_from_tile[i].deadlockFree()) { LOG << " deadlock on buffer " << i << endl; buffer_from_tile[i].Print("deadlock"); } */ if ((req_rx[i]->read() == 1 - current_level_rx[i]) && !buffer_from_tile[i].IsFull()) { //LOG << "Reading flit on port " << i << endl; Flit received_flit = flit_rx[i]->read(); buffer_from_tile[i].Push(received_flit); power.bufferFromTilePush(); current_level_rx[i] = 1 - current_level_rx[i]; } ack_rx[i]->write(current_level_rx[i]); } // IMPORTANT: do not move from here // The txPowerManager assumes that all flit buffer write have been done updateTxPower(); }