[X2Go-Commits] x2godesktopsharing.git - build-main (branch) updated: 3.0.1.2-16-g0720d15

X2Go dev team git-admin at x2go.org
Sat Jun 8 01:13:23 CEST 2013


The branch, build-main has been updated
       via  0720d15908712b9f3c3390e46515bdd3fcd8b550 (commit)
      from  cf356157e83da59220ab7af3c8bb71f722b3e754 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
-----------------------------------------------------------------------

Summary of changes:
 sharetray.cpp |  785 ++++++++++++++++++++++++++++-----------------------------
 1 file changed, 391 insertions(+), 394 deletions(-)

The diff of changes is:
diff --git a/sharetray.cpp b/sharetray.cpp
index 56a785c..9e81db8 100644
--- a/sharetray.cpp
+++ b/sharetray.cpp
@@ -44,132 +44,131 @@ int ShareTray::sigtermFd[2];
 ShareTray::ShareTray()
         : QMainWindow()
 {
-    serverSocket=0l;
-    menuClose=false;
-    current_list=BLACK;
-
-    ui.setupUi ( this );
-    ui.box->setSelectionMode ( QAbstractItemView::ExtendedSelection );
-
-    connect ( ui.close_box,SIGNAL ( clicked ( QAbstractButton* ) ),
-              SLOT ( slotMsgClose ( QAbstractButton* ) ) );
-
-    connect ( ui.ok_cancel_box,SIGNAL ( clicked ( QAbstractButton* ) ),
-              SLOT ( slotMsgOkCancel ( QAbstractButton* ) ) );
-
-    connect ( ui.del,SIGNAL ( clicked() ),
-              SLOT ( slotDelListItem() ) );
-
-    ui.icon->setPixmap ( QPixmap ( ":icons/128x128/x2godesktopsharing.png" ) );
-
-    ui.text->setText ( tr ( "<b>X2GO DesktopSharing v" ) +VERSION+
-                       " </b >(Qt - "+qVersion() +")"+
-                       ui.text->text() );
-
-    setWindowFlags ( Qt::Dialog );
-    Qt::WindowFlags flags=windowFlags();
-    flags&= ~Qt::WindowTitleHint;
-    setWindowFlags ( flags );
-
-    QString dispname=getenv ( "DISPLAY" );
-    socketFname=QDir::tempPath() +"/x2godesktopsharing_@"+
-                getenv ( "LOGNAME" ) +"@"+dispname;
-    lockFname=QDir::tempPath() +"/x2godesktopsharing.lock_"+
-              getenv ( "LOGNAME" ) +"@"+dispname;
-    if ( QFile::exists ( lockFname ) )
-    {
-        QFile file ( lockFname );
-        if ( file.open ( QIODevice::ReadOnly | QIODevice::Text ) )
-        {
-            QTextStream in ( &file );
-            if ( !in.atEnd() )
-            {
-                QString line = in.readLine();
-                file.close();
-                if ( abs ( line.toUInt() -
-                           QDateTime::currentDateTime().toTime_t() ) <5 )
-                {
-
-                    QString message=QString (
-                                        tr (
-                                            "X2Go desktop sharing application "
-                                            "is already active for this "
-                                            "display \n"
-                                            "if this application is no longer "
-                                            "running, remove %1\n"
-                                            "and start again" ) ).arg ( lockFname );
-                    QMessageBox::critical ( 0l,tr (
-                                                "Error" ),message,
-                                            QMessageBox::Ok,
-                                            QMessageBox::NoButton );
-                    exit ( -1 );
-                }
-            }
-        }
-        QFile::remove ( lockFname );
-    }
-    if ( QFile::exists ( socketFname ) )
-        QFile::remove ( socketFname );
-
-    QTimer *lockTimer = new QTimer ( this );
-    connect ( lockTimer, SIGNAL ( timeout() ), this, SLOT ( slotUpdateLockFile() ) );
-    lockTimer->start ( 3000 );
-    trayIcon=new QSystemTrayIcon ( this );
-    setWindowIcon ( QIcon ( ":icons/22x22/x2godesktopsharing.png" ) );
-    menu = new QMenu ( this );
-    trayIcon->setContextMenu ( menu );
-    trayIcon->setToolTip ( tr ( "X2Go desktop sharing application" ) );
-
-    menu->addSeparator();
-
-    actWhite = menu->addAction ( QIcon ( ":icons/32x32/wlist.png" ) ,
-                                 tr ( "Granted users..." ) );
-    actBlack = menu->addAction ( QIcon ( ":icons/32x32/blist.png" ) ,
-                                 tr ( "Banned users..." ) );
-    menu->addSeparator();
-
-    actStart = menu->addAction ( QIcon ( ":icons/32x32/share.png" ) ,
-                                 tr ( "Activate desktop sharing" ) );
-
-    actStop = menu->addAction ( QIcon ( ":icons/32x32/stop.png" ) ,
-                                tr ( "Deactivate desktop sharing" ) );
-
-    menu->addSeparator();
-    QAction* actAbout=menu->addAction (
-                          QIcon ( ":icons/32x32/x2godesktopsharing.png" ),
-                          tr ( "About X2GO Sharing" ) );
-//
-//     QAction* actAboutQt=menu->addAction(
-//                              tr("About Qt"));
-//     connect ( actAboutQt,SIGNAL ( triggered ( bool ) ),this,
-//          SLOT ( slotAboutQt() ) );
-//
-    connect ( actAbout,SIGNAL ( triggered ( bool ) ),this,
-              SLOT ( slotAbout() ) );
-
-
-    menu->addSeparator();
-    QAction* actExit = menu->addAction ( QIcon ( ":icons/32x32/exit.png" ) ,
-                                         tr ( "&Quit" ) );
-
-    connect ( actWhite,SIGNAL ( triggered ( bool ) ),this,
-              SLOT ( slotWhiteList() ) );
-    connect ( actBlack,SIGNAL ( triggered ( bool ) ),this,
-              SLOT ( slotBlackList() ) );
-
-
-    connect ( actExit,SIGNAL ( triggered ( bool ) ),this,
-              SLOT ( slotMenuClose() ) );
-
-    connect ( actStart,SIGNAL ( triggered ( bool ) ),this,
-              SLOT ( slotStartSharing() ) );
-
-    connect ( actStop,SIGNAL ( triggered ( bool ) ),this,
-              SLOT ( slotStopSharing() ) );
-
-
-
-    actStop->setEnabled ( false );
+	serverSocket=0l;
+	menuClose=false;
+	current_list=BLACK;
+
+	ui.setupUi ( this );
+	ui.box->setSelectionMode ( QAbstractItemView::ExtendedSelection );
+
+	connect ( ui.close_box,SIGNAL ( clicked ( QAbstractButton* ) ),
+	          SLOT ( slotMsgClose ( QAbstractButton* ) ) );
+
+	connect ( ui.ok_cancel_box,SIGNAL ( clicked ( QAbstractButton* ) ),
+	          SLOT ( slotMsgOkCancel ( QAbstractButton* ) ) );
+
+	connect ( ui.del,SIGNAL ( clicked() ),
+	          SLOT ( slotDelListItem() ) );
+
+	ui.icon->setPixmap ( QPixmap ( ":icons/128x128/x2godesktopsharing.png" ) );
+
+	ui.text->setText ( tr ( "<b>X2GO DesktopSharing v" ) +VERSION+
+	                   " </b >(Qt - "+qVersion() +")"+
+	                   ui.text->text() );
+
+	setWindowFlags ( Qt::Dialog );
+	Qt::WindowFlags flags=windowFlags();
+	flags&= ~Qt::WindowTitleHint;
+	setWindowFlags ( flags );
+
+	QString dispname=getenv ( "DISPLAY" );
+	socketFname=QDir::tempPath() +"/x2godesktopsharing_@"+
+	            getenv ( "LOGNAME" ) +"@"+dispname;
+	lockFname=QDir::tempPath() +"/x2godesktopsharing.lock_"+
+	          getenv ( "LOGNAME" ) +"@"+dispname;
+	if ( QFile::exists ( lockFname ) )
+	{
+		QFile file ( lockFname );
+		if ( file.open ( QIODevice::ReadOnly | QIODevice::Text ) )
+		{
+			QTextStream in ( &file );
+			if ( !in.atEnd() )
+			{
+				QString line = in.readLine();
+				file.close();
+				if ( abs ( line.toUInt() -
+					QDateTime::currentDateTime().toTime_t() ) <5 )
+					{
+
+					QString message=QString (
+					                tr (
+					                    "X2Go desktop sharing application "
+					                    "is already active for this "
+					                    "display \n"
+					                    "if this application is no longer "
+					                    "running, remove %1\n"
+					                    "and start again" ) ).arg ( lockFname );
+					QMessageBox::critical ( 0l,tr (
+					                                "Error" ),message,
+					                                QMessageBox::Ok,
+					                                QMessageBox::NoButton );
+					exit ( -1 );
+				}
+			}
+		}
+		QFile::remove ( lockFname );
+	}
+	if ( QFile::exists ( socketFname ) )
+		QFile::remove ( socketFname );
+
+	QTimer *lockTimer = new QTimer ( this );
+	connect ( lockTimer, SIGNAL ( timeout() ), this, SLOT ( slotUpdateLockFile() ) );
+	lockTimer->start ( 3000 );
+	trayIcon=new QSystemTrayIcon ( this );
+	setWindowIcon ( QIcon ( ":icons/22x22/x2godesktopsharing.png" ) );
+	menu = new QMenu ( this );
+	trayIcon->setContextMenu ( menu );
+	trayIcon->setToolTip ( tr ( "X2Go desktop sharing application" ) );
+
+	menu->addSeparator();
+
+	actWhite = menu->addAction ( QIcon ( ":icons/32x32/wlist.png" ) ,
+	                             tr ( "Granted users..." ) );
+	actBlack = menu->addAction ( QIcon ( ":icons/32x32/blist.png" ) ,
+	                             tr ( "Banned users..." ) );
+	menu->addSeparator();
+
+	actStart = menu->addAction ( QIcon ( ":icons/32x32/share.png" ) ,
+	                             tr ( "Activate desktop sharing" ) );
+
+	actStop = menu->addAction ( QIcon ( ":icons/32x32/stop.png" ) ,
+	                            tr ( "Deactivate desktop sharing" ) );
+
+	menu->addSeparator();
+	QAction* actAbout=menu->addAction (
+	                                    QIcon ( ":icons/32x32/x2godesktopsharing.png" ),
+	                                    tr ( "About X2GO Sharing" ) );
+	//
+	//     QAction* actAboutQt=menu->addAction(
+	//                              tr("About Qt"));
+	//     connect ( actAboutQt,SIGNAL ( triggered ( bool ) ),this,
+	//          SLOT ( slotAboutQt() ) );
+	//
+	connect ( actAbout,SIGNAL ( triggered ( bool ) ),this,
+	          SLOT ( slotAbout() ) );
+
+
+	menu->addSeparator();
+	QAction* actExit = menu->addAction ( QIcon ( ":icons/32x32/exit.png" ) ,
+	                                     tr ( "&Quit" ) );
+
+	connect ( actWhite,SIGNAL ( triggered ( bool ) ),this,
+	          SLOT ( slotWhiteList() ) );
+	connect ( actBlack,SIGNAL ( triggered ( bool ) ),this,
+	          SLOT ( slotBlackList() ) );
+
+	connect ( actExit,SIGNAL ( triggered ( bool ) ),this,
+	          SLOT ( slotMenuClose() ) );
+
+	connect ( actStart,SIGNAL ( triggered ( bool ) ),this,
+	          SLOT ( slotStartSharing() ) );
+
+	connect ( actStop,SIGNAL ( triggered ( bool ) ),this,
+	          SLOT ( slotStopSharing() ) );
+
+
+
+	actStop->setEnabled ( false );
 
 	// unix signals (TERM, INT) are piped into a unix socket and will raise Qt events
 	if (::socketpair(AF_UNIX, SOCK_STREAM, 0, sigkeybintFd))
@@ -183,24 +182,24 @@ ShareTray::ShareTray()
 	snTerm = new QSocketNotifier(sigtermFd[1], QSocketNotifier::Read, this);
 	connect(snTerm, SIGNAL(activated(int)), this, SLOT(handleSigTerm()));
 
-    QTimer *timer = new QTimer ( this );
-    connect ( timer, SIGNAL ( timeout() ), this, SLOT ( slotTimer() ) );
-    timer->start ( 5000 );
-    loadSettings();
-    setTrayIcon();
-    trayIcon->show();
+	QTimer *timer = new QTimer ( this );
+	connect ( timer, SIGNAL ( timeout() ), this, SLOT ( slotTimer() ) );
+	timer->start ( 5000 );
+	loadSettings();
+	setTrayIcon();
+	trayIcon->show();
 }
 
 
 ShareTray::~ShareTray()
 {
-    qDebug() <<"stopping desktop sharing";
-    slotStopSharing();
-    if ( QFile::exists ( lockFname ) )
-        QFile::remove ( lockFname );
-        qDebug() <<"lock file removed";
-    saveSettings();
-    qDebug() <<"settings saved";
+	qDebug() <<"stopping desktop sharing";
+	slotStopSharing();
+	if ( QFile::exists ( lockFname ) )
+		QFile::remove ( lockFname );
+		qDebug() <<"lock file removed";
+	saveSettings();
+	qDebug() <<"settings saved";
 }
 
 void ShareTray::handleSigKeybInt()
