void AccountWidget::setupConnections( const QPersistentModelIndex& idx, int accountIdx ) { m_myFactoryIdx = idx; m_myAccountIdx = accountIdx; Tomahawk::Accounts::Account* account = idx.data( Tomahawk::Accounts::AccountModel::ChildrenOfFactoryRole ) .value< QList< Tomahawk::Accounts::Account* > >().at( accountIdx ); if ( account ) { connect( m_statusToggle, SIGNAL( toggled( bool ) ), this, SLOT( changeAccountConnectionState( bool ) ) ); connect( m_inviteButton, SIGNAL( clicked() ), this, SLOT( sendInvite() ) ); connect( m_inviteEdit, SIGNAL( returnPressed() ), this, SLOT( sendInvite() ) ); if ( account->sipPlugin() ) { m_inviteEdit->setPlaceholderText( account->sipPlugin()->inviteString() ); connect( account->sipPlugin(), SIGNAL( inviteSentSuccess( QString ) ), SLOT( onInviteSentSuccess( QString ) ) ); connect( account->sipPlugin(), SIGNAL( inviteSentFailure( QString ) ), SLOT( onInviteSentFailure( QString ) ) ); } } }
/** Constructor */ MessageWidget::MessageWidget(bool controlled, QWidget *parent, Qt::WindowFlags flags) : QWidget(parent, flags), toolButtonReply(NULL) { /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); isControlled = controlled; isWindow = false; currMsgFlags = 0; connect(ui.msgList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(msgfilelistWidgetCostumPopupMenu(QPoint))); connect(ui.expandFilesButton, SIGNAL(clicked()), this, SLOT(togglefileview())); connect(ui.downloadButton, SIGNAL(clicked()), this, SLOT(getallrecommended())); connect(ui.msgText, SIGNAL(anchorClicked(QUrl)), this, SLOT(anchorClicked(QUrl))); connect(ui.sendInviteButton, SIGNAL(clicked()), this, SLOT(sendInvite())); connect(NotifyQt::getInstance(), SIGNAL(messagesTagsChanged()), this, SLOT(messagesTagsChanged())); connect(NotifyQt::getInstance(), SIGNAL(messagesChanged()), this, SLOT(messagesChanged())); ui.imageBlockWidget->addButtonAction(tr("Load images always for this message"), this, SLOT(loadImagesAlways()), true); ui.msgText->setImageBlockWidget(ui.imageBlockWidget); /* hide the Tree +/- */ ui.msgList->setRootIsDecorated( false ); ui.msgList->setSelectionMode( QAbstractItemView::ExtendedSelection ); /* Set header resize modes and initial section sizes */ QHeaderView * msglheader = ui.msgList->header () ; QHeaderView_setSectionResizeModeColumn(msglheader, COLUMN_FILE_NAME, QHeaderView::Interactive); QHeaderView_setSectionResizeModeColumn(msglheader, COLUMN_FILE_SIZE, QHeaderView::Interactive); QHeaderView_setSectionResizeModeColumn(msglheader, COLUMN_FILE_HASH, QHeaderView::Interactive); msglheader->resizeSection (COLUMN_FILE_NAME, 200); msglheader->resizeSection (COLUMN_FILE_SIZE, 100); msglheader->resizeSection (COLUMN_FILE_HASH, 200); QFont font = QFont("Arial", 10, QFont::Bold); ui.subjectText->setFont(font); ui.toText->setMaximumHeight(ui.toText->fontMetrics().lineSpacing()*1.5); ui.ccLabel->setVisible(false); ui.ccText->setVisible(false); ui.ccText->setMaximumHeight(ui.ccText->fontMetrics().lineSpacing()*1.5); ui.bccLabel->setVisible(false); ui.bccText->setVisible(false); ui.bccText->setMaximumHeight(ui.bccText->fontMetrics().lineSpacing()*1.5); ui.tagsLabel->setVisible(false); ui.msgText->activateLinkClick(false); if (isControlled == false) { processSettings("MessageWidget", true); } ui.dateText-> setText(""); ui.inviteFrame->hide(); }
/** Default constructor */ IdDetailsDialog::IdDetailsDialog(const RsGxsGroupId& id, QWidget *parent) : QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint), mId(id), ui(new Ui::IdDetailsDialog) { /* Invoke Qt Designer generated QObject setup routine */ ui->setupUi(this); setAttribute (Qt::WA_DeleteOnClose,true); /* Setup UI helper */ mStateHelper = new UIStateHelper(this); mStateHelper->addWidget(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_Nickname); mStateHelper->addWidget(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_KeyId); mStateHelper->addWidget(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_GpgId); mStateHelper->addWidget(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_GpgName); mStateHelper->addWidget(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_Type); mStateHelper->addWidget(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_LastUsed); mStateHelper->addWidget(IDDETAILSDIALOG_IDDETAILS, ui->ownOpinion_CB); mStateHelper->addWidget(IDDETAILSDIALOG_IDDETAILS, ui->overallOpinion_TF); mStateHelper->addWidget(IDDETAILSDIALOG_IDDETAILS, ui->neighborNodesOpinion_TF); mStateHelper->addLoadPlaceholder(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_Nickname); mStateHelper->addLoadPlaceholder(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_GpgName); mStateHelper->addLoadPlaceholder(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_KeyId); mStateHelper->addLoadPlaceholder(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_GpgId); mStateHelper->addLoadPlaceholder(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_Type); mStateHelper->addLoadPlaceholder(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_LastUsed); mStateHelper->addLoadPlaceholder(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_GpgName); mStateHelper->addClear(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_Nickname); mStateHelper->addClear(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_KeyId); mStateHelper->addClear(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_GpgId); mStateHelper->addClear(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_Type); mStateHelper->addClear(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_LastUsed); mStateHelper->addClear(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_GpgName); mStateHelper->setActive(IDDETAILSDIALOG_REPLIST, false); /* Create token queue */ mIdQueue = new TokenQueue(rsIdentity->getTokenService(), this); Settings->loadWidgetInformation(this); ui->headerFrame->setHeaderImage(QPixmap(":/images/identity/identity_64.png")); ui->headerFrame->setHeaderText(tr("Person Details")); //connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(changeGroup())); connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject())); connect(ui->ownOpinion_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(modifyReputation())); connect(ui->autoBanIdentities_CB, SIGNAL(toggled(bool)), this, SLOT(toggleAutoBanIdentities(bool))); connect(ui->inviteButton, SIGNAL(clicked()), this, SLOT(sendInvite())); requestIdDetails(); }
void AmB2ABCalleeSession::onB2ABEvent(B2ABEvent* ev) { if(ev->event_id == B2ABConnectLeg){ try { B2ABConnectLegEvent* co_ev = dynamic_cast<B2ABConnectLegEvent*>(ev); assert(co_ev); MONITORING_LOG4(getLocalTag().c_str(), "b2b_leg", other_id.c_str(), "from", co_ev->local_party.c_str(), "to", co_ev->remote_party.c_str(), "ruri", co_ev->remote_uri.c_str()); dlg.local_party = co_ev->local_party; dlg.local_uri = co_ev->local_uri; dlg.remote_party = co_ev->remote_party; dlg.remote_uri = co_ev->remote_uri; setCallgroup(co_ev->callgroup); setNegotiateOnReply(true); if (sendInvite(co_ev->headers)) { throw string("INVITE could not be sent\n"); } return; } catch(const AmSession::Exception& e){ ERROR("%i %s\n",e.code,e.reason.c_str()); relayEvent(new B2ABConnectOtherLegExceptionEvent(e.code,e.reason)); setStopped(); } catch(const string& err){ ERROR("startSession: %s\n",err.c_str()); relayEvent(new B2ABConnectOtherLegExceptionEvent(500,err)); setStopped(); } catch(...){ ERROR("unexpected exception\n"); relayEvent(new B2ABConnectOtherLegExceptionEvent(500,"unexpected exception")); setStopped(); } } AmB2ABSession::onB2ABEvent(ev); }
void AmB2ABCalleeSession::onB2ABEvent(B2ABEvent* ev) { if(ev->event_id == B2ABConnectLeg){ try { B2ABConnectLegEvent* co_ev = dynamic_cast<B2ABConnectLegEvent*>(ev); assert(co_ev); dlg.local_party = co_ev->local_party; dlg.local_uri = co_ev->local_uri; dlg.remote_party = co_ev->remote_party; dlg.remote_uri = co_ev->remote_uri; // set outbound proxy as next hop if (!AmConfig::OutboundProxy.empty()) dlg.next_hop = AmConfig::OutboundProxy; setCallgroup(co_ev->callgroup); setNegotiateOnReply(true); if (sendInvite(co_ev->headers)) { throw string("INVITE could not be sent\n"); } return; } catch(const AmSession::Exception& e){ ERROR("%i %s\n",e.code,e.reason.c_str()); relayEvent(new B2ABConnectOtherLegExceptionEvent(e.code,e.reason)); setStopped(); } catch(const string& err){ ERROR("startSession: %s\n",err.c_str()); relayEvent(new B2ABConnectOtherLegExceptionEvent(500,err)); setStopped(); } catch(...){ ERROR("unexpected exception\n"); relayEvent(new B2ABConnectOtherLegExceptionEvent(500,"unexpected exception")); setStopped(); } } AmB2ABSession::onB2ABEvent(ev); }
void* UserAgent::run(void* arg) { common = (Common *)arg; init(0); while(common->go) { memo = (Memo*)common->signalQ->waitForData(waitMSec); if(memo) switch(memo->code) { case VIVOCE_SIP_INVITE: if(state==SIP_UA_DISCONNECTED) { //printf("\n\tSending INVITE...."); name = strtok_r(memo->bytes,"@",&temp); remoteId = (char*)malloc(strlen(name)+1); sprintf(remoteId,"%s",name); name = strtok_r(NULL,":",&temp); if(name) { remoteHost = (char*) malloc(strlen(name)+1); sprintf(remoteHost,"%s",name); name=name = strtok_r(NULL,":",&temp); if(name) remoteSipPort = atoi(name); else remoteSipPort = VIVOCE_SIP_PORT; sendInvite(); common->reset(); } else { printf("\n\tSIP: Malformed URI"); common->sipRmg->releaseMemo(memo); } } else common->sipRmg->releaseMemo(memo); break; case VIVOCE_SIP_BYE: if(common->isConnected) { common->isConnected=0; printf("\n\tDisconnecting...."); rptCount=0; sendBye(); } else common->sipRmg->releaseMemo(memo); break; case VIVOCE_SIP_ACCEPT: if(state == SIP_UA_RCVD_INV) { //printf("\n\tSending OK...."); sendOk(); state = SIP_UA_ACCEPTED; common->isRinging=0; } else common->sipRmg->releaseMemo(memo); break; case VIVOCE_SIP_REJECT: if(state == SIP_UA_RCVD_INV) { //printf("\n\tSending DECLINE...."); sendDecline(); common->isRinging=0; } else common->sipRmg->releaseMemo(memo); break; case VIVOCE_SIP_RCVD: //incoming!! if(common->verbose) { printf("\n\tINFO: SIP Msg Recv=%d bytes:\n%s", memo->data1,memo->bytes); } sipPackRecv->reset(); ret = SIPHandler::read(memo->bytes, memo->data1, sipPackRecv); if(ret<0) { printf("\n\tSIP: Error in parsing SIP packet"); } else { if((!sipPackRecv->isRequest) && (sipPackRecv->responseCode!=SIP_RESPONSE_OK)) { printf("\n\tSIP: Received response code %d.", sipPackRecv->responseCode); } switch(state) { case SIP_UA_DISCONNECTED: if((sipPackRecv->isRequest) && (sipPackRecv->requestCode==SIP_METHOD_INV)) { checkPacket(); if(discard) { printf("\n\tSIP: Incorrect SDP content: discarding"); common->sipRmg->releaseMemo(memo); checkSrc=false; } else { callId = sipPackRecv->callId; callIdHost = (char*)malloc(strlen(sipPackRecv->callIdHost)+1); sprintf(callIdHost, "%s", sipPackRecv->callIdHost); //memory leak in these mallocs, but fixing them with realloc causes segfaults! for now, waste these ~100 bytes... remoteId = (char*)malloc(strlen(sipPackRecv->contactUri.id)+1); sprintf(remoteId, "%s", sipPackRecv->contactUri.id); remoteHost = (char*)malloc(strlen(sipPackRecv->contactUri.host)+1); sprintf(remoteHost,"%s", sipPackRecv->contactUri.host); printf("\n\tSIP: Recvd invite from %s at %s!!!", sipPackRecv->contactUri.id, sipPackRecv->contactUri.host); printf("\n\tRing!!!"); sendRinging(); waitMSec=2500; state = SIP_UA_RCVD_INV; defaultAction = SIP_SEND_RING; } } else common->sipRmg->releaseMemo(memo); //else discard break; case SIP_UA_SENT_INV: if((!sipPackRecv->isRequest) && (sipPackRecv->callId == callId) && (!strcmp(callIdHost,sipPackRecv->callIdHost))) { if(sipPackRecv->responseCode==SIP_RESPONSE_RING) { printf("\n\tSIP: Ringing callee...."); common->isRinging=1; waitMSec=5000; defaultAction = SIP_CONN; //display ringing for some time common->sipRmg->releaseMemo(memo); } else if(sipPackRecv->responseCode==SIP_RESPONSE_BUSY) { printf("\n\tSIP: Callee is Busy! Try again later"); waitMSec=500; defaultAction = SIP_DISCONN; common->sipRmg->releaseMemo(memo); common->isRinging=0; } else if(sipPackRecv->responseCode==SIP_RESPONSE_DECLINE) { printf("\n\tSIP: Callee has declined to accept your call"); waitMSec=500; defaultAction = SIP_DISCONN; common->sipRmg->releaseMemo(memo); common->isRinging=0; } else if(sipPackRecv->responseCode==SIP_RESPONSE_OK) { checkPacket(); if(discard) { printf("\n\tSIP: Incorrect SDP content: discarding"); common->sipRmg->releaseMemo(memo); checkSrc=false; } else { if(common->verbose) { printf("\n\tINFO: Listening for RTP/RTCP on ports %d/%d", remoteRtpPort, remoteRtcpPort); } UdpBase::initRemoteAddr(common, remoteHost, remoteRtpPort, remoteRtcpPort, 0); printf("\n\tSIP: Connected!!!"); sendAck(); common->isRinging=0; } } else checkSrc=true; } else checkSrc=true; break; case SIP_UA_SENT_BYE: if(!sipPackRecv->isRequest) { if(sipPackRecv->responseCode==SIP_RESPONSE_OK) { printf("\n\tSIP: Disconnect complete."); state = SIP_UA_DISCONNECTED; cleanup(); defaultAction = SIP_NONE; } common->sipRmg->releaseMemo(memo); } else checkSrc=true; break; case SIP_UA_ACCEPTED: if(sipPackRecv->isRequest && (sipPackRecv->requestCode== SIP_METHOD_ACK) && (sipPackRecv->callId == callId) && (!strcmp(callIdHost, sipPackRecv->callIdHost))) { //printf("\n\tSIP: Acknowledged...."); common->isConnected = 1; common->rtpMgr->init(RTP_PAYLOAD_TYPE_ADPCM, const_cast<char*>("stats")); waitMSec=2500; defaultAction = SIP_NONE; state = SIP_UA_IN_CALL; common->sipRmg->releaseMemo(memo); common->isRinging=0; } else checkSrc=true; break; case SIP_UA_REJECTED: if(sipPackRecv->isRequest && (sipPackRecv->requestCode== SIP_METHOD_ACK) && (sipPackRecv->callId == callId) && (!strcmp(callIdHost,sipPackRecv->callIdHost))) { //printf("\n\tSIP: Acknowledged...."); common->isConnected=0; waitMSec=500; defaultAction = SIP_DISCONN; common->sipRmg->releaseMemo(memo); common->isRinging=0; } else checkSrc=true; break; case SIP_UA_IN_CALL: if(sipPackRecv->isRequest && (sipPackRecv->requestCode==SIP_METHOD_BYE) && (sipPackRecv->callId == callId)) { //printf("\n\tSending OK for BYE...."); printf("\n\tSIP: Disconnected by peer."); sendOk(); common->isConnected=0; waitMSec=2500; defaultAction = SIP_DISCONN; state = SIP_UA_DISCONNECTED; } else checkSrc=true; break; default: checkSrc=true; break; } if(checkSrc) { checkSrc=false; if(sipPackRecv->callId != callId) { //printf("\n\tSending BUSY"); UdpBase::initTempRemoteAddr(common, sipPackRecv->contactUri.host, remoteSipPort); sendBusy(); } else common->sipRmg->releaseMemo(memo); } break; } break; default: printf("\n\tSIP: In invalid state! %d",state); common->sipRmg->releaseMemo(memo); break; case VIVOCE_RESPOND: printf("\n\tUser Agent active - %d",state); common->sipRmg->releaseMemo(memo); break; } else doDefaultAction(); } printf("UserAgent stopped. "); return NULL; }