/*Di bawah ini fungsi untuk print perintah ke user. Kalo bikin fungsi lagi, di atasnya aja ya...*/
void Client::printSignUp()
{
    cout << "Welcome to this chat application" << endl;
    cout << "Masukkan username baru\t: ";
    getline(cin, username);
    cout << "Masukkan password\t\t: ";
    getline(cin, password);
    cout << "Konfirmasi Password\t: ";
    getline (cin, confirmPassword);
    
    if(password.compare(confirmPassword) == 0)
    {
        char * buff; buff = new char[MAXBUF];
    
        strcpy(buff,signup(username, password));
        cout << (string)buff << endl;
        openTCPConnection();
        setServerAddress((char*)"127.0.0.1");
        reqConnect();
        ConnectionHandler(buff);
    }
    else
    {
        cout << "Password dan konfirmasi password anda tidak sama" << endl;
    }

}
void SettingsDialog::loadSettings() {
    /* Load settings for panel rotation, fullscreen, and address from .ini file */
    
    _settings->beginGroup("settings");
    qDebug() << Q_FUNC_INFO << _settings->value("panelrotation").toInt();
    ui->panelRotationDial->setValue(_settings->value("panelrotation").toInt());
    ui->fullscreenCheckbox->setChecked(_settings->value("fullscreen", false).toBool());
    emit fullscreenChanged(ui->fullscreenCheckbox->isChecked());
    ui->serverAddressEdit->setText(_settings->value("serveraddress", "127.0.0.1:51000").toString());
    emit setServerAddress(ui->serverAddressEdit->text());
    _settings->endGroup();

}
SettingsDialog::SettingsDialog(QWidget *parent, QSettings *settings) :
    QDialog(parent),
    ui(new Ui::SettingsDialog){

/*    _rotation=0;
    _fullscreen=false;
    _serverAddress=QString("127.0.0.1:51000");
*/
    _settings = settings;

    ui->setupUi(this);
    connect(ui->panelRotationDial, SIGNAL(valueChanged(int)), this, SIGNAL(rotationChanged(int)));
    connect(ui->fullscreenCheckbox, SIGNAL(clicked(bool)), this, SIGNAL(fullscreenChanged(bool)));
    connect(ui->serverAddressEdit, SIGNAL(textChanged(QString)), this, SIGNAL(setServerAddress(QString)));
}
Exemple #4
0
void EditServer::setConnections(){
    QObject::connect(uiServerNameLine, SIGNAL(textChanged(QString)), _server, SLOT(setServerName(QString)));
    QObject::connect(uiServerNameLine, SIGNAL(textChanged(QString)), this, SLOT(updateUI()));

    QObject::connect(uiServerAddressLine, SIGNAL(editingFinished()), this, SLOT(setServerAddress()));
    QObject::connect(uiServerAddressLine, SIGNAL(editingFinished()), this, SLOT(updateUI()));

    QObject::connect(uiUserNameLine, SIGNAL(textChanged(QString)), _server, SLOT(setUserName(QString)));
    QObject::connect(uiUserNameLine, SIGNAL(textChanged(QString)), this, SLOT(updateUI()));

    QObject::connect(uiUserPassLine, SIGNAL(textChanged(QString)), _server, SLOT(setUserPass(QString)));
    QObject::connect(uiUserPassLine, SIGNAL(textChanged(QString)), this, SLOT(updateUI()));

    QObject::connect(uiAddCalendar, SIGNAL(clicked()), this, SLOT(addCalendar()));
    QObject::connect(uiDeleteCalendar, SIGNAL(clicked()), this, SLOT(deleteCalendar()));
}
void Client::printLogin()
{
    char * buff; buff = new char[MAXBUF];
//    string passwordCheck = "akhfa";
    cout << "username: "******"password: "******"127.0.0.1");
    reqConnect();
    ConnectionHandler(buff);
