// process a channel event message // would be good to refactor to use ANTMessage at some point // but not compelling reason to do so at this point and might // break existing code. void ANTChannel::channelEvent(unsigned char *ant_message) { unsigned char *message=ant_message+2; //qDebug()<<"channel event:"<< ANTMessage::channelEventMessage(*(message+1)); if (MESSAGE_IS_RESPONSE_NO_ERROR(message)) { attemptTransition(RESPONSE_NO_ERROR_MESSAGE_ID(message)); } else if (MESSAGE_IS_EVENT_CHANNEL_CLOSED(message)) { parent->sendMessage(ANTMessage::unassignChannel(number)); } else if (MESSAGE_IS_EVENT_RX_SEARCH_TIMEOUT(message)) { // timeouts are normal for search channel if (channel_type_flags & CHANNEL_TYPE_QUICK_SEARCH) { channel_type_flags &= ~CHANNEL_TYPE_QUICK_SEARCH; channel_type_flags |= CHANNEL_TYPE_WAITING; emit searchTimeout(number); } else { emit lostInfo(number); // Don't wipe out the channel settings when the search times out, // else can not reconnect to the device once back in range.. //channel_type=CHANNEL_TYPE_UNUSED; //channel_type_flags=0; //device_number=0; //value2=value=0; //setId(); parent->sendMessage(ANTMessage::unassignChannel(number)); } } else if (MESSAGE_IS_EVENT_RX_FAIL(message)) { messages_dropped++; double t=get_timestamp(); if (t > (last_message_timestamp + timeout_drop)) { if (channel_type != CHANNEL_TYPE_UNUSED) emit dropInfo(number, messages_dropped, messages_received); // this is a hacky way to prevent the drop message from sending multiple times last_message_timestamp+=2*timeout_drop; } } else if (MESSAGE_IS_EVENT_RX_ACKNOWLEDGED(message)) { exit(-10); } else if (MESSAGE_IS_EVENT_TRANSFER_TX_COMPLETED(message)) { // do nothing } }
DocumentPage::DocumentPage(const QString& filePath, QGraphicsItem *parent) : MApplicationPage(parent) , currentPage(1) , m_pinchInProgress(false) , m_endScale(1.0) , m_blockRecenter(false) , pageLoaded(false) , m_defaultZoomLevelAction(ActionPool::ZoomFitToWidth) , pageIndicator(0) , m_infoBanner(0) , shareIf(0) , searchstring("") , searchingTimeout(false) , zoomAction(0) , indicatorAction(0) , zoomCombobox(0) , indicatorCombobox(0) , searchStarted(false) , noMatches(false) , totalPage(1) , liveDocument(0) , bounceAnimation(0) , jumpToPageOverlay(0) , findtoolbar(0) , quickViewToolbar(0) , quickViewer(false) , m_pageView(new ZoomBackground(this)) , m_lastZoomFactor(1.0) { setView(m_pageView); documentName = filePath; setObjectName("documentpage"); // double click interval setting to 325ms QApplication::setDoubleClickInterval(DOUBLETAP_INTERVAL); setAutoMarginsForComponentsEnabled(false); setComponentsDisplayMode(MApplicationPage::AllComponents, MApplicationPageModel::Hide); setEscapeMode(MApplicationPageModel::EscapeCloseWindow); qRegisterMetaType<ZoomLevel>("ZoomLevel"); m_autoHideTimer.setSingleShot(true); m_autoHideTimer.setInterval(NAVI_BAR_TIMEOUT); m_shortTapTimer.setSingleShot(true); m_shortTapTimer.setInterval(QApplication::doubleClickInterval()); searchTimer.setSingleShot(true); searchTimer.setInterval(searchDelay); connect(&searchTimer, SIGNAL(timeout()), this, SLOT(searchTimeout())); connect(&m_shortTapTimer, SIGNAL(timeout()), this, SLOT(shortTapEvent())); connect(&m_autoHideTimer, SIGNAL(timeout()), this, SLOT(autoHideToolbar())); connect(this, SIGNAL(backButtonClicked()), this, SLOT(onClose())); connect(ActionPool::instance(), SIGNAL(destroyed(QObject *)), this, SLOT(removeActions())); connect(this, SIGNAL(loadSuccess(QString)), SLOT(updateViewerType())); connect(MInputMethodState::instance(), SIGNAL(inputMethodAreaChanged(const QRect &)), this, SLOT(sendVisibleAreayChanged())); }
// process a channel event message // XXX should re-use ANTMessage rather than // raw message data void ANTChannel::channelEvent(unsigned char *ant_message) { unsigned char *message=ant_message+2; //qDebug()<<"channel event:"<< ANTMessage::channelEventMessage(*(message+1)); if (MESSAGE_IS_RESPONSE_NO_ERROR(message)) { attemptTransition(RESPONSE_NO_ERROR_MESSAGE_ID(message)); } else if (MESSAGE_IS_EVENT_CHANNEL_CLOSED(message)) { parent->sendMessage(ANTMessage::unassignChannel(number)); } else if (MESSAGE_IS_EVENT_RX_SEARCH_TIMEOUT(message)) { // timeouts are normal for search channel if (channel_type_flags & CHANNEL_TYPE_QUICK_SEARCH) { channel_type_flags &= ~CHANNEL_TYPE_QUICK_SEARCH; channel_type_flags |= CHANNEL_TYPE_WAITING; emit searchTimeout(number); } else { emit lostInfo(number); channel_type=CHANNEL_TYPE_UNUSED; channel_type_flags=0; device_number=0; value2=value=0; setId(); parent->sendMessage(ANTMessage::unassignChannel(number)); } //XXX channel_manager_start_waiting_search(self->parent); } else if (MESSAGE_IS_EVENT_RX_FAIL(message)) { messages_dropped++; double t=get_timestamp(); if (t > (last_message_timestamp + timeout_drop)) { if (channel_type != CHANNEL_TYPE_UNUSED) emit dropInfo(number, messages_dropped, messages_received); // this is a hacky way to prevent the drop message from sending multiple times last_message_timestamp+=2*timeout_drop; } } else if (MESSAGE_IS_EVENT_RX_ACKNOWLEDGED(message)) { exit(-10); } else if (MESSAGE_IS_EVENT_TRANSFER_TX_COMPLETED(message)) { if (tx_ack_disposition) {} //XXX tx_ack_disposition(); } else { // XXX not handled! } }