Exemplo n.º 1
0
/** Default constructor */
ProfileWidget::ProfileWidget(QWidget *parent, Qt::WindowFlags flags)
  : QWidget(parent, flags)
{
    /* Invoke Qt Designer generated QObject setup routine */
    ui.setupUi(this);

    connect(ui.editstatustoolButton,SIGNAL(clicked()), this, SLOT(statusmessagedlg()));
    connect(ui.CopyCertButton,SIGNAL(clicked()), this, SLOT(copyCert()));
    connect(ui.profile_Button,SIGNAL(clicked()), this, SLOT(profilemanager()));

    ui.onlinesince->setText(DateTime::formatLongDateTime(Rshare::startupTime()));
}
Exemplo n.º 2
0
void ConnectFriendWizard::initializePage(int id)
{
    switch ((Page) id) {
    case Page_Intro:
        ui->textRadioButton->setChecked(true);
        break;
    case Page_Text:
        connect(ui->userCertHelpButton, SIGNAL( clicked()), this, SLOT(showHelpUserCert()));
        connect(ui->userCertIncludeSignaturesButton, SIGNAL(clicked()), this, SLOT(toggleSignatureState()));
        connect(ui->userCertOldFormatButton, SIGNAL(clicked()), this, SLOT(toggleFormatState()));
        connect(ui->userCertCopyButton, SIGNAL(clicked()), this, SLOT(copyCert()));
        connect(ui->userCertSaveButton, SIGNAL(clicked()), this, SLOT(saveCert()));
        connect(ui->userCertMailButton, SIGNAL(clicked()), this, SLOT(runEmailClient()));
        connect(ui->friendCertEdit, SIGNAL(textChanged()), this, SLOT(friendCertChanged()));

        cleanfriendCertTimer = new QTimer(this);
        cleanfriendCertTimer->setSingleShot(true);
        cleanfriendCertTimer->setInterval(1000); // 1 second
        connect(cleanfriendCertTimer, SIGNAL(timeout()), this, SLOT(cleanFriendCert()));

        ui->userCertOldFormatButton->setChecked(true);

        toggleFormatState(false);
        toggleSignatureState(false);
        updateOwnCert();

        cleanFriendCert();

        break;
    case Page_Cert:
        connect(ui->userFileCreateButton, SIGNAL(clicked()), this, SLOT(generateCertificateCalled()));
        connect(ui->friendFileNameOpenButton, SIGNAL(clicked()), this, SLOT(loadFriendCert()));

        ui->friendFileNameEdit->setAcceptFile(true);

        ui->CertificatePage->registerField("friendCertificateFile*", ui->friendFileNameEdit);
        break;
    case Page_Foff:
        ui->userSelectionCB->addItem(tr("Any peer I've not signed"));
        ui->userSelectionCB->addItem(tr("Friends of my friends who already trust me"));
        ui->userSelectionCB->addItem(tr("Signed peers showing as denied"));

        ui->selectedPeersTW->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("")));
        ui->selectedPeersTW->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Peer name")));
        ui->selectedPeersTW->setHorizontalHeaderItem(2, new QTableWidgetItem(tr("Also signed by")));
        ui->selectedPeersTW->setHorizontalHeaderItem(3, new QTableWidgetItem(tr("Peer id")));

        connect(ui->makeFriendButton, SIGNAL(clicked()), this, SLOT(signAllSelectedUsers()));
        connect(ui->userSelectionCB, SIGNAL(activated(int)), this, SLOT(updatePeersList(int)));

        updatePeersList(ui->userSelectionCB->currentIndex());

        ui->FofPage->setComplete(false);
        break;
    case Page_Rsid:
        ui->RsidPage->registerField("friendRSID*", ui->friendRsidEdit);
        break;
    case Page_Email:
        ui->EmailPage->registerField("addressEdit*", ui->addressEdit);
        ui->EmailPage->registerField("subjectEdit*", ui->subjectEdit);

        ui->subjectEdit->setText(tr("RetroShare Invitation"));
        ui->inviteTextEdit->setPlainText(GetStartedDialog::GetInviteText());

        break;
    case Page_ErrorMessage:
        break;
    case Page_Conclusion:
    {
        std::cerr << "Conclusion page id : " << peerDetails.id << "; gpg_id : " << peerDetails.gpg_id << std::endl;

        ui->_anonymous_routing_CB_2->setChecked(peerDetails.service_perm_flags & RS_SERVICE_PERM_TURTLE) ;
        ui->_discovery_CB_2        ->setChecked(peerDetails.service_perm_flags & RS_SERVICE_PERM_DISCOVERY) ;
        ui->_forums_channels_CB_2  ->setChecked(peerDetails.service_perm_flags & RS_SERVICE_PERM_DISTRIB) ;
        ui->_direct_transfer_CB_2  ->setChecked(peerDetails.service_perm_flags & RS_SERVICE_PERM_DIRECT_DL) ;

        RsPeerDetails tmp_det ;
        bool already_in_keyring = rsPeers->getPeerDetails(peerDetails.gpg_id, tmp_det) ;

        ui->addKeyToKeyring_CB->setChecked(true) ;
        ui->addKeyToKeyring_CB->setEnabled(!already_in_keyring) ;

        if(already_in_keyring)
            ui->addKeyToKeyring_CB->setToolTip(tr("This key is already in your keyring")) ;
        else
            ui->addKeyToKeyring_CB->setToolTip(tr("Check this to add the key to your keyring\nThis might be useful for sending\ndistant messages to this peer\neven if you don't make friends.")) ;

        //set the radio button to sign the GPG key
        if (peerDetails.accept_connection && !peerDetails.ownsign) {
            //gpg key connection is already accepted, don't propose to accept it again
            ui->signGPGCheckBox->setChecked(false);
            ui->acceptNoSignGPGCheckBox->hide();
            ui->acceptNoSignGPGCheckBox->setChecked(false);
        }
        if (!peerDetails.accept_connection && peerDetails.ownsign) {
            //gpg key is already signed, don't propose to sign it again
            ui->acceptNoSignGPGCheckBox->setChecked(true);
            ui->signGPGCheckBox->hide();
            ui->signGPGCheckBox->setChecked(false);
        }
        if (!peerDetails.accept_connection && !peerDetails.ownsign) {
            ui->acceptNoSignGPGCheckBox->setChecked(true);
            ui->signGPGCheckBox->show();
            ui->signGPGCheckBox->setChecked(false);
            ui->acceptNoSignGPGCheckBox->show();
        }
        if (peerDetails.accept_connection && peerDetails.ownsign) {
            ui->acceptNoSignGPGCheckBox->setChecked(false);
            ui->acceptNoSignGPGCheckBox->hide();
            ui->signGPGCheckBox->setChecked(false);
            ui->signGPGCheckBox->hide();
            ui->alreadyRegisteredLabel->show();
        } else {
            ui->alreadyRegisteredLabel->hide();
        }

        QString trustString;
        switch (peerDetails.validLvl) {
        case RS_TRUST_LVL_ULTIMATE:
            trustString = tr("Ultimate");
            break;
        case RS_TRUST_LVL_FULL:
            trustString = tr("Full");
            break;
        case RS_TRUST_LVL_MARGINAL:
            trustString = tr("Marginal");
            break;
        case RS_TRUST_LVL_NEVER:
            trustString = tr("None");
            break;
        default:
            trustString = tr("No Trust");
            break;
        }

        QString ts;
        std::list<std::string>::iterator it;
        for (it = peerDetails.gpgSigners.begin(); it != peerDetails.gpgSigners.end(); ++it) {
            {
                std::string peer_name = rsPeers->getPeerName(*it) ;

                // This is baaaad code. We should handle this kind of errors with proper exceptions.
                // This happens because signers from a unknown key cannt be found in the keyring, including
                // self-signatures.
                //
                if(peer_name == "[Unknown PGP Cert name]" && *it == peerDetails.gpg_id)
                    peer_name = peerDetails.name ;

                ts += QString("%1<%2>\n").arg(QString::fromUtf8(peer_name.c_str()), QString::fromStdString(*it));
            }
        }

        ui->nameEdit->setText(QString::fromUtf8(peerDetails.name.c_str()));
        ui->trustEdit->setText(trustString);
        ui->emailEdit->setText(QString::fromUtf8(peerDetails.email.c_str()));
        QString loc = QString::fromUtf8(peerDetails.location.c_str());
        if (!loc.isEmpty())
        {
            loc += " (";
            loc += QString::fromStdString(peerDetails.id);
            loc += ")";
        }
        else
        {
            if (!peerDetails.id.empty())
            {
                loc += QString::fromStdString(peerDetails.id);
            }
        }

        ui->locationEdit->setText(loc);
        ui->signersEdit->setPlainText(ts);

        fillGroups(this, ui->groupComboBox, groupId);
    }
    break;
    case Page_FriendRequest:
    {
        std::cerr << "Friend request page id : " << peerDetails.id << "; gpg_id : " << peerDetails.gpg_id << std::endl;

        ui->fr_avatar->setFrameType(AvatarWidget::NORMAL_FRAME);
        setPixmap(QWizard::LogoPixmap, QPixmap(":/images/user/user_request48.png"));

        //set the radio button to sign the GPG key
        if (peerDetails.accept_connection && !peerDetails.ownsign) {
            //gpg key connection is already accepted, don't propose to accept it again
            ui->fr_signGPGCheckBox->setChecked(false);
            ui->fr_acceptNoSignGPGCheckBox->hide();
            ui->fr_acceptNoSignGPGCheckBox->setChecked(false);
        }
        if (!peerDetails.accept_connection && peerDetails.ownsign) {
            //gpg key is already signed, don't propose to sign it again
            ui->fr_acceptNoSignGPGCheckBox->setChecked(true);
            ui->fr_signGPGCheckBox->hide();
            ui->fr_signGPGCheckBox->setChecked(false);
        }
        if (!peerDetails.accept_connection && !peerDetails.ownsign) {
            ui->fr_acceptNoSignGPGCheckBox->setChecked(true);
            ui->fr_signGPGCheckBox->show();
            ui->fr_signGPGCheckBox->setChecked(false);
            ui->fr_acceptNoSignGPGCheckBox->show();
        }
        if (peerDetails.accept_connection && peerDetails.ownsign) {
            ui->fr_acceptNoSignGPGCheckBox->setChecked(false);
            ui->fr_acceptNoSignGPGCheckBox->hide();
            ui->fr_signGPGCheckBox->setChecked(false);
            ui->fr_signGPGCheckBox->hide();
        }

        ui->fr_nameEdit->setText(QString::fromUtf8(peerDetails.name.c_str()));
        ui->fr_emailEdit->setText(QString::fromUtf8(peerDetails.email.c_str()));

        QString loc = QString::fromUtf8(peerDetails.location.c_str());
        if (!loc.isEmpty())
        {
            loc += " (";
            loc += QString::fromStdString(peerDetails.id);
            loc += ")";
        }
        else
        {
            if (!peerDetails.id.empty())
            {
                loc += QString::fromStdString(peerDetails.id);
            }
        }

        ui->fr_locationEdit->setText(loc);

        ui->fr_label->setText(tr("You have a friend request from") + " " + QString::fromUtf8(peerDetails.name.c_str()));

        fillGroups(this, ui->fr_groupComboBox, groupId);
    }
    break;
    case Page_FriendRecommendations:
        ui->frec_recommendList->setHeaderText(tr("Recommend friends"));
        ui->frec_recommendList->setModus(FriendSelectionWidget::MODUS_CHECK);
        ui->frec_recommendList->setShowType(FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_SSL);
        ui->frec_recommendList->start();

        ui->frec_toList->setHeaderText(tr("To"));
        ui->frec_toList->setModus(FriendSelectionWidget::MODUS_CHECK);
        ui->frec_toList->start();

        ui->frec_messageEdit->setText(MessageComposer::recommendMessage());
        break;
    }
}