[PC-BSD Commits] r20060 - pcbsd/current/src-qt4/pc-mounttray

svn at pcbsd.org svn at pcbsd.org
Mon Oct 29 11:46:45 PDT 2012


Author: kenmoore
Date: 2012-10-29 18:46:45 +0000 (Mon, 29 Oct 2012)
New Revision: 20060

Modified:
   pcbsd/current/src-qt4/pc-mounttray/mountTray.cpp
   pcbsd/current/src-qt4/pc-mounttray/mountTray.h
   pcbsd/current/src-qt4/pc-mounttray/pc-mounttray.pro
Log:
Change the mount tray over to using QLocalSocket for the devd watcher instead of using QProcess.



Modified: pcbsd/current/src-qt4/pc-mounttray/mountTray.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-mounttray/mountTray.cpp	2012-10-29 18:38:37 UTC (rev 20059)
+++ pcbsd/current/src-qt4/pc-mounttray/mountTray.cpp	2012-10-29 18:46:45 UTC (rev 20060)
@@ -5,13 +5,8 @@
 #include <QDir>
 #include <QImage>
 #include <QMenu>
-#include <QProcess>
-#include <QToolTip>
-#include <QTextStream>
-#include <QTimer>
 #include <QTranslator>
-#include <QProcessEnvironment>
-#include <iostream>
+//#include <iostream>
 
 #include "mountTray.h"
 #include <pcbsd-hardware.h>
@@ -169,17 +164,21 @@
 
 
 void MountTray::startupDevdProc(){
-  devdProc = new QProcess(this);
-  connect(devdProc, SIGNAL(readyReadStandardOutput()), this, SLOT(newDevdMessage()) );
-  
-  devdProc->start("cat /var/run/devd.pipe");
-  
+  devdProc = new QLocalSocket(this);
+  devdProc->connectToServer("/var/run/devd.pipe",QIODevice::ReadOnly | QIODevice::Text);
+  if( devdProc->waitForConnected(3000) ){ //Max wait of 3 sec
+    connect(devdProc, SIGNAL(readyRead()), this, SLOT(newDevdMessage()) );
+  }else{
+    qDebug() << " - Could not startup the devd watching process";
+  }
 }
 
 void MountTray::newDevdMessage(){
-  QString tmpline = devdProc->readAllStandardOutput();
   //Make sure there are not multiple lines output at the same time
-  QStringList lList = tmpline.split("\n");
+  QStringList lList;
+  while(devdProc->canReadLine()){
+    lList << devdProc->readLine();
+  }
   //Parse each line seperately
   for(int i=0; i<lList.length(); i++){
     QString line = lList[i];
@@ -199,8 +198,8 @@
       index = findDeviceInList(cdev);
       if( !cdevtype.isEmpty() ){
         if( isAttached && !dlab.isEmpty() && (index == -1) ){ deviceFound = TRUE; }
-	else if( !isAttached && ( index != -1) ){ deviceFound = TRUE; }
-      }
+	
+      }else if( !isAttached && ( index != -1) ){ deviceFound = TRUE; }
     }
     //Perform action if a device is found
     if(deviceFound){
@@ -225,7 +224,7 @@
 void MountTray::closeTray(){
   qDebug() << "pc-mounttray: closing down";
   //Kill the devd watching process
-  devdProc->terminate();
+  devdProc->disconnectFromServer();
   //Close down the application
   exit(0);
 }

Modified: pcbsd/current/src-qt4/pc-mounttray/mountTray.h
===================================================================
--- pcbsd/current/src-qt4/pc-mounttray/mountTray.h	2012-10-29 18:38:37 UTC (rev 20059)
+++ pcbsd/current/src-qt4/pc-mounttray/mountTray.h	2012-10-29 18:46:45 UTC (rev 20060)
@@ -1,11 +1,12 @@
+#ifndef MOUNT_TRAY_H
+#define MOUNT_TRAY_H
+
 // QT Includes
 #include <qpair.h>
-#include <QProcess>
 #include <QDialog>
-#include <QFileSystemWatcher>
 #include <QSystemTrayIcon>
 #include <QMenu>
-#include <QTimer>
+#include <QLocalSocket>
 
 #include "menuItem.h"
 
@@ -37,7 +38,7 @@
   
 private:
   QString MOUNTDIR, DEVICEDIR, USERNAME, FILEMAN;
-  QProcess *devdProc;
+  QLocalSocket* devdProc;
   int numMount, numAvail;
   QSystemTrayIcon* trayIcon;
   QMenu* trayIconMenu;
@@ -53,3 +54,5 @@
   void getDefaultFileManager();
 
 };
+
+#endif

Modified: pcbsd/current/src-qt4/pc-mounttray/pc-mounttray.pro
===================================================================
--- pcbsd/current/src-qt4/pc-mounttray/pc-mounttray.pro	2012-10-29 18:38:37 UTC (rev 20059)
+++ pcbsd/current/src-qt4/pc-mounttray/pc-mounttray.pro	2012-10-29 18:46:45 UTC (rev 20060)
@@ -1,6 +1,6 @@
 TEMPLATE	= app
 LANGUAGE	= C++
-QT	+= core gui
+QT	+= core gui network
 
 CONFIG	+= qt warn_on release
 



More information about the Commits mailing list