[PC-BSD Commits] r4274 - in pcbsd/trunk/pcbsd-netmanager/src: NetworkManager NetworkTray
svn at pcbsd.org
svn at pcbsd.org
Tue Jul 28 08:22:10 PDT 2009
Author: kris
Date: 2009-07-28 08:22:07 -0700 (Tue, 28 Jul 2009)
New Revision: 4274
Modified:
pcbsd/trunk/pcbsd-netmanager/src/NetworkManager/networkman.cpp
pcbsd/trunk/pcbsd-netmanager/src/NetworkTray/NetworkTray.cpp
pcbsd/trunk/pcbsd-netmanager/src/NetworkTray/NetworkTray.h
pcbsd/trunk/pcbsd-netmanager/src/NetworkTray/main.cpp
Log:
Fixed some bugs with the network tray in KDE 4.3, use right permissions and .desktop format
now.
Also fixed bug when starting with an invalid device, in case user changes devices around, don't
continue with non-existant device name.
Modified: pcbsd/trunk/pcbsd-netmanager/src/NetworkManager/networkman.cpp
===================================================================
--- pcbsd/trunk/pcbsd-netmanager/src/NetworkManager/networkman.cpp 2009-07-28 13:57:21 UTC (rev 4273)
+++ pcbsd/trunk/pcbsd-netmanager/src/NetworkManager/networkman.cpp 2009-07-28 15:22:07 UTC (rev 4274)
@@ -588,19 +588,21 @@
Type="-ethernet";
}
- // Save the new file
+ // Save the new file
QFile fileout( "/home/" + username + "/.kde4/Autostart/tray-" + Devs[sel] + ".desktop" );
if ( fileout.open( QIODevice::WriteOnly ) ) {
- QTextStream streamout( &fileout );
- streamout << "[Desktop Entry]\nExec=pc-nettray ";
+ QTextStream streamout( &fileout );
+ streamout << "#!/usr/bin/env xdg-open\n";
+ streamout << "[Desktop Entry]\nExec=pc-nettray ";
streamout << Type + " " + Devs[sel] ;
streamout << "\nIcon=network\nStartupNotify=false\nType=Application\n";
fileout.close();
runCommand("chown " + username + ":" + username + " \"/home/" + username + "/.kde4/Autostart/tray-" + Devs[sel] + ".desktop\"");
- //runCommand("su " + username + " -c \"pc-nettray " + Type + " " + Devs[sel] + "\"");
- // Run the command without SU flags
- runCommand("pc-nettray " + Type + " " + Devs[sel] + " &");
+ runCommand("chmod 744 \"/home/" + username + "/.kde4/Autostart/tray-" + Devs[sel] + ".desktop\"");
+
+ // Now start the tray icon
+ runCommand("pc-nettray " + Type + " " + Devs[sel] + " &");
}
Modified: pcbsd/trunk/pcbsd-netmanager/src/NetworkTray/NetworkTray.cpp
===================================================================
--- pcbsd/trunk/pcbsd-netmanager/src/NetworkTray/NetworkTray.cpp 2009-07-28 13:57:21 UTC (rev 4273)
+++ pcbsd/trunk/pcbsd-netmanager/src/NetworkTray/NetworkTray.cpp 2009-07-28 15:22:07 UTC (rev 4274)
@@ -52,6 +52,8 @@
username = QString::fromLocal8Bit(getenv("LOGNAME"));
+ // Confirm this is a legit device
+ confirmDevice(DeviceName);
DeviceStatus = getStatusForIdent( DeviceName );
DeviceIP = getIpForIdent( DeviceName );
@@ -145,6 +147,24 @@
}
+void NetworkTray::confirmDevice( QString device )
+{
+ QString command = "ifconfig -l | grep " + device;
+ QString line = getLineFromCommandOutput(command);
+ if ( line.isEmpty() )
+ {
+ // Opps, this device doesn't seem to exist!
+ // First run a check to see if this device has a auto-start .desktop associated with it
+ QFile desktopfile("/home/" + username + "/.kde4/Autostart/tray-" + device + ".desktop");
+ if ( desktopfile.exists() )
+ {
+ // Remove this file
+ desktopfile.remove();
+ }
+ exit(1);
+ }
+}
+
QString NetworkTray::getLineFromCommandOutput( QString command )
{
FILE *file = popen(command.toLatin1(),"r");
Modified: pcbsd/trunk/pcbsd-netmanager/src/NetworkTray/NetworkTray.h
===================================================================
--- pcbsd/trunk/pcbsd-netmanager/src/NetworkTray/NetworkTray.h 2009-07-28 13:57:21 UTC (rev 4273)
+++ pcbsd/trunk/pcbsd-netmanager/src/NetworkTray/NetworkTray.h 2009-07-28 15:22:07 UTC (rev 4274)
@@ -34,6 +34,7 @@
private:
void displayTooltip();
+ void confirmDevice(QString device);
QString getLineFromCommandOutput( QString command );
QString getNameForIdent( QString ident );
QString getIpForIdent( QString ident );
Modified: pcbsd/trunk/pcbsd-netmanager/src/NetworkTray/main.cpp
===================================================================
--- pcbsd/trunk/pcbsd-netmanager/src/NetworkTray/main.cpp 2009-07-28 13:57:21 UTC (rev 4273)
+++ pcbsd/trunk/pcbsd-netmanager/src/NetworkTray/main.cpp 2009-07-28 15:22:07 UTC (rev 4274)
@@ -61,6 +61,8 @@
} else if (flag == "-wireless") {
Type = "Wireless";
tray.programInit(Type, Device);
+ } else {
+ exit(1);
}
tray.show();
More information about the Commits
mailing list