//    len = send(sock,buff,strlen(buff),0);
//    len = -1;
//    bzero(buff,MAXBUF);
//    cout << len << endl;
//    cout << "buff: " << buff << endl;
//    cout << strlen(buff) << endl;
//    if (len>=0){
//        len = recv(sock, buff , MAXBUF , 0); //receive message from user
//        if (strcmp(buff,"true")==0){
//            cout << "yayyyyyyyyy" << endl;
//            setLoginStatus(true);
//        status = 1;
//        
////        cout << "req connect.........." << endl;
////        openTCPConnection();
////        setServerAddress((char*)"127.0.0.1");
////        reqConnect();
//        }
//    }
//    len=-1;
//    if(password.compare(passwordCheck) == 0)
//    {
//        cout << "Success Login" << endl;
//        
//    }
}
	void processConfiguration(char * key , char * value){

		if( equalsStrings(key , FTPS_CONFIGURATION_KEY_FTPS_LOGLEVEL) ){
			setLoggingLevel(value);
		}
		if( equalsStrings(key , FTPS_CONFIGURATION_KEY_FTPS_DATADIR) ){
			setDataDirectory(value);
		}
		if( equalsStrings(key , FTPS_CONFIGURATION_KEY_FTPS_CONTROLPORT) ){
			setServerControlPort(value);
		}
		if( equalsStrings(key , FTPS_CONFIGURATION_KEY_FTPS_DATAPORT) ){
			setServerDataPort(value);
		}
		if( equalsStrings(key , FTPS_CONFIGURATION_KEY_FTPS_ADDRESS) ){
			setServerAddress(value);
		}
		if( equalsStrings(key , FTPS_CONFIGURATION_KEY_FTPS_LOGDIR) ){
			setLoggingDirectory(value);
		}
		if( equalsStrings(key , FTPS_CONFIGURATION_KEY_MAX_RETRIES) ){
			setMaxRetriesFindingDataPort( atoi(value) );
		}
		if( equalsStrings(key , FTPS_CONFIGURATION_KEY_FTPS_STARTMODE) ){
			if(!strcmp("true" , value)){
				setOfflineStartMode(TRUE);
			}else{
				setOfflineStartMode(FALSE);
			}
		}
		if( equalsStrings(key , FTPS_CONFIGURATION_KEY_KSS_ADDRESS) ){
			setKssAddress(value);
		}
		if( equalsStrings(key , FTPS_CONFIGURATION_KEY_KSS_PORT) ){
			setKssPort(value);
		}

		if( isDebugEnabled()) 
			debug(concat(getGlobalHeap() , 4, " Seteando " , key , "=" , value ));
	}
