Ejemplo n.º 1
0
ServicePermissionFlags ConnectFriendWizard::serviceFlags() const
{
    ServicePermissionFlags flags(0) ;

    if (hasVisitedPage(Page_FriendRequest))
    {
        if(  ui->_direct_transfer_CB->isChecked()) flags |= RS_NODE_PERM_DIRECT_DL ;
        if(  ui->_allow_push_CB->isChecked()) flags |= RS_NODE_PERM_ALLOW_PUSH ;
        if(  ui->_require_WL_CB->isChecked()) flags |= RS_NODE_PERM_REQUIRE_WL ;
    } else if (hasVisitedPage(Page_Conclusion)) {
        if(  ui->_direct_transfer_CB_2->isChecked()) flags |= RS_NODE_PERM_DIRECT_DL ;
        if(  ui->_allow_push_CB_2->isChecked()) flags |= RS_NODE_PERM_ALLOW_PUSH ;
        if(  ui->_require_WL_CB_2->isChecked()) flags |= RS_NODE_PERM_REQUIRE_WL ;
    }
    return flags ;
}
Ejemplo n.º 2
0
ServicePermissionFlags ConnectFriendWizard::serviceFlags() const
{
    ServicePermissionFlags flags(0) ;

    if (hasVisitedPage(Page_FriendRequest))
    {
        if(ui->_anonymous_routing_CB->isChecked()) flags |= RS_SERVICE_PERM_TURTLE ;
        if(        ui->_discovery_CB->isChecked()) flags |= RS_SERVICE_PERM_DISCOVERY ;
        if(  ui->_forums_channels_CB->isChecked()) flags |= RS_SERVICE_PERM_DISTRIB ;
        if(  ui->_direct_transfer_CB->isChecked()) flags |= RS_SERVICE_PERM_DIRECT_DL ;
    } else if (hasVisitedPage(Page_Conclusion)) {
        if(ui->_anonymous_routing_CB_2->isChecked()) flags |= RS_SERVICE_PERM_TURTLE ;
        if(        ui->_discovery_CB_2->isChecked()) flags |= RS_SERVICE_PERM_DISCOVERY ;
        if(  ui->_forums_channels_CB_2->isChecked()) flags |= RS_SERVICE_PERM_DISTRIB ;
        if(  ui->_direct_transfer_CB_2->isChecked()) flags |= RS_SERVICE_PERM_DIRECT_DL ;
    }
    return flags ;
}
Ejemplo n.º 3
0
void ConnectFriendWizard::accept()
{
    bool sign = false;
    bool accept_connection = false;
    bool add_key_to_keyring = false;

    if (hasVisitedPage(Page_Conclusion)) {
        std::cerr << "ConnectFriendWizard::accept() called with page conclusion visited" << std::endl;

        sign = ui->signGPGCheckBox->isChecked();
        accept_connection = ui->acceptNoSignGPGCheckBox->isChecked();
        add_key_to_keyring = ui->addKeyToKeyring_CB->isChecked() ;
    } else if (hasVisitedPage(Page_FriendRequest)) {
        std::cerr << "ConnectFriendWizard::accept() called with page friend request visited" << std::endl;

        sign = ui->fr_signGPGCheckBox->isChecked();
        accept_connection = ui->fr_acceptNoSignGPGCheckBox->isChecked();
    } else {
        QDialog::accept();
        return;
    }

    if (!mCertificate.empty() && add_key_to_keyring)
    {
        std::string pgp_id,ssl_id,error_string ;

        if(!rsPeers->loadCertificateFromString(mCertificate,ssl_id,pgp_id,error_string))
        {
            std::cerr << "ConnectFriendWizard::accept(): cannot load that certificate." << std::endl;
            return ;
        }
    }

    bool runProgressDialog = false;

    if(accept_connection && !peerDetails.gpg_id.empty())
    {
        std::cerr << "ConclusionPage::validatePage() accepting GPG key for connection." << std::endl;
        rsPeers->addFriend(peerDetails.id, peerDetails.gpg_id,serviceFlags()) ;
        rsPeers->setServicePermissionFlags(peerDetails.gpg_id,serviceFlags()) ;

        if(sign)
        {
            std::cerr << "ConclusionPage::validatePage() signing GPG key." << std::endl;
            rsPeers->signGPGCertificate(peerDetails.gpg_id); //bye default sign set accept_connection to true;
            rsPeers->setServicePermissionFlags(peerDetails.gpg_id,serviceFlags()) ;
        }

        if (!groupId.isEmpty())
            rsPeers->assignPeerToGroup(groupId.toStdString(), peerDetails.gpg_id, true);
    }

    if(accept_connection)
    {
        //let's check if there is ip adresses in the wizard.
        if (!peerDetails.extAddr.empty() && peerDetails.extPort) {
            std::cerr << "ConnectFriendWizard::accept() : setting ip ext address." << std::endl;
            rsPeers->setExtAddress(peerDetails.id, peerDetails.extAddr, peerDetails.extPort);
        }
        if (!peerDetails.localAddr.empty() && peerDetails.localPort) {
            std::cerr << "ConnectFriendWizard::accept() : setting ip local address." << std::endl;
            rsPeers->setLocalAddress(peerDetails.id, peerDetails.localAddr, peerDetails.localPort);
        }
        if (!peerDetails.dyndns.empty()) {
            std::cerr << "ConnectFriendWizard::accept() : setting DynDNS." << std::endl;
            rsPeers->setDynDNS(peerDetails.id, peerDetails.dyndns);
        }
        if (!peerDetails.location.empty()) {
            std::cerr << "ConnectFriendWizard::accept() : setting peerLocation." << std::endl;
            rsPeers->setLocation(peerDetails.id, peerDetails.location);
        }
        runProgressDialog = true;
    }

    if (runProgressDialog)
    {
        std::string ssl_id = peerDetails.id;
        // its okay if ssl_id is invalid - dialog will show error.
        ConnectProgressDialog::showProgress(ssl_id);
    }

    NotifyQt::getInstance()->notifyListChange(NOTIFY_LIST_NEIGHBOURS,1) ;

    QDialog::accept();
}
Ejemplo n.º 4
0
void ConnectFriendWizard::accept()
{
	bool sign = false;
	bool accept_connection = false;
	bool add_key_to_keyring = false;

	if (hasVisitedPage(Page_Conclusion)) {
		std::cerr << "ConnectFriendWizard::accept() called with page conclusion visited" << std::endl;

		sign = ui->signGPGCheckBox->isChecked();
		accept_connection = ui->acceptNoSignGPGCheckBox->isChecked();
		add_key_to_keyring = ui->addKeyToKeyring_CB->isChecked() ;
	} else if (hasVisitedPage(Page_FriendRequest)) {
		std::cerr << "ConnectFriendWizard::accept() called with page friend request visited" << std::endl;

		sign = ui->fr_signGPGCheckBox->isChecked();
		accept_connection = ui->fr_acceptNoSignGPGCheckBox->isChecked();
	} else {
		QDialog::accept();
		return;
	}

	if (!mCertificate.empty() && add_key_to_keyring)
	{
		RsPgpId pgp_id ;
		RsPeerId ssl_id ;
		std::string error_string ;

		if(!rsPeers->loadCertificateFromString(mCertificate,ssl_id,pgp_id,error_string))
		{
			std::cerr << "ConnectFriendWizard::accept(): cannot load that certificate." << std::endl;
			return ;
		}
	}

	bool runProgressDialog = false;

	if(accept_connection && !peerDetails.gpg_id.isNull()) 
	{
		std::cerr << "ConclusionPage::validatePage() accepting GPG key for connection." << std::endl;
        rsPeers->addFriend(peerDetails.id, peerDetails.gpg_id,serviceFlags()) ;
        rsPeers->setServicePermissionFlags(peerDetails.gpg_id,serviceFlags()) ;

    if(ui->_addIPToWhiteList_CB_2->isChecked())
    {
        sockaddr_storage addr ;
        if(sockaddr_storage_ipv4_aton(addr,peerDetails.extAddr.c_str()) && sockaddr_storage_isValidNet(addr))
        {
            std::cerr << "ConclusionPage::adding IP " << sockaddr_storage_tostring(addr) << " to whitelist." << std::endl;
            rsBanList->addIpRange(addr,ui->_addIPToWhiteList_ComboBox_2->currentIndex(),RSBANLIST_TYPE_WHITELIST,std::string(tr("Added with certificate from %1").arg(ui->nameEdit->text()).toUtf8().constData()));
        }
    }

		if(sign)
		{
			std::cerr << "ConclusionPage::validatePage() signing GPG key." << std::endl;
			rsPeers->signGPGCertificate(peerDetails.gpg_id); //bye default sign set accept_connection to true;
			rsPeers->setServicePermissionFlags(peerDetails.gpg_id,serviceFlags()) ;
		} 

		if (!groupId.isEmpty()) 
			rsPeers->assignPeerToGroup(groupId.toStdString(), peerDetails.gpg_id, true);
	}

	if ((accept_connection) && (!peerDetails.id.isNull()))
	{
		runProgressDialog = true;

		if (!peerDetails.location.empty()) {
			std::cerr << "ConnectFriendWizard::accept() : setting peer node." << std::endl;
			rsPeers->setLocation(peerDetails.id, peerDetails.location);
		}

		if (peerDetails.isHiddenNode)
		{
			std::cerr << "ConnectFriendWizard::accept() : setting hidden node." << std::endl;
			rsPeers->setHiddenNode(peerDetails.id, peerDetails.hiddenNodeAddress, peerDetails.hiddenNodePort);
		}
		else
		{
			//let's check if there is ip adresses in the wizard.
			if (!peerDetails.extAddr.empty() && peerDetails.extPort) {
				std::cerr << "ConnectFriendWizard::accept() : setting ip ext address." << std::endl;
				rsPeers->setExtAddress(peerDetails.id, peerDetails.extAddr, peerDetails.extPort);
			}
			if (!peerDetails.localAddr.empty() && peerDetails.localPort) {
				std::cerr << "ConnectFriendWizard::accept() : setting ip local address." << std::endl;
				rsPeers->setLocalAddress(peerDetails.id, peerDetails.localAddr, peerDetails.localPort);
			}
			if (!peerDetails.dyndns.empty()) {
				std::cerr << "ConnectFriendWizard::accept() : setting DynDNS." << std::endl;
				rsPeers->setDynDNS(peerDetails.id, peerDetails.dyndns);
			}
		}

	}
		
	if (runProgressDialog)
	{
		RsPeerId ssl_id = peerDetails.id;
		// its okay if ssl_id is invalid - dialog will show error.
		ConnectProgressDialog::showProgress(ssl_id);
	}

	NotifyQt::getInstance()->notifyListChange(NOTIFY_LIST_NEIGHBOURS,1) ;

	QDialog::accept();
}