login::login(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::login)
{
    ui->setupUi(this);


    setWindowTitle("Welcome to Crypt-Chat!");


    mysocket = new QTcpSocket(this);
    buffer = new QBuffer(this);
    buffer->open(QIODevice::ReadWrite);
    ui->login_2->setDefault(true);


    this->connect(ui->createnew,SIGNAL(clicked()),this,SLOT(opennew()));
    this->connect(ui->changepass,SIGNAL(clicked()),this,SLOT(changepassw()));
    this->connect(ui->login_2,SIGNAL(clicked()),this,SLOT(checklogin()));
    connect(this, SIGNAL(enterlogin()), this, SLOT(checklogin()));
    this->connect(ui->settingsbutton,SIGNAL(clicked()), this, SLOT(settingsb()));

    connect(mysocket, SIGNAL(readyRead()), SLOT(receiveMessage()));
    connect(this, SIGNAL(loginfosend(string*)), SLOT(sendMessage(string*)));
    connect(this, SIGNAL(sendforkey(string*)), SLOT(sendMessage(string*)));
    connect(this, SIGNAL(logconnect()), SLOT(toggleConnection()));
    connect(this, SIGNAL(connectfailed()), this, SLOT(connectfalse()));
    connect(this, SIGNAL(connectworked()), this, SLOT(connecttrue()));

 }