Exemple #7
0
bool TcpServer::listen(const IpAddress& address, uint16_t port)	
{
	if(address.isNull())
		return false;

	int fd = socket(AF_INET, SOCK_STREAM, 0);

	struct sockaddr_in addr;
	bzero(&addr, sizeof(addr));
	addr.sin_family = AF_INET;
	addr.sin_port = htons(port);
	inet_pton(AF_INET, address.toString().c_str(), &addr.sin_addr);	
	
	if(bind(fd, (struct sockaddr *)&addr, sizeof(addr)) == 0)
	{
		setServerAddress(address); 
	 	setServerPort(port);
		setSocketDescriptor(fd);
		if(::listen(fd, SOMAXCONN) == 0)
			return true;
	}

	return false;
}
Exemple #8
0
int SGSocket::startConnect(const char* ip, unsigned short port)
{
    setServerAddress(ip, port);
    return startConnect();
}
Exemple #9
0
void UdpManager::readUDP()
{
    QByteArray Temp;
    Temp.resize(socket->pendingDatagramSize());

    QHostAddress sender;
    quint16 senderPort;
    socket->readDatagram(Temp.data(),Temp.size(),&sender,&senderPort);

    QString debugMessage = "Got \"" + QString(Temp.data()) + "\" from " + sender.toString() + ":"+ QString::number(senderPort) + " (UDP)";
    emit updateClientGUIConsole(debugMessage);

    QString compareString = "BLENDER";
    QString message;
    if(Temp.data() == compareString)
    {
        if (workerIsBusy)
            message = "BLENDER0";       //is busy
        else{
            if (isGPUWorker)
                message = "BLENDER2";   // is available GPU-Worker
            else
                message = "BLENDER1";   // is available CPU-Worker
        }
        writeUDP(message, sender);
    }
    else if( QString(Temp.data()).at(0) == '#' && !workerIsBusy )
    {
        message = "";

        QString filepathToBlend = QDir::currentPath() + "/awesome.blend";

        QByteArray fileData;

        QFile file( filepathToBlend ); //e.g.: /.../build/awesome.blend
        if( file.open(QIODevice::ReadOnly) )
        {
            fileData = file.readAll();
            file.close();

            //Generate MD5 Hash
            QByteArray hashData = QCryptographicHash::hash(fileData, QCryptographicHash::Md5);
            file_hash = hashData.toHex();

            qDebug() << "Hex-Hash: " << hashData.toHex();

        }
        else
        {
            //Error
            file_hash = "Th15I5Th3DummymD5HasH0fGSORF.0RG";
        }

        //Send UDP Response
        writeUDP( "#" + file_hash, sender );
        if(file_hash==QString(Temp.data()).remove('#') )
        {
            emit setFileCached(true);
        }
        else
        {
            emit setFileCached(false);
        }
    }
    else if( QString(Temp.data()).startsWith("killall"))
    {
    qDebug()<<"Bye Bye Blender";
    QProcess *myProcess = new QProcess(this);
    myProcess->start("killall blender");
    myProcess->waitForFinished();
    }


    emit setServerAddress(sender);

}
	void setUpConfiguration(){

		char * dataDir = getConfigurationStrValue( getGlobalHeap() , 
			CONFIGURATION_FILE , FTPS_SECTION , FTPS_CONFIGURATION_KEY_FTPS_DATADIR);
				
		char * ctrlPort = getConfigurationStrValue( getGlobalHeap() ,
			CONFIGURATION_FILE , FTPS_SECTION , FTPS_CONFIGURATION_KEY_FTPS_CONTROLPORT);

		char * dataPort = getConfigurationStrValue( getGlobalHeap() ,
			CONFIGURATION_FILE , FTPS_SECTION , FTPS_CONFIGURATION_KEY_FTPS_DATAPORT);
	
		char * serverAddr = getConfigurationStrValue( getGlobalHeap() ,
			CONFIGURATION_FILE , FTPS_SECTION , FTPS_CONFIGURATION_KEY_FTPS_ADDRESS);
		
		char * logDir = getConfigurationStrValue( getGlobalHeap() ,
			CONFIGURATION_FILE , FTPS_SECTION , FTPS_CONFIGURATION_KEY_FTPS_LOGDIR);
		
		char * logLevel = getConfigurationStrValue( getGlobalHeap() ,
			CONFIGURATION_FILE , FTPS_SECTION , FTPS_CONFIGURATION_KEY_FTPS_LOGLEVEL);

		char * startMode = getConfigurationStrValue( getGlobalHeap() ,
			CONFIGURATION_FILE , FTPS_SECTION , FTPS_CONFIGURATION_KEY_FTPS_STARTMODE);

		char * kssAddress = getConfigurationStrValue( getGlobalHeap() , 
			CONFIGURATION_FILE , KSS_SECTION , FTPS_CONFIGURATION_KEY_KSS_ADDRESS);

		char * kssPort = getConfigurationStrValue( getGlobalHeap() , 
			CONFIGURATION_FILE , KSS_SECTION , FTPS_CONFIGURATION_KEY_KSS_PORT);

		char * maxRetries = getConfigurationStrValue( getGlobalHeap() ,
			CONFIGURATION_FILE , FTPS_SECTION , FTPS_CONFIGURATION_KEY_MAX_RETRIES);

		info("Cargando la configuracion");
		
		setDataDirectory(dataDir);
		setServerControlPort(ctrlPort);
		setServerDataPort(dataPort);
		setServerAddress(serverAddr);
		setLoggingDirectory(logDir);
		setLoggingLevel(logLevel);
		setMaxRetriesFindingDataPort(atoi(maxRetries));
		setKssAddress(kssAddress);
		setKssPort(kssPort);

		if(!strcmp("true" , startMode)){
			setOfflineStartMode(TRUE);
		}else{
			setOfflineStartMode(FALSE);
		}

		if(isDebugEnabled()) 
			debug(concat(getGlobalHeap() , 4 , "Seteando " , 
				FTPS_CONFIGURATION_KEY_FTPS_DATADIR , "=" , dataDir));

		if(isDebugEnabled()) 
			debug(concat(getGlobalHeap() , 4 , "Seteando " , 
				FTPS_CONFIGURATION_KEY_FTPS_CONTROLPORT , "=" , ctrlPort));

		if(isDebugEnabled()) 
			debug(concat(getGlobalHeap() , 4 , "Seteando " , 
				FTPS_CONFIGURATION_KEY_FTPS_DATAPORT , "=" , dataPort));

		if(isDebugEnabled()) 
			debug(concat(getGlobalHeap() , 4 , "Seteando " , 
				FTPS_CONFIGURATION_KEY_FTPS_ADDRESS , "=" , serverAddr));

		if(isDebugEnabled()) 
			debug(concat(getGlobalHeap() , 4 , "Seteando " , 
				FTPS_CONFIGURATION_KEY_FTPS_LOGDIR , "=" , logDir));

		if(isDebugEnabled()) 
			debug(concat(getGlobalHeap() , 4 , "Seteando " , 
				FTPS_CONFIGURATION_KEY_FTPS_LOGLEVEL , "=" , logLevel));

		if(isDebugEnabled()) 
			debug(concat(getGlobalHeap() , 4 , "Seteando " , 
				FTPS_CONFIGURATION_KEY_FTPS_STARTMODE , "=" , startMode));

		if(isDebugEnabled()) 
			debug(concat(getGlobalHeap() , 4 , "Seteando " , 
				FTPS_CONFIGURATION_KEY_MAX_RETRIES , "=" , maxRetries));

		if(isDebugEnabled()) 
			debug(concat(getGlobalHeap() , 4 , "Seteando " , 
				FTPS_CONFIGURATION_KEY_KSS_ADDRESS , "=" , kssAddress));

		if(isDebugEnabled()) 
			debug(concat(getGlobalHeap() , 4 , "Seteando " , 
				FTPS_CONFIGURATION_KEY_KSS_ADDRESS , "=" , kssPort));			
		
		
	}