@@ -241,368 +240,366 @@ void ShareTray::termSignalHandler(int)
 
 void ShareTray::slotStopSharing()
 {
-    if ( serverSocket )
-    {
-        serverSocket->close();
-        delete serverSocket;
-        serverSocket=0l;
-    }
-    if ( QFile::exists ( socketFname ) )
-        QFile::remove ( socketFname );
-    for ( int i=menu->actions().count()-STAT_ACT_COUNT-1;i>=0;--i )
-    {
-        slotCloseConnection ( ( AccessAction* ) ( menu->actions() [i] ) );
-    }
-    actStop->setEnabled ( false );
-    actStart->setEnabled ( true );
-    setTrayIcon();
+	if ( serverSocket )
+	{
+		serverSocket->close();
+		delete serverSocket;
+		serverSocket=0l;
+	}
+	if ( QFile::exists ( socketFname ) )
+		QFile::remove ( socketFname );
+	for ( int i=menu->actions().count()-STAT_ACT_COUNT-1;i>=0;--i )
+	{
+		slotCloseConnection ( ( AccessAction* ) ( menu->actions() [i] ) );
+	}
+	actStop->setEnabled ( false );
+	actStart->setEnabled ( true );
+	setTrayIcon();
 }
 
 
 void ShareTray::slotStartSharing()
 {
-    actStop->setEnabled ( true );
-    actStart->setEnabled ( false );
-    if ( serverSocket )
-        delete serverSocket;
-    if ( QFile::exists ( socketFname ) )
-        QFile::remove ( socketFname );
-    serverSocket=new QLocalServer ( this );
-    if ( serverSocket->listen ( socketFname ) )
-    {
-
-        chown ( socketFname.toAscii(),getuid(),getgrnam ( "x2godesktopsharing" )->gr_gid );
-        QFile::setPermissions ( socketFname,
-                                QFile::ReadOwner|QFile::WriteOwner|QFile::ReadGroup|QFile::WriteGroup );
-        connect ( serverSocket,SIGNAL ( newConnection() ),
-                  this,SLOT ( slotServerConnection() ) );
-    }
-    else
-    {
-        QString message=
-            tr (
-                "Can't listen on socket:" ) + socketFname;
-        QMessageBox::critical ( 0l,tr (
-                                    "Error" ),message,
-                                QMessageBox::Ok,
-                                QMessageBox::NoButton );
-        close();
-    }
-    setTrayIcon();
+	actStop->setEnabled ( true );
+	actStart->setEnabled ( false );
+	if ( serverSocket )
+		delete serverSocket;
+	if ( QFile::exists ( socketFname ) )
+		QFile::remove ( socketFname );
+	serverSocket=new QLocalServer ( this );
+	if ( serverSocket->listen ( socketFname ) )
+	{
+
+		chown ( socketFname.toAscii(),getuid(),getgrnam ( "x2godesktopsharing" )->gr_gid );
+		QFile::setPermissions ( socketFname,
+		                        QFile::ReadOwner|QFile::WriteOwner|QFile::ReadGroup|QFile::WriteGroup );
+		connect ( serverSocket,SIGNAL ( newConnection() ),
+		          this,SLOT ( slotServerConnection() ) );
+	}
+	else
+	{
+		QString message=
+		    tr (
+		        "Can't listen on socket:" ) + socketFname;
+		QMessageBox::critical ( 0l,tr (
+		                            "Error" ),message,
+		                        QMessageBox::Ok,
+		                        QMessageBox::NoButton );
+		close();
+	}
+	setTrayIcon();
 }
 
 bool ShareTray::acceptConnections()
 {
-    return actStop->isEnabled();
+	return actStop->isEnabled();
 }
 
 QString ShareTray::getSocketAnswer ( QString message )
 {
-    qDebug() <<"message: "<<message;
-    QStringList lst=message.split ( ' ' );
-    if ( lst.size() !=11 )
-    {
-        qDebug() <<"wrong parameters";
-        return "DENY";
-    }
-    QStringList params=lst[9].split ( "XSHAD" );
-    if ( params.size() !=3 )
-    {
-        qDebug() <<"wrong parameters";
-        return "DENY";
-    }
-    QString client=lst[0];
-    QString user=params[1];
-    QString remote_user=lst[10];
-    if ( getAccess ( remote_user, client ) ==QMessageBox::Yes )
-    {
-        trayMessage ( tr ( "Access granted" ),QString ( tr ( "%1(%2): access granted" ) ).arg (remote_user ).arg ( client ) );
-        //start agent
-        QProcess proc ( this );
-        lst.removeAt ( 10 );;
-        lst.removeAt ( 0 );;
-        proc.start ( "x2gostartagent",lst );
-        if ( !proc.waitForFinished ( 5000 ) )
-        {
-            return "DENY";
-        }
-        else
-        {
-            QString output=proc.readAllStandardOutput();
-            qDebug() <<"agent out: "<<output;
-            QStringList lines=output.split ( "\n" );
-            QString pid="pid";
-            if ( lines.size() >3 )
-                pid=lines[2];
-            qDebug() <<"agent pid: "<<pid;
-            AccessAction *act=new AccessAction (
-                pid,remote_user,client,
-                QString ( tr ( "Disconnect %1(%2)" ) ).arg ( remote_user ).arg ( client ),
-                this );
-            menu->insertAction ( menu->actions() [0],act );
-            connect ( act,SIGNAL ( actionActivated ( AccessAction* ) ),this,
-                      SLOT ( slotCloseConnection ( AccessAction* ) ) );
-            trayMessage ( tr ( "Remote connection" ),
-                          QString (
-                              tr ( "%1(%2) connected" ) ).arg ( remote_user ).arg ( client ) );
-            setTrayIcon();
-            return output;
-        }
-    }
-    trayMessage ( tr ( "Access denied" ),QString (
-                      tr ( "%1(%2): access denied" ) ).arg ( remote_user ).arg ( client ) );
-    return "DENY";
+	qDebug() <<"message: "<<message;
+	QStringList lst=message.split ( ' ' );
+	if ( lst.size() !=11 )
+	{
+		qDebug() <<"wrong parameters";
+		return "DENY";
+	}
+	QStringList params=lst[9].split ( "XSHAD" );
+	if ( params.size() !=3 )
+	{
+		qDebug() <<"wrong parameters";
+		return "DENY";
+	}
+	QString client=lst[0];
+	QString user=params[1];
+	QString remote_user=lst[10];
+	if ( getAccess ( remote_user, client ) ==QMessageBox::Yes )
+	{
+		trayMessage ( tr ( "Access granted" ),QString ( tr ( "%1(%2): access granted" ) ).arg (remote_user ).arg ( client ) );
+		//start agent
+		QProcess proc ( this );
+		lst.removeAt ( 10 );;
+		lst.removeAt ( 0 );;
+		proc.start ( "x2gostartagent",lst );
+		if ( !proc.waitForFinished ( 5000 ) )
+		{
+			return "DENY";
+		}
+		else
+		{
+			QString output=proc.readAllStandardOutput();
+			qDebug() <<"agent out: "<<output;
+			QStringList lines=output.split ( "\n" );
+			QString pid="pid";
+			if ( lines.size() >3 )
+				pid=lines[2];
+			qDebug() <<"agent pid: "<<pid;
+			AccessAction *act=new AccessAction (
+			    pid,remote_user,client,
+			    QString ( tr ( "Disconnect %1(%2)" ) ).arg ( remote_user ).arg ( client ),
+			    this );
+			menu->insertAction ( menu->actions() [0],act );
+			connect ( act,SIGNAL ( actionActivated ( AccessAction* ) ),this,
+			          SLOT ( slotCloseConnection ( AccessAction* ) ) );
+			trayMessage ( tr ( "Remote connection" ),
+			              QString (
+			                  tr ( "%1(%2) connected" ) ).arg ( remote_user ).arg ( client ) );
+			setTrayIcon();
+			return output;
+		}
+	}
+	trayMessage ( tr ( "Access denied" ),QString (
+	              tr ( "%1(%2): access denied" ) ).arg ( remote_user ).arg ( client ) );
+	return "DENY";
 }
 
 void ShareTray::closeSocket ( SimpleLocalSocket* sock )
 {
-    qDebug() <<"closing null socket";
-    if ( sock )
-    {
-        qDebug() <<"closing socket";
-        delete sock;
-        qDebug() <<"done";
-    }
+	qDebug() <<"closing null socket";
+	if ( sock )
+	{
+		qDebug() <<"closing socket";
+		delete sock;
+		qDebug() <<"done";
+	}
 }
 
 void ShareTray::slotServerConnection()
 {
-    new SimpleLocalSocket ( this,serverSocket->nextPendingConnection() );
+	new SimpleLocalSocket ( this,serverSocket->nextPendingConnection() );
 }
 
 void ShareTray::slotCloseConnection ( AccessAction* action )
 {
-    kill ( action->pid().toUInt(),15 );
-    menu->removeAction ( action );
-    delete action;
-    setTrayIcon();
+	kill ( action->pid().toUInt(),15 );
+	menu->removeAction ( action );
+	delete action;
+	setTrayIcon();
 }
 
 
 int ShareTray::getAccess ( QString remote_user, QString host )
 {
-    if ( whiteList.contains ( remote_user ) )
-        return QMessageBox::Yes;
-    if ( blackList.contains ( remote_user ) )
-        return QMessageBox::No;
-
-    MessageBox m ( remote_user, host, this );
-    m.activateWindow();
-    m.raise();
-    int res=m.exec();
-    if ( m.isChecked() &&res==QMessageBox::Yes )
-        whiteList<<remote_user;
-    if ( m.isChecked() &&res==QMessageBox::No )
-        blackList<<remote_user;
-    actBlack->setEnabled ( blackList.size() >0 );
-    actWhite->setEnabled ( whiteList.size() >0 );
-    return res;
+	if ( whiteList.contains ( remote_user ) )
+		return QMessageBox::Yes;
+	if ( blackList.contains ( remote_user ) )
+		return QMessageBox::No;
+
+	MessageBox m ( remote_user, host, this );
+	m.activateWindow();
+	m.raise();
+	int res=m.exec();
+	if ( m.isChecked() &&res==QMessageBox::Yes )
+		whiteList<<remote_user;
+	if ( m.isChecked() &&res==QMessageBox::No )
+		blackList<<remote_user;
+	actBlack->setEnabled ( blackList.size() >0 );
+	actWhite->setEnabled ( whiteList.size() >0 );
+	return res;
 }
 
 void ShareTray::closeEvent ( QCloseEvent*  ev )
 {
-    if ( !menuClose )
-    {
-        ev->ignore();
-        hide();
-        return;
-    }
-    qDebug() <<"stopping desktop sharing";
-    slotStopSharing();
-    if ( QFile::exists ( lockFname ) )
-        QFile::remove ( lockFname );
-        qDebug() <<"lock file removed";
-    saveSettings();
-    qDebug() <<"settings saved";
+	if ( !menuClose )
+	{
+		ev->ignore();
+		hide();
+		return;
+	}
+	qDebug() <<"stopping desktop sharing";
+	slotStopSharing();
+	if ( QFile::exists ( lockFname ) )
+		QFile::remove ( lockFname );
+		qDebug() <<"lock file removed";
+	saveSettings();
+	qDebug() <<"settings saved";
 }
 
 void ShareTray::slotTimer()
 {
-    for ( int i=menu->actions().count()-STAT_ACT_COUNT-1;i>=0;--i )
-    {
-        AccessAction* action= ( AccessAction* ) ( menu->actions() [i] );
-        if ( !isProcessRunning ( action->pid() ) )
-        {
-            trayMessage ( tr ( "User disconnected" ),
-                          QString (
-                              tr ( "%1(%2) disconnected" ) ).arg (
-                              action->user() ).arg ( action->host() ) );
-            menu->removeAction ( action );
-            delete action;
-        }
-    }
-    setTrayIcon();
+	for ( int i=menu->actions().count()-STAT_ACT_COUNT-1;i>=0;--i )
+	{
+		AccessAction* action= ( AccessAction* ) ( menu->actions() [i] );
+		if ( !isProcessRunning ( action->pid() ) )
+		{
+			trayMessage ( tr ( "User disconnected" ),
+			              QString (
+			                  tr ( "%1(%2) disconnected" ) ).arg (
+			                  action->user() ).arg ( action->host() ) );
+			menu->removeAction ( action );
+			delete action;
+		}
+	}
+	setTrayIcon();
 }
 
 void ShareTray::trayMessage ( QString title, QString text )
 {
-    if ( !QSystemTrayIcon::supportsMessages () )
-        QToolTip::showText ( geometry().topLeft(),
-                             text );
-    else
-        trayIcon->showMessage ( title,text );
+	if ( !QSystemTrayIcon::supportsMessages () )
+		QToolTip::showText ( geometry().topLeft(),
+		                     text );
+	else
+		trayIcon->showMessage ( title,text );
 }
 
 
 bool ShareTray::isProcessRunning ( QString pid )
 {
-    if ( kill ( pid.toInt(),SIGCONT ) ==-1 )
-    {
-        if ( errno==ESRCH )
-        {
-            return false;
-        }
-    }
-    return true;
+	if ( kill ( pid.toInt(),SIGCONT ) ==-1 )
+	{
+		if ( errno==ESRCH )
+		{
+			return false;
+		}
+	}
+	return true;
 }
 
 
 void ShareTray::slotBlackList()
 {
-    current_list=BLACK;
-    showList();
-    setWindowTitle ( tr ( "Banned users" ) );
-
+	current_list=BLACK;
+	showList();
+	setWindowTitle ( tr ( "Banned users" ) );
 }
 
 void ShareTray::slotWhiteList()
 {
-    current_list=WHITE;
-    showList();
-    setWindowTitle ( tr ( "Granted users" ) );
-
+	current_list=WHITE;
+	showList();
+	setWindowTitle ( tr ( "Granted users" ) );
 }
 
 void ShareTray::showList()
 {
-    show();
-    ui.ok_cancel_box->show();
-    ui.box->show();
-    ui.del->show();
-
-    ui.close_box->hide();
-    ui.icon->hide();
-    ui.text->hide();
-
-    QStringList* lst;
-    if ( current_list==BLACK )
-        lst=&blackList;
-    else
-        lst=&whiteList;
-    lst->sort();
-    ui.box->clear();
-    ui.box->insertItems ( 0,*lst );
+	show();
+	ui.ok_cancel_box->show();
+	ui.box->show();
+	ui.del->show();
+
+	ui.close_box->hide();
+	ui.icon->hide();
+	ui.text->hide();
+
+	QStringList* lst;
+	if ( current_list==BLACK )
+		lst=&blackList;
+	else
+		lst=&whiteList;
+	lst->sort();
+	ui.box->clear();
+	ui.box->insertItems ( 0,*lst );
 }
 
 void ShareTray::loadSettings()
 {
-    QSettings st ( QDir::homePath() +"/.x2godesktopsharing/settings",
-                   QSettings::NativeFormat );
+	QSettings st ( QDir::homePath() +"/.x2godesktopsharing/settings",
+	               QSettings::NativeFormat );
 
-    blackList= st.value ( "blacklist" ).toStringList();
-    whiteList= st.value ( "whitelist" ).toStringList();
+	blackList= st.value ( "blacklist" ).toStringList();
+	whiteList= st.value ( "whitelist" ).toStringList();
 
-    actBlack->setEnabled ( blackList.size() >0 );
-    actWhite->setEnabled ( whiteList.size() >0 );
+	actBlack->setEnabled ( blackList.size() >0 );
+	actWhite->setEnabled ( whiteList.size() >0 );
 }
 
 void ShareTray::saveSettings()
 {
-    QSettings st ( QDir::homePath() +"/.x2godesktopsharing/settings",
-                   QSettings::NativeFormat );
+	QSettings st ( QDir::homePath() +"/.x2godesktopsharing/settings",
+	               QSettings::NativeFormat );
 
-    st.setValue ( "blacklist",blackList );
-    st.setValue ( "whitelist",whiteList );
+	st.setValue ( "blacklist",blackList );
+	st.setValue ( "whitelist",whiteList );
 }
 
 
 void ShareTray::setTrayIcon()
 {
-    if ( !acceptConnections() )
-    {
-        trayIcon->setIcon ( QIcon ( ":icons/22x22/discard.png" ) );
-        return;
-    }
-    if ( menu->actions().count() >STAT_ACT_COUNT )
-    {
-        trayIcon->setIcon ( QIcon ( ":icons/22x22/view.png" ) );
-        return;
-    }
-    trayIcon->setIcon ( QIcon ( ":icons/22x22/accept.png" ) );
+	if ( !acceptConnections() )
+	{
+		trayIcon->setIcon ( QIcon ( ":icons/22x22/discard.png" ) );
+		return;
+	}
+	if ( menu->actions().count() >STAT_ACT_COUNT )
+	{
+		trayIcon->setIcon ( QIcon ( ":icons/22x22/view.png" ) );
+		return;
+	}
+	trayIcon->setIcon ( QIcon ( ":icons/22x22/accept.png" ) );
 }
 
 
 
 void ShareTray::slotAbout()
 {
-    setWindowTitle ( tr ( "X2Go Desktop Sharing" ) );
+	setWindowTitle ( tr ( "X2Go Desktop Sharing" ) );
 
-    show();
-    ui.ok_cancel_box->hide();
-    ui.box->hide();
-    ui.del->hide();
+	show();
+	ui.ok_cancel_box->hide();
+	ui.box->hide();
+	ui.del->hide();
 
-    ui.close_box->show();
-    ui.icon->show();
-    ui.text->show();
+	ui.close_box->show();
+	ui.icon->show();
+	ui.text->show();
 }
 
 
 void ShareTray::slotAboutQt()
 {
-    QMessageBox::aboutQt ( 0 );
+	QMessageBox::aboutQt ( 0 );
 }
 
 void ShareTray::slotMsgOkCancel ( QAbstractButton* button )
 {
-    if ( ui.ok_cancel_box->buttonRole ( button ) ==QDialogButtonBox::AcceptRole )
-    {
-        QStringList* lst;
-        if ( current_list==BLACK )
-            lst=&blackList;
-        else
-            lst=&whiteList;
-        lst->clear();
-        for ( int i=ui.box->count()-1;i>=0;--i )
-        {
-            *lst<<ui.box->item ( i )->text();
-        }
-    }
-    actBlack->setEnabled ( blackList.size() >0 );
-    actWhite->setEnabled ( whiteList.size() >0 );
-    hide();
+	if ( ui.ok_cancel_box->buttonRole ( button ) ==QDialogButtonBox::AcceptRole )
+	{
+		QStringList* lst;
+		if ( current_list==BLACK )
+			lst=&blackList;
+		else
+			lst=&whiteList;
+		lst->clear();
+		for ( int i=ui.box->count()-1;i>=0;--i )
+		{
+			*lst<<ui.box->item ( i )->text();
+		}
+	}
+	actBlack->setEnabled ( blackList.size() >0 );
+	actWhite->setEnabled ( whiteList.size() >0 );
+	hide();
 }
 
 void ShareTray::slotMsgClose ( QAbstractButton* )
 {
-    hide();
+	hide();
 }
 
 void ShareTray::slotDelListItem()
 {
-    for ( int i=ui.box->count()-1;i>=0;--i )
-    {
-        QListWidgetItem* it=ui.box->item ( i );
-        if ( it->isSelected() )
-        {
-            ui.box->takeItem ( i );
-            delete it;
-        }
-    }
+	for ( int i=ui.box->count()-1;i>=0;--i )
+	{
+		QListWidgetItem* it=ui.box->item ( i );
+		if ( it->isSelected() )
+		{
+			ui.box->takeItem ( i );
+			delete it;
+		}
+	}
 }
 
 void ShareTray::slotMenuClose()
 {
-    menuClose=true;
-    close();
+	menuClose=true;
+	close();
 }
 
 void ShareTray::slotUpdateLockFile()
 {
-    QFile file ( lockFname );
-    if ( file.open ( QIODevice::WriteOnly | QIODevice::Text ) )
-    {
-        QTextStream out ( &file );
-        out<<QDateTime::currentDateTime().toTime_t();
-    }
+	QFile file ( lockFname );
+	if ( file.open ( QIODevice::WriteOnly | QIODevice::Text ) )
+	{
+		QTextStream out ( &file );
+		out<<QDateTime::currentDateTime().toTime_t();
+	}
 }


hooks/post-receive
-- 
x2godesktopsharing.git (Desktop Sharing for X2Go)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "x2godesktopsharing.git" (Desktop Sharing for X2Go).




More information about the x2go-commits mailing list