|
@@ -1,670 +0,0 @@
|
|
|
-#include "PSKlient.h"
|
|
|
-#include <Text.h>
|
|
|
-#include <Datei.h>
|
|
|
-#include <Zeit.h>
|
|
|
-#include <InitDatei.h>
|
|
|
-#include "Keys.h"
|
|
|
-
|
|
|
-// Inhalt der PSKlient Klasse aus PSKlient.h
|
|
|
-// Konstruktor
|
|
|
-PSKlient::PSKlient()
|
|
|
-{
|
|
|
- Datei *dat = new Datei();
|
|
|
- dat->setDatei( "data/tmp/k.id" );
|
|
|
- dat->open( Datei::Style::lesen );
|
|
|
- dat->lese( (char*)&id, 4 );
|
|
|
- dat->close();
|
|
|
- klient = 0;
|
|
|
- InitializeCriticalSection( &cs );
|
|
|
- verbunden = 0;
|
|
|
- dat->setDatei( "data/tmp/schlüssel.netw" );
|
|
|
- dat->open( Datei::Style::lesen );
|
|
|
- dat->lese( &schlüsselLän, 1 );
|
|
|
- schlüssel = new char[ schlüsselLän ];
|
|
|
- dat->lese( schlüssel, schlüsselLän );
|
|
|
- dat->close();
|
|
|
- dat = dat->release();
|
|
|
- fehler = new Text();
|
|
|
- ref = 1;
|
|
|
-}
|
|
|
-
|
|
|
-// Destruktor
|
|
|
-PSKlient::~PSKlient()
|
|
|
-{
|
|
|
- delete[] schlüssel;
|
|
|
- if( verbunden )
|
|
|
- trenne( 1 );
|
|
|
- if( klient )
|
|
|
- klient->release();
|
|
|
- fehler->release();
|
|
|
- DeleteCriticalSection( &cs );
|
|
|
-}
|
|
|
-
|
|
|
-// nicht constant
|
|
|
-void PSKlient::lock()
|
|
|
-{
|
|
|
- EnterCriticalSection( &cs );
|
|
|
-}
|
|
|
-
|
|
|
-void PSKlient::unlock()
|
|
|
-{
|
|
|
- LeaveCriticalSection( &cs );
|
|
|
-}
|
|
|
-
|
|
|
-bool PSKlient::verbinde()
|
|
|
-{
|
|
|
- lock();
|
|
|
- if( verbunden )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- return 1;
|
|
|
- }
|
|
|
- if( !klient )
|
|
|
- {
|
|
|
- InitDatei *iniDat = new InitDatei( "data/optionen.ini" );
|
|
|
- iniDat->laden();
|
|
|
- Text *ipT = iniDat->getWert( "ServerIP" );
|
|
|
- Datei d;
|
|
|
- d.setDatei( "data/tmp/m.port" );
|
|
|
- d.open( Datei::Style::lesen );
|
|
|
- int port = 0;
|
|
|
- d.lese( (char*)&port, 4 );
|
|
|
- iniDat->release();
|
|
|
- d.close();
|
|
|
- int län = ipT->getLength();
|
|
|
- char *msIp = new char[ län + 1 ];
|
|
|
- msIp[ län ] = 0;
|
|
|
- for( int i = 0; i < län; i++ )
|
|
|
- msIp[ i ] = ipT->getText()[ i ];
|
|
|
- ipT->release();
|
|
|
- klient = new Klient();
|
|
|
- char *key;
|
|
|
- int length;
|
|
|
- Keys::getServerKey( &key, length, Keys::MAIN, Keys::SENDEN );
|
|
|
- klient->setSendeKey( key, length );
|
|
|
- delete[] key;
|
|
|
- Keys::getServerKey( &key, length, Keys::MAIN, Keys::EMPFANGEN );
|
|
|
- klient->setEmpfangKey( key, length );
|
|
|
- delete[] key;
|
|
|
- if( !klient->verbinde( port, msIp ) )
|
|
|
- {
|
|
|
- fehler->setText( "Fehler beim verbinden mit dem Main Server. Bitte versuche es Später erneut." );
|
|
|
- klient = klient->release();
|
|
|
- delete[] msIp;
|
|
|
- unlock();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- delete[] msIp;
|
|
|
- klient->sende( "\0", 1 ); // verschlüsselung aktivieren
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
- klient->sendeEncrypted( (char*)&id, 4 );
|
|
|
- char serverReturn = 0;
|
|
|
- klient->getNachrichtEncrypted( &serverReturn, 1 );
|
|
|
- if( serverReturn == 3 )
|
|
|
- {
|
|
|
- char byte = 0;
|
|
|
- klient->getNachrichtEncrypted( &byte, 1 );
|
|
|
- char *err = new char[ byte + 1 ];
|
|
|
- err[ byte ] = 0;
|
|
|
- klient->getNachrichtEncrypted( err, byte );
|
|
|
- fehler->setText( err );
|
|
|
- delete[] err;
|
|
|
- klient->sendeEncrypted( "\3", 1 );
|
|
|
- klient->getNachrichtEncrypted( &serverReturn, 1 );
|
|
|
- klient->trenne();
|
|
|
- klient = klient->release();
|
|
|
- unlock();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- klient->setSendeKey( schlüssel, schlüsselLän );
|
|
|
- klient->setEmpfangKey( schlüssel, schlüsselLän );
|
|
|
- klient->sendeEncrypted( "\6\2", 2 );
|
|
|
- char byte = 0;
|
|
|
- klient->getNachrichtEncrypted( &byte, 1 );
|
|
|
- if( byte == 2 )
|
|
|
- {
|
|
|
- unsigned char psIp[ 4 ];
|
|
|
- klient->getNachrichtEncrypted( (char *)psIp, 4 );
|
|
|
- unsigned short psPort = 0;
|
|
|
- klient->getNachrichtEncrypted( (char*)&psPort, 2 );
|
|
|
- klient->sendeEncrypted( "\3", 1 );
|
|
|
- klient->getNachrichtEncrypted( &serverReturn, 1 );
|
|
|
- klient->trenne();
|
|
|
- Text *psIpT = new Text( "" );
|
|
|
- psIpT->append( (int)psIp[ 0 ] );
|
|
|
- psIpT->append( "." );
|
|
|
- psIpT->append( (int)psIp[ 1 ] );
|
|
|
- psIpT->append( "." );
|
|
|
- psIpT->append( (int)psIp[ 2 ] );
|
|
|
- psIpT->append( "." );
|
|
|
- psIpT->append( (int)psIp[ 3 ] );
|
|
|
- if( verbinde( psPort, psIpT->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- psIpT->release();
|
|
|
- return 1;
|
|
|
- }
|
|
|
- psIpT->release();
|
|
|
- }
|
|
|
- if( byte == 3 )
|
|
|
- {
|
|
|
- klient->getNachrichtEncrypted( &byte, 1 );
|
|
|
- char *err = new char[ byte + 1 ];
|
|
|
- err[ byte ] = 0;
|
|
|
- klient->getNachrichtEncrypted( err, byte );
|
|
|
- fehler->setText( err );
|
|
|
- delete[] err;
|
|
|
- klient->sendeEncrypted( "\3", 1 );
|
|
|
- klient->getNachrichtEncrypted( &serverReturn, 1 );
|
|
|
- klient->trenne();
|
|
|
- klient = klient->release();
|
|
|
- unlock();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- }
|
|
|
- if( klient && verbinde( klient->getServerPort(), klient->getServerIp() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- return 1;
|
|
|
- }
|
|
|
- unlock();
|
|
|
- return 0;
|
|
|
-}
|
|
|
-
|
|
|
-bool PSKlient::verbinde( int port, const char *ip )
|
|
|
-{
|
|
|
- lock();
|
|
|
- if( verbunden )
|
|
|
- trenne( 1 );
|
|
|
- if( !klient )
|
|
|
- klient = new Klient();
|
|
|
- if( !klient->verbinde( (short)port, ip ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- char *key;
|
|
|
- int length;
|
|
|
- Keys::getServerKey( &key, length, Keys::PATCH, Keys::SENDEN );
|
|
|
- klient->setSendeKey( key, length );
|
|
|
- delete[] key;
|
|
|
- Keys::getServerKey( &key, length, Keys::PATCH, Keys::EMPFANGEN );
|
|
|
- klient->setEmpfangKey( key, length );
|
|
|
- delete[] key;
|
|
|
- klient->sende( "\0", 1 ); // Verschlüsselung aktivieren
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
- klient->sendeEncrypted( (char*)&id, 4 );
|
|
|
-#ifdef _WIN64
|
|
|
- klient->sendeEncrypted( "\2", 1 ); // 64 Bit Client
|
|
|
-#else
|
|
|
- klient->sendeEncrypted( "\1", 1 ); // 32 Bit Client
|
|
|
-#endif
|
|
|
- char ret = 0;
|
|
|
- klient->getNachrichtEncrypted( &ret, 1 );
|
|
|
- if( ret == 3 )
|
|
|
- { // error
|
|
|
- klient->getNachrichtEncrypted( &ret, 1 );
|
|
|
- char *msg = new char[ ret + 1 ];
|
|
|
- msg[ ret ] = 0;
|
|
|
- if( ret )
|
|
|
- klient->getNachrichtEncrypted( msg, ret );
|
|
|
- fehler->setText( msg );
|
|
|
- delete[] msg;
|
|
|
- trenne( 0 );
|
|
|
- unlock();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- klient->setSendeKey( schlüssel, schlüsselLän );
|
|
|
- klient->setEmpfangKey( schlüssel, schlüsselLän );
|
|
|
- verbunden = 1;
|
|
|
- unlock();
|
|
|
- return 1;
|
|
|
-}
|
|
|
-
|
|
|
-KSGTDatei *PSKlient::getDateiGruppenListe()
|
|
|
-{
|
|
|
- lock();
|
|
|
- if( !verbunden )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- klient->sendeEncrypted( "\xC", 1 );
|
|
|
- char ret = 0;
|
|
|
- klient->getNachrichtEncrypted( &ret, 1 );
|
|
|
- if( ret == 3 )
|
|
|
- { // error
|
|
|
- klient->getNachrichtEncrypted( &ret, 1 );
|
|
|
- char *msg = new char[ ret + 1 ];
|
|
|
- msg[ ret ] = 0;
|
|
|
- if( ret )
|
|
|
- klient->getNachrichtEncrypted( msg, ret );
|
|
|
- fehler->setText( msg );
|
|
|
- delete[] msg;
|
|
|
- unlock();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- KSGTDatei *dgtb = new KSGTDatei();
|
|
|
- int id = 0;
|
|
|
- klient->getNachrichtEncrypted( (char*)&id, 4 );
|
|
|
- while( id )
|
|
|
- {
|
|
|
- RCArray< Text > *zeile = new RCArray< Text >();
|
|
|
- Text *idT = new Text();
|
|
|
- idT->append( id );
|
|
|
- zeile->set( idT, 0 );
|
|
|
- int län = 0;
|
|
|
- klient->getNachrichtEncrypted( (char*)&län, 4 );
|
|
|
- char *pfad = new char[ län + 1 ];
|
|
|
- pfad[ län ] = 0;
|
|
|
- if( län )
|
|
|
- klient->getNachrichtEncrypted( pfad, län );
|
|
|
- zeile->set( new Text( pfad ), 1 );
|
|
|
- delete[] pfad;
|
|
|
- int vs = 0;
|
|
|
- klient->getNachrichtEncrypted( (char*)&vs, 4 );
|
|
|
- Text *vsT = new Text();
|
|
|
- vsT->append( vs );
|
|
|
- zeile->set( vsT, 2 );
|
|
|
- dgtb->addZeile( 3, zeile );
|
|
|
- zeile->release();
|
|
|
- klient->getNachrichtEncrypted( (char*)&id, 4 );
|
|
|
- }
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
- unlock();
|
|
|
- return dgtb;
|
|
|
-}
|
|
|
-
|
|
|
-KSGTDatei *PSKlient::getDateiListe( int gruppe )
|
|
|
-{
|
|
|
- lock();
|
|
|
- if( !verbunden )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- klient->sendeEncrypted( "\x9", 1 );
|
|
|
- char ret = 0;
|
|
|
- klient->getNachrichtEncrypted( &ret, 1 );
|
|
|
- if( ret == 3 )
|
|
|
- { // error
|
|
|
- klient->getNachrichtEncrypted( &ret, 1 );
|
|
|
- char *msg = new char[ ret + 1 ];
|
|
|
- msg[ ret ] = 0;
|
|
|
- if( ret )
|
|
|
- klient->getNachrichtEncrypted( msg, ret );
|
|
|
- fehler->setText( msg );
|
|
|
- delete[] msg;
|
|
|
- unlock();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- klient->sendeEncrypted( (char*)&gruppe, 4 );
|
|
|
- klient->getNachrichtEncrypted( &ret, 1 );
|
|
|
- if( ret == 3 )
|
|
|
- { // error
|
|
|
- klient->getNachrichtEncrypted( &ret, 1 );
|
|
|
- char *msg = new char[ ret + 1 ];
|
|
|
- msg[ ret ] = 0;
|
|
|
- if( ret )
|
|
|
- klient->getNachrichtEncrypted( msg, ret );
|
|
|
- fehler->setText( msg );
|
|
|
- delete[] msg;
|
|
|
- unlock();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- KSGTDatei *dtb = new KSGTDatei();
|
|
|
- int län = 0;
|
|
|
- klient->getNachrichtEncrypted( (char*)&län, 4 );
|
|
|
- while( län )
|
|
|
- {
|
|
|
- RCArray< Text > *zeile = new RCArray< Text >();
|
|
|
- zeile->set( new Text( "1" ), 0 );
|
|
|
- char *pfad = new char[ län + 1 ];
|
|
|
- pfad[ län ] = 0;
|
|
|
- klient->getNachrichtEncrypted( pfad, län );
|
|
|
- zeile->set( new Text( pfad ), 1 );
|
|
|
- delete[] pfad;
|
|
|
- int vs = 0;
|
|
|
- klient->getNachrichtEncrypted( (char*)&vs, 4 );
|
|
|
- Text *vsT = new Text();
|
|
|
- vsT->append( vs );
|
|
|
- zeile->set( vsT, 2 );
|
|
|
- dtb->addZeile( 3, zeile );
|
|
|
- zeile->release();
|
|
|
- klient->getNachrichtEncrypted( (char*)&län, 4 );
|
|
|
- }
|
|
|
- klient->getNachrichtEncrypted( (char*)&län, 4 );
|
|
|
- while( län )
|
|
|
- {
|
|
|
- RCArray< Text > *zeile = new RCArray< Text >();
|
|
|
- zeile->set( new Text( "0" ), 0 );
|
|
|
- char *pfad = new char[ län + 1 ];
|
|
|
- pfad[ län ] = 0;
|
|
|
- klient->getNachrichtEncrypted( pfad, län );
|
|
|
- zeile->set( new Text( pfad ), 1 );
|
|
|
- delete[] pfad;
|
|
|
- dtb->addZeile( 2, zeile );
|
|
|
- zeile->release();
|
|
|
- klient->getNachrichtEncrypted( (char*)&län, 4 );
|
|
|
- }
|
|
|
- unlock();
|
|
|
- return dtb;
|
|
|
-}
|
|
|
-
|
|
|
-__int64 PSKlient::getDateiGröße( int gruppe, const char *pfad )
|
|
|
-{
|
|
|
- lock();
|
|
|
- if( !verbunden )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- klient->sendeEncrypted( "\xA", 1 );
|
|
|
- char ret = 0;
|
|
|
- klient->getNachrichtEncrypted( &ret, 1 );
|
|
|
- if( ret == 3 )
|
|
|
- { // error
|
|
|
- klient->getNachrichtEncrypted( &ret, 1 );
|
|
|
- char *msg = new char[ ret + 1 ];
|
|
|
- msg[ ret ] = 0;
|
|
|
- if( ret )
|
|
|
- klient->getNachrichtEncrypted( msg, ret );
|
|
|
- fehler->setText( msg );
|
|
|
- delete[] msg;
|
|
|
- unlock();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- klient->sendeEncrypted( (char*)&gruppe, 4 );
|
|
|
- ret = 0;
|
|
|
- klient->getNachrichtEncrypted( &ret, 1 );
|
|
|
- if( ret == 3 )
|
|
|
- { // error
|
|
|
- klient->getNachrichtEncrypted( &ret, 1 );
|
|
|
- char *msg = new char[ ret + 1 ];
|
|
|
- msg[ ret ] = 0;
|
|
|
- if( ret )
|
|
|
- klient->getNachrichtEncrypted( msg, ret );
|
|
|
- fehler->setText( msg );
|
|
|
- delete[] msg;
|
|
|
- unlock();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- if( ret == 2 )
|
|
|
- { // verweis auf anderen Server
|
|
|
- int port = 0;
|
|
|
- klient->getNachrichtEncrypted( (char*)&port, 4 );
|
|
|
- int län = 0;
|
|
|
- klient->getNachrichtEncrypted( (char*)&län, 4 );
|
|
|
- char *ip = new char[ län + 1 ];
|
|
|
- ip[ län ] = 0;
|
|
|
- klient->getNachrichtEncrypted( ip, län );
|
|
|
- if( !trenne( 0 ) )
|
|
|
- {
|
|
|
- delete[] ip;
|
|
|
- unlock();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- if( !verbinde( port, ip ) )
|
|
|
- {
|
|
|
- delete[] ip;
|
|
|
- unlock();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- delete[] ip;
|
|
|
- unlock();
|
|
|
- return getDateiGröße( gruppe, pfad );
|
|
|
- }
|
|
|
- int län = textLength( pfad );
|
|
|
- klient->sendeEncrypted( (char*)&län, 4 );
|
|
|
- klient->sendeEncrypted( pfad, län );
|
|
|
- __int64 größe = 0;
|
|
|
- klient->getNachrichtEncrypted( (char*)&größe, 8 );
|
|
|
- unlock();
|
|
|
- return größe;
|
|
|
-}
|
|
|
-
|
|
|
-bool PSKlient::downloadDatei( int gruppe, __int64 *start, const char *pfad, const char *zielPfad, FBalken *zFb, bool *abbruch, int maxbps )
|
|
|
-{
|
|
|
- lock();
|
|
|
- if( !verbunden )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- Datei *zielD = new Datei();
|
|
|
- zielD->setDatei( zielPfad );
|
|
|
- if( !zielD->existiert() )
|
|
|
- zielD->erstellen();
|
|
|
- bool ok = 0;
|
|
|
- if( !( *start ) ) // datei neu erstellen
|
|
|
- ok = zielD->open( Datei::Style::schreiben );
|
|
|
- else // datei weiterschreiben
|
|
|
- ok = zielD->open( Datei::Style::schreiben | Datei::Style::lesen );
|
|
|
- if( !ok )
|
|
|
- {
|
|
|
- zielD->release();
|
|
|
- unlock();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- zielD->setSPosition( *start, 0 );
|
|
|
- klient->sendeEncrypted( "\xB", 1 );
|
|
|
- char ret = 0;
|
|
|
- klient->getNachrichtEncrypted( &ret, 1 );
|
|
|
- if( ret == 3 )
|
|
|
- { // error
|
|
|
- klient->getNachrichtEncrypted( &ret, 1 );
|
|
|
- char *msg = new char[ ret + 1 ];
|
|
|
- msg[ ret ] = 0;
|
|
|
- if( ret )
|
|
|
- klient->getNachrichtEncrypted( msg, ret );
|
|
|
- fehler->setText( msg );
|
|
|
- delete[] msg;
|
|
|
- zielD->close();
|
|
|
- zielD->release();
|
|
|
- unlock();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- klient->sendeEncrypted( (char*)&gruppe, 4 );
|
|
|
- ret = 0;
|
|
|
- klient->getNachrichtEncrypted( &ret, 1 );
|
|
|
- if( ret == 3 )
|
|
|
- { // error
|
|
|
- klient->getNachrichtEncrypted( &ret, 1 );
|
|
|
- char *msg = new char[ ret + 1 ];
|
|
|
- msg[ ret ] = 0;
|
|
|
- if( ret )
|
|
|
- klient->getNachrichtEncrypted( msg, ret );
|
|
|
- fehler->setText( msg );
|
|
|
- delete[] msg;
|
|
|
- zielD->close();
|
|
|
- zielD->release();
|
|
|
- unlock();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- if( ret == 2 )
|
|
|
- { // verweis auf anderen Server
|
|
|
- int port = 0;
|
|
|
- klient->getNachrichtEncrypted( (char*)&port, 4 );
|
|
|
- int län = 0;
|
|
|
- klient->getNachrichtEncrypted( (char*)&län, 4 );
|
|
|
- char *ip = new char[ län + 1 ];
|
|
|
- ip[ län ] = 0;
|
|
|
- klient->getNachrichtEncrypted( ip, län );
|
|
|
- if( !trenne( 0 ) )
|
|
|
- {
|
|
|
- delete[] ip;
|
|
|
- zielD->close();
|
|
|
- zielD->release();
|
|
|
- unlock();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- if( !verbinde( port, ip ) )
|
|
|
- {
|
|
|
- delete[] ip;
|
|
|
- zielD->close();
|
|
|
- zielD->release();
|
|
|
- unlock();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- delete[] ip;
|
|
|
- zielD->close();
|
|
|
- zielD->release();
|
|
|
- unlock();
|
|
|
- return downloadDatei( gruppe, start, pfad, zielPfad, zFb, abbruch, maxbps );
|
|
|
- }
|
|
|
- int län = textLength( pfad );
|
|
|
- klient->sendeEncrypted( (char*)&län, 4 );
|
|
|
- klient->sendeEncrypted( pfad, län );
|
|
|
- klient->sendeEncrypted( (char*)start, 8 );
|
|
|
- char *bytes = new char[ 2048 ];
|
|
|
- unsigned short byteLän = 0;
|
|
|
- klient->getNachricht( (char*)&byteLän, 2 );
|
|
|
- ZeitMesser *zMess = new ZeitMesser();
|
|
|
- zMess->messungStart();
|
|
|
- if( byteLän )
|
|
|
- {
|
|
|
- int bps = 0;
|
|
|
- double sec = 0;
|
|
|
- while( 1 )
|
|
|
- {
|
|
|
- klient->getNachricht( bytes, byteLän );
|
|
|
- zielD->schreibe( bytes, byteLän );
|
|
|
- if( zFb )
|
|
|
- zFb->aktionPlus( byteLän );
|
|
|
- ( *start ) += byteLän;
|
|
|
- bps += byteLän;
|
|
|
- if( byteLän == 2048 )
|
|
|
- {
|
|
|
- if( ( *abbruch ) )
|
|
|
- {
|
|
|
- zielD->close();
|
|
|
- zielD->release();
|
|
|
- klient->trenne();
|
|
|
- verbunden = 0;
|
|
|
- delete[] bytes;
|
|
|
- zMess->release();
|
|
|
- unlock();
|
|
|
- return 1;
|
|
|
- }
|
|
|
- klient->getNachricht( (char*)&byteLän, 2 ); // sendelänge empfangen
|
|
|
- if( !byteLän )
|
|
|
- break;
|
|
|
- }
|
|
|
- else
|
|
|
- break;
|
|
|
- if( maxbps )
|
|
|
- {
|
|
|
- zMess->messungEnde();
|
|
|
- sec += zMess->getSekunden();
|
|
|
- zMess->messungStart();
|
|
|
- if( sec >= 1 )
|
|
|
- {
|
|
|
- sec = 0;
|
|
|
- bps = 0;
|
|
|
- }
|
|
|
- while( bps >= maxbps )
|
|
|
- {
|
|
|
- Sleep( 10 );
|
|
|
- zMess->messungEnde();
|
|
|
- sec += zMess->getSekunden();
|
|
|
- zMess->messungStart();
|
|
|
- if( sec >= 1 )
|
|
|
- {
|
|
|
- sec = 0;
|
|
|
- bps = 0;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- zMess->release();
|
|
|
- delete[] bytes;
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
- zielD->close();
|
|
|
- zielD->release();
|
|
|
- unlock();
|
|
|
- return 1;
|
|
|
-}
|
|
|
-
|
|
|
-bool PSKlient::trenne( bool abmelden )
|
|
|
-{
|
|
|
- lock();
|
|
|
- if( !verbunden )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- return 1;
|
|
|
- }
|
|
|
- if( abmelden )
|
|
|
- {
|
|
|
- klient->sendeEncrypted( "\4", 1 );
|
|
|
- char ret = 0;
|
|
|
- klient->getNachrichtEncrypted( &ret, 1 );
|
|
|
- if( ret == 3 )
|
|
|
- { // error
|
|
|
- klient->getNachrichtEncrypted( &ret, 1 );
|
|
|
- char *msg = new char[ ret + 1 ];
|
|
|
- msg[ ret ] = 0;
|
|
|
- if( ret )
|
|
|
- klient->getNachrichtEncrypted( msg, ret );
|
|
|
- fehler->setText( msg );
|
|
|
- unlock();
|
|
|
- delete[] msg;
|
|
|
- }
|
|
|
- }
|
|
|
- klient->sendeEncrypted( "\3", 1 );
|
|
|
- char ret = 0;
|
|
|
- klient->getNachrichtEncrypted( &ret, 1 );
|
|
|
- if( ret == 3 )
|
|
|
- { // error
|
|
|
- klient->getNachrichtEncrypted( &ret, 1 );
|
|
|
- char *msg = new char[ ret + 1 ];
|
|
|
- msg[ ret ] = 0;
|
|
|
- if( ret )
|
|
|
- klient->getNachrichtEncrypted( msg, ret );
|
|
|
- unlock();
|
|
|
- fehler->setText( msg );
|
|
|
- delete[] msg;
|
|
|
- }
|
|
|
- klient->trenne();
|
|
|
- if( abmelden )
|
|
|
- klient = klient->release();
|
|
|
- verbunden = 0;
|
|
|
- unlock();
|
|
|
- return 1;
|
|
|
-}
|
|
|
-
|
|
|
-// constant
|
|
|
-bool PSKlient::istVerbunden() const
|
|
|
-{
|
|
|
- return verbunden;
|
|
|
-}
|
|
|
-
|
|
|
-bool PSKlient::istRegistriert() const
|
|
|
-{
|
|
|
- return klient != 0;
|
|
|
-}
|
|
|
-
|
|
|
-int PSKlient::getDownload() const
|
|
|
-{
|
|
|
- return klient ? (klient->getDownloadBytes( 1 ) + klient->getUploadBytes( 1 ) ) : 0;
|
|
|
-}
|
|
|
-
|
|
|
-Text *PSKlient::zError() const
|
|
|
-{
|
|
|
- return fehler;
|
|
|
-}
|
|
|
-
|
|
|
-// Reference Counting
|
|
|
-PSKlient *PSKlient::getThis()
|
|
|
-{
|
|
|
- ref++;
|
|
|
- return this;
|
|
|
-}
|
|
|
-
|
|
|
-PSKlient *PSKlient::release()
|
|
|
-{
|
|
|
- ref--;
|
|
|
- if( !ref )
|
|
|
- delete this;
|
|
|
- return 0;
|
|
|
-}
|