示例#2
0
void MainWindow::SetConnectionState()
{
    qDebug() << __FUNCTION__;
    /* force querier to disconnect */
    liveEditingEnabled = false;
    querier->device_lost = true;
    querier->still_not_exists = false;
    toggleConnection(!deviceStatus, true);

    if(deviceStatus)
        querier->timer.setInterval(0);
}
示例#3
0
void MainWindow::readFromConfig()
{
    //switchLanguage(NULL);

    /* read saved state */
    readSettings(&settings, false);

    toggleASQLow(ui->checkBox_asq_detectLow->isChecked());
    toggleASQHigh(ui->checkBox_asq_detectHigh->isChecked());

    toggleTransmitPilot(ui->checkBox_transmitter_pilot->isChecked());
    toggleTransmitRds(ui->checkBox_transmitter_rds->isChecked());
    toggleTransmitEnabled(ui->checkBox_transmitter_enabled->isChecked());

    toggleRDSaf(ui->checkBox_rds_useaf->isChecked());
    toggleRDSfifo(ui->checkBox_rds_fifo->isChecked());
    toggleRDSPSVisibility(ui->spinBox_rds_ps_msgs->value());
    UpdateRDSRTFileEnabled(ui->checkBox_rds_title_file->isChecked());
    UpdateRDSRTPlusEnabled();
    //updateHTTPListener();

    createLanguageMenu();
    ui->actionSelect_Language->setMenu(languageMenu);

    setupTrayIcon();
    SetWindowMode(!ui->checkBox_mini_mode->isChecked());
    SetAudioCompLimPresetByParams();

    /* actions for querier */
    if(ui->checkBox_rds_time->isChecked()) {
        querier->rdsInterval = ui->spinBox_rds_time_int->value() * 1000;
    }

    /* try to connect */
    toggleConnection(false, false);
    if(ui->checkBox_sw_autoconnect->isChecked())
        querier->timer.start();
    else {
        QStatusBar *status = statusBar();
        status->showMessage(tr("Default config editing mode..."));
        status->show();
    }

    this->adjustSize();
    this->resize(1,1);
    this->updateGeometry();

    qDebug() << __FUNCTION__;
}
示例#4
0
changepassword::changepassword(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::changepassword)
{
    ui->setupUi(this);
    setWindowTitle("Change Password");
    changesocket = new QTcpSocket(this);
    buffer = new QBuffer(this);
    buffer->open(QIODevice::ReadWrite);

    connect(changesocket, SIGNAL(readyRead()), SLOT(receiveMessage()));
    connect(this, SIGNAL(connectworked(QString*)), SLOT(sendMessage(QString*)));
    connect(this, SIGNAL(logconnect()), SLOT(toggleConnection()));
    connect(this, SIGNAL(receivedthis(string)), this , SLOT(checkiftrue(string)));


    this->connect(ui->submit,SIGNAL(clicked()), this, SLOT(changepass()));
    this->connect(ui->cancel,SIGNAL(clicked()), this, SLOT(cancel()));
}
示例#5
0
void MainWindow::RedrawEverything(bool bFound)
{
    int ret, transmitting;
    char cpuid[32];
    char rev[32];
    QStatusBar *status = statusBar();
    qDebug() << __FUNCTION__;
    fmtxEEPROMInfoClean();

    liveEditingEnabled=false;
    querier->is_ready=false;
    deviceStatus=bFound;

    toggleConnection(bFound, false);
    if(!bFound) {
        querier->is_ready=ui->checkBox_sw_autoconnect->isChecked();
        if(!ui->checkBox_sw_autoconnect->isChecked())
            querier->timer.stop();
        qDebug() << "frontend flagged as" << bFound << " returning.";
        if(!is_normal || !this->isVisible())
            trayIcon->showMessage(tr("FmStick disconnected"),
                        tr("Device disconnected!"),
                        QSystemTrayIcon::Information, 5 * 1000);
        return;
    }

    status->showMessage(tr("(Re)Reading frontend info..."), 10000);
    status->show();

    cpuid[0] = '\0';
    rev[0] = '\0';
    querier->HidAccessMutex.lock();
    ret = fmtxIoAppIdString(cpuid, rev);
    querier->HidAccessMutex.unlock();
    if(ret!=FMTX_MODE_OK) {
        qDebug() << "can't get id string";
        goto redraw_err;
    }
    qDebug() << "got CPU ID: "<<QString(cpuid)<<" rev.:"<<QString(rev);
    ui->lineEdit_hw_id_cpuid->setText(QString(cpuid));
    ui->lineEdit_hw_id_cpufwid->setText(QString(rev));


    status->showMessage(tr("Reading EEPROM..."), 10000);
    status->show();
    qDebug() << "Reading EEPROM...";
    querier->HidAccessMutex.lock();
    fmtxCmdSpecial = FMTX_SPECIAL_EEPROM;   ///< now work with eeprom instead of frontend
    ret=fmtxEEPROMReadConfig();
    fmtxCmdSpecial = FMTX_SPECIAL_FRONTEND;
    querier->HidAccessMutex.unlock();

    ui->checkBox_hw_run_txAtPowerUp->blockSignals(true);
    ui->checkBox_hw_run_txAtPowerUp->setChecked(fmtxEEPROMGetStartupFlag());
    ui->checkBox_hw_run_txAtPowerUp->blockSignals(false);

    if(ret==FMTX_MODE_POWER_DOWN) {
        qDebug() << "EEPROM is empty yet!";
    } else if(ret!=FMTX_MODE_OK) {
        qDebug() << "Can't read EEPROM";
        goto redraw_err;
    }
    qDebug() << "EEPROM Readed..";


    transmitting = 0;
    querier->HidAccessMutex.lock();
    ret = fmtxIoAppFeGetMode(&transmitting);
    querier->HidAccessMutex.unlock();
    qDebug() << "Frontend mode: " << ret << "transmitting: " << transmitting;
    if(ret == FMTX_MODE_POWER_DOWN){
        qDebug() << "Frontend powered down!";
        ret = SetFrontendPowerUp();
    }

    if(ret!=FMTX_MODE_POWER_UP && ret!=FMTX_MODE_TRANSMITTING) {
        qDebug() << "Frontend not found..";
        SetTransmitIcon(ICON_WARN);
        goto redraw_err;
    }

    if(transmitting) {
        qDebug() << "Already transmitting!";
        SetTransmitIcon(ICON_TX);
    }

    /* needed to detect if hardware supports rds */
    querier->HidAccessMutex.lock();
    DisplayFirmwareInfo();
    querier->HidAccessMutex.unlock();
    if(fmtxCmdStatus!=FMTX_MODE_OK)
        goto redraw_err;

    if(ui->checkBox_rewriteCfg->isChecked()) {
        qDebug() << "Forcing configuration from software, instead of hardware!";
        status->showMessage("Writing running config...", 10000);
        status->show();
        if(SetFrontendParams()!=FMTX_MODE_OK)
            goto redraw_err;
        //hack for digital audio
        if(! SetDigitalAudioHack())
                goto redraw_err;
    }

    status->showMessage(tr("Reading running config..."), 10000);
    status->show();
    querier->HidAccessMutex.lock();
    ret=GetFrontendParams();
    querier->HidAccessMutex.unlock();

    if(ret!=FMTX_MODE_OK)
        goto redraw_err;

    liveEditingEnabled=ui->checkBox_sw_live_edit->isChecked();
    statusBar()->hide();
    this->adjustSize();
    this->resize(1,1);
    this->updateGeometry();
    querier->is_ready=true;

    qDebug() << "Redraw everything done! transmitting: " << transmitting;
    if(!is_normal || !this->isVisible())
        trayIcon->showMessage(tr("FmStick connected"),
                    tr("Device found and connected!%1")
                              .arg( transmitting ? tr("\nAnd transmitter is powered on!") : ""),
                    QSystemTrayIcon::Information, 5 * 1000);
    return;

redraw_err:
    if(!is_normal || !this->isVisible())
        trayIcon->showMessage(tr("FmStick not connected"), tr("Can't connect to frontend!"),
                          QSystemTrayIcon::Critical, 5 * 1000);
    status->showMessage(tr("Can't connect to frontend!"), 10000);
    status->show();
    qDebug() << "Error while redraw everything";
    querier->is_ready=true;
    SetTransmitIcon(ICON_ERR);
}
示例#6
0
KiloWindow::KiloWindow(QWidget *parent): QWidget(parent), device(0), sending(false), connected(false) {
    // Create status bar
    status = new QStatusBar();
    status->showMessage("disconnected.");
    status->setSizeGripEnabled(false);

    // Create status bar button
    connect_button = new QToolButton(status);
    status->addPermanentWidget(connect_button);
    connect_button->setText("Connect");
    connect(connect_button, SIGNAL(clicked()), this, SLOT(toggleConnection()));

    // Create serial input window and its trigger button
    serial_button = new QPushButton("Serial Input");
    serial = new SerialWindow("Serial Input", this);
    QObject::connect(serial_button, SIGNAL(clicked()), this, SLOT(serialShow()));

    // Create calibration window and its trigger button
    calib_button = new QPushButton("Calibration");
    calib = new CalibWindow("Calibration Values", this);
    QObject::connect(calib_button, SIGNAL(clicked()), this, SLOT(calibShow()));

    connect(calib, SIGNAL(calibUID(int)), this, SLOT(calibUID(int)));
    connect(calib, SIGNAL(calibLeft(int)), this, SLOT(calibLeft(int)));
    connect(calib, SIGNAL(calibRight(int)), this, SLOT(calibRight(int)));
    connect(calib, SIGNAL(calibStraight(int)), this, SLOT(calibStraight(int)));
    connect(calib, SIGNAL(calibStop()), this, SLOT(calibStop()));
    connect(calib, SIGNAL(calibSave()), this, SLOT(calibSave()));

    QVBoxLayout *vbox = new QVBoxLayout;
    vbox->addWidget(createDeviceSelect());
    vbox->addWidget(createFileInput());
    vbox->addWidget(createCommands());
    vbox->addWidget(serial_button);
    vbox->addWidget(calib_button);
    vbox->addWidget(status);

    setLayout(vbox);
    setWindowTitle("Kilobots Toolkit");
    setWindowIcon(QIcon(":/images/kilogui.png"));
    setWindowState(Qt::WindowActive);


    vusb_conn = new VUSBConnection();
    ftdi_conn = new FTDIConnection();
    serial_conn = new SerialConnection();
    connect(ftdi_conn, SIGNAL(readText(QString)), serial, SLOT(addText(QString)));
    connect(serial_conn, SIGNAL(readText(QString)), serial, SLOT(addText(QString)));

    connect(vusb_conn, SIGNAL(error(QString)), this, SLOT(showError(QString)));
    connect(vusb_conn, SIGNAL(status(QString)), this, SLOT(vusbUpdateStatus(QString)));
    connect(ftdi_conn, SIGNAL(error(QString)), this, SLOT(showError(QString)));
    connect(ftdi_conn, SIGNAL(status(QString)), this, SLOT(ftdiUpdateStatus(QString)));
    connect(serial_conn, SIGNAL(error(QString)), this, SLOT(showError(QString)));
    connect(serial_conn, SIGNAL(status(QString)), this, SLOT(serialUpdateStatus(QString)));

    // Create thread
    QThread *thread = new QThread();
    connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));

    // Move connections to thread
    vusb_conn->moveToThread(thread);
    ftdi_conn->moveToThread(thread);
    serial_conn->moveToThread(thread);

    // Start thread and open connections
    thread->start();
    vusb_conn->open();
    ftdi_conn->open();
    serial_conn->open();
}