[PC-BSD Commits] r4258 - pbibuild/pbi-source/PBItext
svn at pcbsd.org
svn at pcbsd.org
Tue Jul 21 11:18:28 PDT 2009
Author: kris
Date: 2009-07-21 11:18:28 -0700 (Tue, 21 Jul 2009)
New Revision: 4258
Modified:
pbibuild/pbi-source/PBItext/main.cpp
Log:
Updated PBItext to use new xdg utils, it is now ready for 8.0
Modified: pbibuild/pbi-source/PBItext/main.cpp
===================================================================
--- pbibuild/pbi-source/PBItext/main.cpp 2009-07-21 18:10:49 UTC (rev 4257)
+++ pbibuild/pbi-source/PBItext/main.cpp 2009-07-21 18:18:28 UTC (rev 4258)
@@ -21,10 +21,10 @@
void CreateConfigSlot(void);
void CreateIconsSlot( int exenum );
void CheckScriptSlot(void);
-void CreateMimeSlot( int MimeNum );
void acceptLicense(void);
void slotSetupCustomRemoveScript();
void runKmenuRegen();
+void doDesktopInstallScript();
QString ProgramName;
QString ProgramVer;
@@ -58,9 +58,11 @@
QString ExeTaskbar[100];
QString ProgUpdateURL;
int acceptlic = 0;
-int createdMimeFiles = 0;
+QStringList IconScript;
+QStringList IconUnScript;
+
int main( int argc, char ** argv )
{
QCoreApplication a( argc, argv);
@@ -637,39 +639,95 @@
// Start creating the Icons now
CreateIconsSlot(i);
-
-
-
i++;
}
-
- // Check if we need to create any mime icons
- if ( ! MimeExt[0].isEmpty() )
+ // Install the XDG data
+ doDesktopInstallScript();
+
+ // Check if there is a custom script to be run
+ CheckScriptSlot();
+
+
+}
+
+
+
+
+void doDesktopInstallScript()
+{
+ // Make sure our .sbin directory exists
+ QString binDir = "/Programs/" + ProgDirName + "/.sbin";
+ QString tmp;
+ QDir bindir;
+ bindir.mkpath ( binDir );
+
+ // Write the install script
+ //////////////////////////////////////////////////
+ tmp = binDir + "/install-xdg-icons.sh";
+ QFile file( tmp );
+ if(!file.open( QIODevice::WriteOnly))
{
- createdMimeFiles=1;
- CreateMimeSlot(0);
- } else {
- // Check if there is a custom script to be run
- CheckScriptSlot();
+ cout << "Failed to open install-xdg-icons.sh for writing!";
+ return;
}
+ QTextStream stream( &file );
+ // Read through the install script list, and write it now
+ for (int i = 0; i < IconScript.size(); ++i) {
+ stream << IconScript.at(i) + "\n";
+ }
+ file.close();
+ // Chmod 755 on this script
+ system("chmod 755 " + tmp.toLatin1() );
-}
+ // Now run the install script
+ system( tmp.toLatin1() );
+ // Write the uninstall script
+ //////////////////////////////////////////////////
+ tmp = binDir + "/uninstall-xdg-icons.sh";
+ QFile unfile( tmp );
+ if(!unfile.open( QIODevice::WriteOnly))
+ {
+ cout << "Failed to open uninstall-xdg-icons.sh for writing!\n";
+ return;
+ }
+ QTextStream unstream( &unfile );
+ // Read through the install script list, and write it now
+ for (int i = 0; i < IconUnScript.size(); ++i) {
+ unstream << IconUnScript.at(i) + "\n";
+ }
+ unfile.close();
+ // Chmod 755 on this script
+ system("chmod 755 " + tmp.toLatin1() );
+}
+
void CreateIconsSlot( int exenum )
{
- QString ExeTemp = ExePath[exenum];
+ QString ExeTemp = ExePath[exenum];
QString tmp;
- //StatusLabel->setText("Creating Icons...");
-
- // Get the binary name
QString Binary;
+ QString Icon;
+ QString MainIcon;
+ //StatusLabel->setText("Creating Icons...");
+
+
+ // Define our kmenu / desktop file directories
+ QString DesktopDir = "/Programs/" + ProgDirName + "/.desktop-icons";
+ QString MenuDir = "/Programs/" + ProgDirName + "/.kmenu-icons";
+ QDir deskdir;
+ deskdir.mkpath ( DesktopDir );
+ deskdir.mkpath ( MenuDir );
+
+
+ // Get the binary name / info
+ ///////////////////////////////////////////////////////////////
if ( ExeWebLink[exenum] == "1" )
{
Binary.setNum(exenum);
@@ -677,7 +735,7 @@
} else {
// Remove a trailing /
- if ( ExeTemp.lastIndexOf("/" ) != -1 )
+ if ( ExeTemp.lastIndexOf("/") != -1 )
{
Binary = ExeTemp.remove(0, ExeTemp.lastIndexOf("/") );
} else {
@@ -691,11 +749,12 @@
Binary = tmp.remove(0,1);
}
}
-
- // Get the right icon
- QString Icon;
- QString MainIcon;
-
+ ///////////////////////////////////////////////////////////////
+
+
+
+ // Get the right icon
+ ///////////////////////////////////////////////////////////////
MainIcon = "/Programs/" + ProgDirName + "/" + DefaultIcon;
if ( ExeIcon[exenum].isEmpty() && DefaultIcon.isEmpty() )
@@ -706,351 +765,335 @@
} else {
Icon = "/Programs/" + ProgDirName + "/" + ExeIcon[exenum];
}
+ ///////////////////////////////////////////////////////////////
+ // Make our PATH links for this binary
+ ///////////////////////////////////////////////////////////////
+ QDir bindir;
+ bindir.mkpath ( "/Programs/bin");
+ runCommand("ln -fs /Programs/" + ProgDirName + "/.sbin/" + Binary \
+ + " /Programs/bin/" + Binary+ " >/dev/null 2>/dev/null");
+ ///////////////////////////////////////////////////////////////
- if( NoMenu[exenum] == "0" )
+
+
+ // Menu Icon Creation
+ ///////////////////////////////////////////////////////////////
+ tmp = MenuDir + "/PBI-" + ProgDirName + "-" + Binary + ".desktop";
+ QFile file( tmp );
+ if(!file.open( QIODevice::WriteOnly))
{
- tmp = "/usr/local/share/applications/kde/PBI-" + ProgramName + "-" + Binary + ".desktop";
- QFile file( tmp );
- if(!file.open( QIODevice::WriteOnly))
+ //QMessageBox::information( this, tr("Error!"), "Failed to open " + tmp + " for writing!" );
+ return;
+ }
+
+ QTextStream stream( &file );
+
+
+ stream << "[Desktop Entry]\n";
+ stream << "Value=1.0\n";
+ stream << "Type=Application\n";
+
+ if( NoMenu[exenum] != "0" )
+ {
+ stream << "Hidden=true\n";
+ }
+
+ // Regular Program Application
+ if ( ExeLink[exenum] == "0" && ExeWebLink[exenum] == "0" ) {
+ stream << "Name=" + Binary + "\n";
+ stream << "GenericName=" + ExeDescr[exenum] + "\n";
+ stream << "Exec=/Programs/bin/" + Binary + "\n";
+ } else {
+ // We are working on a link of some type
+ QString link;
+ if ( ExeWebLink[exenum] == "1" )
{
- printf("Failed to open " + tmp.toLatin1() + " for writing!\n");
- return;
- }
- QTextStream stream( &file );
+ link = ExePath[exenum];
+ } else {
+ link = "/Programs/" + ProgDirName + "/" +ExePath[exenum];
+ }
+ stream << "Name=" + ExeDescr[exenum] + "\n";
+ stream << "GenericName=" + ExeDescr[exenum] + "\n";
+ stream << "Exec=kfmclient exec '" << link << "'\n";
+ }
- // Regular Program Application
- if ( ExeLink[exenum] == "0" && ExeWebLink[exenum] == "0" && ExeLink[exenum] == "0" ) {
-
- QDir bindir;
- bindir.mkpath ( "/Programs/bin");
- runCommand("ln -fs /Programs/" + ProgDirName + "/.sbin/" + Binary + " /Programs/bin/" + Binary+ " >/dev/null 2>/dev/null");
+ stream << "Path=/Programs/" + ProgDirName + "/\n";
+ stream << "Icon=" + Icon + "\n";
- stream << "[Desktop Entry]\n";
- stream << "GenericName=" + ExeDescr[exenum] + "\n";
- stream << "Name=" + Binary + "\n";
- //stream << "Exec=/Programs/" + ProgDirName + "/.sbin/" + Binary + "\n";
- stream << "Exec=/Programs/bin/" + Binary + "\n";
- stream << "Type=Application\n";
- stream << "Path=/Programs/" + ProgDirName + "/\n";
- stream << "Icon=" + Icon + "\n";
+ // Check if we have any mime types for this binary
+ if ( ! MimeExt[exenum].isEmpty() )
+ {
+ stream << "MimeType=application/x-" + Binary + "\n";
- } else {
+ QString mimetmp = MenuDir + "/PBI-" + ProgDirName + "-" + Binary + ".xml";
+ QFile mimefile( mimetmp );
+ if(!mimefile.open( QIODevice::WriteOnly))
+ {
+ //QMessageBox::information( this, tr("Error!"), "Failed to open " + mimetmp + " for writing!" );
+ return;
+ }
- QString link;
-
- if ( ExeWebLink[exenum] == "1" )
- {
- link = ExePath[exenum];
- } else {
- link = "/Programs/" + ProgDirName + "/" +ExePath[exenum];
- }
-
- stream << "[Desktop Entry]\n";
- stream << "Exec=kfmclient exec '" << link << "'\n";
- stream << "Icon=" + Icon + "\n";
- stream << "Name=" + ExeDescr[exenum] + "\n";
- stream << "Path=\n";
- stream << "Type=Application\n";
- stream << "StartupNotify=false\n";
- stream << "X-KDE-SubstituteUID=false\n";
+ QTextStream mimestream( &mimefile );
+
+
+ mimestream << "<?xml version=\"1.0\"?>\n";
+ mimestream << "<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>\n";
+ mimestream << " <mime-type type=\"application/x-" + Binary + "\">\n";
+ mimestream << " <comment>" + ExeDescr[exenum] + "</comment>\n";
+
+ // Read through the extensions and write them
+ QStringList extensions = MimeExt[exenum].split(";", QString::SkipEmptyParts);
+ for (int i = 0; i < extensions.size(); ++i) {
+ QString tmpmime = extensions.at(i).simplified();
+ tmpmime.replace(QString(" "), QString(""));
+ mimestream << " <glob pattern=\"" + tmpmime + "\"/>\n";
}
-
- if ( RunRoot[exenum] == "1" )
- {
- stream << "X-KDE-SubstituteUID=true\nX-KDE-Username=root\n";
- }
- if ( RunShell[exenum] == "1" )
- {
- stream << "Terminal=true\nTerminalOptions=\n";
- }
- if ( Notify[exenum] == "0" )
- {
- stream << "X-KDE-StartupNotify=false\n";
- } else {
- stream << "X-KDE-StartupNotify=true\n";
- }
+
+ mimestream << " </mime-type>\n";
+ mimestream << "</mime-info>\n";
+
+ // Add the icons
+ IconScript << " " << "xdg-icon-resource install --context mimetypes /Programs/" \
+ + ProgDirName + "/" + MimeIcon[exenum] + " --size 64 application-x-" \
+ + Binary;
+ IconUnScript << " " << "xdg-icon-resource uninstall --context mimetypes /Programs/" \
+ + ProgDirName + "/" + MimeIcon[exenum] + " --size 64 application-x-" \
+ + Binary;
+
+ // Add the mime info now
+ IconScript << " " << "xdg-mime install " + mimetmp;
+ IconUnScript << "xdg-mime uninstall " + mimetmp;
+
+ } // End of mime additition
+
+ if ( RunRoot[exenum] == "1" )
+ {
+ stream << "X-KDE-SubstituteUID=true\nX-KDE-Username=root\n";
+ }
+ if ( RunShell[exenum] == "1" )
+ {
+ stream << "Terminal=true\nTerminalOptions=\n";
+ }
+ if ( Notify[exenum] == "0" )
+ {
+ stream << "X-KDE-StartupNotify=false\n";
+ } else {
+ stream << "X-KDE-StartupNotify=true\n";
+ }
- // Create a directory directly in the top menu
- if ( ExeOwndir[exenum] == 0 ) {
- // Create our desktop-directories entry
- tmp = "/usr/local/share/desktop-directories/PBI-" + ProgDirName + ".directory";
- QFile desktopdirfile( tmp );
- if ( desktopdirfile.open( QIODevice::WriteOnly | QIODevice::Text) ) {
- QTextStream streamdd( &desktopdirfile );
- streamdd << "[Desktop Entry]\n";
- streamdd << "Comment=" << ProgDirName << "\n";
- streamdd << "GenericName=" << ProgramName << "\n";
- streamdd << "Icon=" << MainIcon << "\n";
- streamdd << "Name=" << ProgramName << "\n";
- desktopdirfile.close();
- }
+ // Create a subdirectory in the top level or a sub menu
+ if ( ExeOwndir[exenum] == 0 || ExeOwndir[exenum] == 1 ) {
+ // Create our desktop-directories entry
+ tmp = MenuDir + "/PBI-" + ProgDirName + ".directory";
+ QFile desktopdirfile( tmp );
+ if ( desktopdirfile.open( QIODevice::WriteOnly | QIODevice::Text) ) {
+ QTextStream streamdd( &desktopdirfile );
+ streamdd << "[Desktop Entry]\n";
+ streamdd << "Value=1.0\n";
+ streamdd << "Type=Directory\n";
+ streamdd << "Name=" << ProgramName << "\n";
+ streamdd << "Comment=" << ProgDirName << "\n";
+ streamdd << "Icon=" << MainIcon << "\n";
+ desktopdirfile.close();
+ }
- tmp = "/usr/local/etc/xdg/menus/applications-merged/PBI-" + ProgDirName + ".merge.menu";
- QFile xdgfile( tmp );
- if ( xdgfile.open( QIODevice::WriteOnly | QIODevice::Text) ) {
- QTextStream streamxdg( &xdgfile );
- streamxdg << "<!DOCTYPE Menu PUBLIC \"-//freedesktop//DTD Menu 1.0//EN\" \"http://www.freedesktop.org/standards/menu-spec/1.0/menu.dtd\">\n";
- streamxdg << "<Menu>\n";
- streamxdg << " <Menu>\n";
- streamxdg << " <Name>" << ProgramName << "</Name>\n";
- streamxdg << " <Directory>PBI-" << ProgDirName << ".directory</Directory>\n";
- streamxdg << " <Include>\n";
- streamxdg << " <Category>X-" << ProgDirName << "</Category>\n";
- streamxdg << " </Include>\n";
- streamxdg << " </Menu>\n";
- streamxdg << "</Menu>\n";
+ // Add this desktop file to our install script
+ IconScript << " " << "xdg-desktop-menu install " + MenuDir + "/PBI-" + ProgDirName + ".directory " \
+ + MenuDir + "/PBI-" + ProgDirName + "-" + Binary + ".desktop";
+ IconUnScript << " " << "xdg-desktop-menu uninstall " + MenuDir + "/PBI-" + ProgDirName + ".directory " \
+ + MenuDir + "/PBI-" + ProgDirName + "-" + Binary + ".desktop";
+
+ // Create a directory in a KDE sub-menu
+ if (ExeOwndir[exenum] == 1) {
+ QDir xdgdir;
+ xdgdir.mkpath ( "/usr/local/etc/xdg/menus/applications-merged");
+ tmp = "/usr/local/etc/xdg/menus/applications-merged/PBI-" + ProgDirName + ".merge.menu";
- xdgfile.close();
- }
+ // Make sure we cleanup and remove this file during uninstall
+ IconUnScript << " " << "rm " + tmp;
- stream << "Categories=Qt;KDE;X-" + ProgDirName + ";\n";
- }
+ QFile xdgfile( tmp );
+ if ( xdgfile.open( QIODevice::WriteOnly | QIODevice::Text) ) {
+ QString ParentCat, SubCat;
+ if ( ExeKdeCat[exenum] == "Development")
+ ParentCat = "Development";
+ if ( ExeKdeCat[exenum] == "Editors")
+ ParentCat = "Editors";
+ if ( ExeKdeCat[exenum] == "Edutainment")
+ ParentCat = "Education";
+ if ( ExeKdeCat[exenum] == "Edutainment/Languages") {
+ ParentCat = "Education";
+ SubCat = "Languages";
+ }
+ if ( ExeKdeCat[exenum] == "Edutainment/Math") {
+ ParentCat = "Education";
+ SubCat = "Mathmatics";
+ }
+ if ( ExeKdeCat[exenum] == "Edutainment/Misc") {
+ ParentCat = "Education";
+ SubCat = "Misc";
+ }
+ if ( ExeKdeCat[exenum] == "Edutainment/Science") {
+ ParentCat = "Education";
+ SubCat = "Science";
+ }
+ if ( ExeKdeCat[exenum] == "Edutainment/Teaching") {
+ ParentCat = "Education";
+ SubCat = "Teaching";
+ }
+ if ( ExeKdeCat[exenum] == "Games/Arcade") {
+ ParentCat = "Games";
+ SubCat = "Arcade";
+ }
+ if ( ExeKdeCat[exenum] == "Games/Board") {
+ ParentCat = "Games";
+ SubCat = "Board";
+ }
+ if ( ExeKdeCat[exenum] == "Games/Card") {
+ ParentCat = "Games";
+ SubCat = "Card";
+ }
+ if ( ExeKdeCat[exenum] == "Games/Kidsgames") {
+ ParentCat = "Games";
+ SubCat = "Kidsgames";
+ }
+ if ( ExeKdeCat[exenum] == "Games/TacticStrategy") {
+ ParentCat = "Games";
+ SubCat = "TacticStrategy";
+ }
+ if ( ExeKdeCat[exenum] == "Games")
+ ParentCat = "Games";
+ if ( ExeKdeCat[exenum] == "Graphics")
+ ParentCat = "Graphics";
+ if ( ExeKdeCat[exenum] == "Internet")
+ ParentCat = "Internet";
+ if ( ExeKdeCat[exenum] == "Multimedia")
+ ParentCat = "Multimedia";
+ if ( ExeKdeCat[exenum] == "Office")
+ ParentCat = "Office";
+ if ( ExeKdeCat[exenum] == "System")
+ ParentCat = "System";
+ if ( ExeKdeCat[exenum] == "Toys") {
+ ParentCat = "Games";
+ SubCat = "Toys";
+ }
+ if ( ExeKdeCat[exenum] == "Utilities") {
+ ParentCat = "Utilities";
+ }
- // Create a directory in a KDE sub-menu
- if (ExeOwndir[exenum] == 1) {
- tmp = "/usr/local/share/desktop-directories/PBI-" + ProgDirName + ".directory";
- QFile desktopdirfile( tmp );
- if ( desktopdirfile.open( QIODevice::WriteOnly | QIODevice::Text) ) {
- QTextStream streamdd( &desktopdirfile );
- streamdd << "[Desktop Entry]\n";
- streamdd << "Comment=" << ProgDirName << "\n";
- streamdd << "GenericName=" << ProgramName << "\n";
- streamdd << "Icon=" << MainIcon << "\n";
- streamdd << "Name=" + ProgramName + "\n";
- desktopdirfile.close();
- }
+ QTextStream streamxdg( &xdgfile );
+ streamxdg << "<!DOCTYPE Menu PUBLIC \"-//freedesktop//DTD Menu 1.0//EN\" \"http://www.freedesktop.org/standards/menu-spec/1.0/menu.dtd\">\n";
+ streamxdg << "<Menu>\n";
+ streamxdg << " <Menu>\n";
+ streamxdg << " <Name>" << ParentCat << "</Name>\n";
+ if ( ! SubCat.isEmpty() )
+ {
+ streamxdg << " <Menu>\n";
+ streamxdg << " <Name>" << SubCat << "</Name>\n";
+ }
+ streamxdg << " <Menu>\n";
+ streamxdg << " <Name>" << ProgramName << "</Name>\n";
+ streamxdg << " <Directory>PBI-" << ProgDirName << ".directory</Directory>\n";
+ streamxdg << " <Include>\n";
+ streamxdg << " <Category>X-" << ProgDirName << "</Category>\n";
+ streamxdg << " </Include>\n";
+ streamxdg << " </Menu>\n";
+ if ( ! SubCat.isEmpty() )
+ {
+ streamxdg << " </Menu>\n";
+ }
+ streamxdg << " </Menu>\n";
+ streamxdg << "</Menu>\n";
- tmp = "/usr/local/etc/xdg/menus/applications-merged/PBI-" + ProgDirName + ".merge.menu";
- QFile xdgfile( tmp );
- if ( xdgfile.open( QIODevice::WriteOnly | QIODevice::Text) ) {
+ xdgfile.close();
- QString ParentCat, SubCat;
- if ( ExeKdeCat[exenum] == "Development")
- {
- ParentCat = "Development";
- }
- if ( ExeKdeCat[exenum] == "Editors")
- {
- ParentCat = "Editors";
- }
- if ( ExeKdeCat[exenum] == "Edutainment")
- {
- ParentCat = "Education";
- }
- if ( ExeKdeCat[exenum] == "Edutainment/Languages")
- {
- ParentCat = "Education";
- SubCat = "Languages";
- }
- if ( ExeKdeCat[exenum] == "Edutainment/Math")
- {
- ParentCat = "Education";
- SubCat = "Mathmatics";
- }
- if ( ExeKdeCat[exenum] == "Edutainment/Misc")
- {
- ParentCat = "Education";
- SubCat = "Misc";
- }
- if ( ExeKdeCat[exenum] == "Edutainment/Science")
- {
- ParentCat = "Education";
- SubCat = "Science";
- }
- if ( ExeKdeCat[exenum] == "Edutainment/Teaching")
- {
- ParentCat = "Education";
- SubCat = "Teaching";
- }
- if ( ExeKdeCat[exenum] == "Games/Arcade")
- {
- ParentCat = "Games";
- SubCat = "Arcade";
- }
- if ( ExeKdeCat[exenum] == "Games/Board")
- {
- ParentCat = "Games";
- SubCat = "Board";
- }
- if ( ExeKdeCat[exenum] == "Games/Card")
- {
- ParentCat = "Games";
- SubCat = "Card";
- }
- if ( ExeKdeCat[exenum] == "Games/Kidsgames")
- {
- ParentCat = "Games";
- SubCat = "Kidsgames";
- }
- if ( ExeKdeCat[exenum] == "Games/TacticStrategy")
- {
- ParentCat = "Games";
- SubCat = "TacticStrategy";
- }
- if ( ExeKdeCat[exenum] == "Games")
- {
- ParentCat = "Games";
- }
- if ( ExeKdeCat[exenum] == "Graphics")
- {
- ParentCat = "Graphics";
- }
- if ( ExeKdeCat[exenum] == "Internet")
- {
- ParentCat = "Internet";
- }
- if ( ExeKdeCat[exenum] == "Multimedia")
- {
- ParentCat = "Multimedia";
- }
- if ( ExeKdeCat[exenum] == "Office")
- {
- ParentCat = "Office";
- }
- if ( ExeKdeCat[exenum] == "System")
- {
- ParentCat = "System";
- }
- if ( ExeKdeCat[exenum] == "Toys")
- {
- ParentCat = "Games";
- SubCat = "Toys";
- }
- if ( ExeKdeCat[exenum] == "Utilities")
- {
- ParentCat = "Utilities";
- }
+ }
- QTextStream streamxdg( &xdgfile );
- streamxdg << "<!DOCTYPE Menu PUBLIC \"-//freedesktop//DTD Menu 1.0//EN\" \"http://www.freedesktop.org/standards/menu-spec/1.0/menu.dtd\">\n";
- streamxdg << "<Menu>\n";
- streamxdg << " <Menu>\n";
- streamxdg << " <Name>" << ParentCat << "</Name>\n";
- if ( ! SubCat.isEmpty() )
- {
- streamxdg << " <Menu>\n";
- streamxdg << " <Name>" << SubCat << "</Name>\n";
- }
- streamxdg << " <Menu>\n";
- streamxdg << " <Name>" << ProgramName << "</Name>\n";
- streamxdg << " <Directory>PBI-" << ProgDirName << ".directory</Directory>\n";
- streamxdg << " <Include>\n";
- streamxdg << " <Category>X-" << ProgDirName << "</Category>\n";
- streamxdg << " </Include>\n";
- streamxdg << " </Menu>\n";
- if ( ! SubCat.isEmpty() )
- {
- streamxdg << " </Menu>\n";
- }
- streamxdg << " </Menu>\n";
- streamxdg << "</Menu>\n";
+ // Add this category to our list
+ stream << "Categories=Qt;KDE;X-" + ProgDirName + ";\n";
+ } // End of check for placing within a subdir
- xdgfile.close();
+ } // End of creation for Icons in a subdir, both in top level and submenu
- xdgfile.close();
- }
- stream << "Categories=Qt;KDE;X-" + ProgDirName + ";\n";
- }
+ // Add entry to place in KDE default directories
+ /////////////////////////////////////////////////////////////////
+ if ( ExeOwndir[exenum] == 2 )
+ {
- // Add entry to place in KDE default directories
- if ( ExeOwndir[exenum] == 2 )
- {
- if ( ExeKdeCat[exenum] == "Development")
- {
- stream << "Categories=Qt;KDE;Development;\n";
- }
- if ( ExeKdeCat[exenum] == "Editors")
- {
- stream << "Categories=Qt;KDE;Editors;\n";
- }
- if ( ExeKdeCat[exenum] == "Edutainment")
- {
- stream << "Categories=Qt;KDE;Education;\n";
- }
- if ( ExeKdeCat[exenum] == "Edutainment/Languages")
- {
- stream << "Categories=Qt;KDE;Education;Languages;\n";
- }
- if ( ExeKdeCat[exenum] == "Edutainment/Math")
- {
- stream << "Categories=Qt;KDE;Education;Math;\n";
- }
- if ( ExeKdeCat[exenum] == "Edutainment/Misc")
- {
- stream << "Categories=Qt;KDE;Education;\n";
- }
- if ( ExeKdeCat[exenum] == "Edutainment/Science")
- {
- stream << "Categories=Qt;KDE;Education;Science;\n";
- }
- if ( ExeKdeCat[exenum] == "Edutainment/Teaching")
- {
- stream << "Categories=Qt;KDE;Education;Teaching;\n";
- }
- if ( ExeKdeCat[exenum] == "Games")
- {
- stream << "Categories=Qt;KDE;Game;\n";
- }
- if ( ExeKdeCat[exenum] == "Games/Arcade")
- {
- stream << "Categories=Qt;KDE;Game;ArcadeGame;\n";
- }
- if ( ExeKdeCat[exenum] == "Games/Board")
- {
- stream << "Categories=Qt;KDE;Game;BoardGame;\n";
- }
- if ( ExeKdeCat[exenum] == "Games/Card")
- {
- stream << "Categories=Qt;KDE;Game;CardGame;\n";
- }
- if ( ExeKdeCat[exenum] == "Games/Kidsgames")
- {
- stream << "Categories=Qt;KDE;Game;X-KDE-KidsGame;\n";
- }
- if ( ExeKdeCat[exenum] == "Games/TacticStrategy")
- {
- stream << "Categories=Qt;KDE;Game;StrategyGame;\n";
- }
- if ( ExeKdeCat[exenum] == "Graphics")
- {
- stream << "Categories=Qt;KDE;Graphics;\n";
- }
- if ( ExeKdeCat[exenum] == "Internet")
- {
- stream << "Categories=Qt;KDE;Network;\n";
- }
- if ( ExeKdeCat[exenum] == "Multimedia")
- {
- stream << "Categories=Qt;KDE;AudioVideo;Audio;Player;\n";
- }
- if ( ExeKdeCat[exenum] == "Office")
- {
- stream << "Categories=Qt;KDE;Office;\n";
- }
- if ( ExeKdeCat[exenum] == "System")
- {
- stream << "Categories=Qt;KDE;System;\n";
- }
- if ( ExeKdeCat[exenum] == "Toys")
- {
- stream << "Categories=Qt;KDE;Toys;\n";
- }
- if ( ExeKdeCat[exenum] == "Utilities")
- {
- stream << "Categories=Qt;KDE;Utility;\n";
- }
+ // Add this desktop file to our install script
+ IconScript << " " << "xdg-desktop-menu install " + MenuDir + "/PBI-" + ProgDirName + "-" + Binary + ".desktop";
+ IconUnScript << " " << "xdg-desktop-menu uninstall " + MenuDir + "/PBI-" + ProgDirName + "-" + Binary + ".desktop";
+
+ if ( ExeKdeCat[exenum] == "Development")
+ stream << "Categories=Qt;KDE;Development;\n";
+ if ( ExeKdeCat[exenum] == "Editors")
+ stream << "Categories=Qt;KDE;Editors;\n";
+ if ( ExeKdeCat[exenum] == "Edutainment")
+ stream << "Categories=Qt;KDE;Education;\n";
+ if ( ExeKdeCat[exenum] == "Edutainment/Languages")
+ stream << "Categories=Qt;KDE;Education;Languages;\n";
+ if ( ExeKdeCat[exenum] == "Edutainment/Math")
+ stream << "Categories=Qt;KDE;Education;Math;\n";
+ if ( ExeKdeCat[exenum] == "Edutainment/Misc")
+ stream << "Categories=Qt;KDE;Education;\n";
+ if ( ExeKdeCat[exenum] == "Edutainment/Science")
+ stream << "Categories=Qt;KDE;Education;Science;\n";
+ if ( ExeKdeCat[exenum] == "Edutainment/Teaching")
+ stream << "Categories=Qt;KDE;Education;Teaching;\n";
+ if ( ExeKdeCat[exenum] == "Games")
+ stream << "Categories=Qt;KDE;Game;\n";
+ if ( ExeKdeCat[exenum] == "Games/Arcade")
+ stream << "Categories=Qt;KDE;Game;ArcadeGame;\n";
+ if ( ExeKdeCat[exenum] == "Games/Board")
+ stream << "Categories=Qt;KDE;Game;BoardGame;\n";
+ if ( ExeKdeCat[exenum] == "Games/Card")
+ stream << "Categories=Qt;KDE;Game;CardGame;\n";
+ if ( ExeKdeCat[exenum] == "Games/Kidsgames")
+ stream << "Categories=Qt;KDE;Game;X-KDE-KidsGame;\n";
+ if ( ExeKdeCat[exenum] == "Games/TacticStrategy")
+ stream << "Categories=Qt;KDE;Game;StrategyGame;\n";
+ if ( ExeKdeCat[exenum] == "Graphics")
+ stream << "Categories=Qt;KDE;Graphics;\n";
+ if ( ExeKdeCat[exenum] == "Internet")
+ stream << "Categories=Qt;KDE;Network;\n";
+ if ( ExeKdeCat[exenum] == "Multimedia")
+ stream << "Categories=Qt;KDE;AudioVideo;Audio;Player;\n";
+ if ( ExeKdeCat[exenum] == "Network")
+ stream << "Categories=Qt;KDE;Network;\n";
+ if ( ExeKdeCat[exenum] == "Network/Email")
+ stream << "Categories=Qt;KDE;Network;Email;\n";
+ if ( ExeKdeCat[exenum] == "Network/FileTransfer")
+ stream << "Categories=Qt;KDE;Network;FileTransfer;\n";
+ if ( ExeKdeCat[exenum] == "Network/InstantMessaging")
+ stream << "Categories=Qt;KDE;Network;InstantMessaging;\n";
+ if ( ExeKdeCat[exenum] == "Network/News")
+ stream << "Categories=Qt;KDE;Network;News;\n";
+ if ( ExeKdeCat[exenum] == "Network/RemoteAccess")
+ stream << "Categories=Qt;KDE;Network;RemoteAccess;\n";
+ if ( ExeKdeCat[exenum] == "Network/WebBrowser")
+ stream << "Categories=Qt;KDE;Network;WebBrowser;\n";
+ if ( ExeKdeCat[exenum] == "Office")
+ stream << "Categories=Qt;KDE;Office;\n";
+ if ( ExeKdeCat[exenum] == "System")
+ stream << "Categories=Qt;KDE;System;\n";
+ if ( ExeKdeCat[exenum] == "Toys")
+ stream << "Categories=Qt;KDE;Toys;\n";
+ if ( ExeKdeCat[exenum] == "Utilities")
+ stream << "Categories=Qt;KDE;Utility;\n";
- }
-
-
- file.close();
-
}
+
+ file.close();
+ ///////////////////////////////////////////////////////////////
- if (NoDesktop[exenum] == "0" && ExeWebLink[exenum] != "1" )
+
+
+ // Make the desktop files now if we need them
+ ///////////////////////////////////////////////////////////////
+ if ( NoDesktop[exenum] == "0" && ExeWebLink[exenum] != "1" )
{
QFile file2( "/home/" + RealUserName + "/Desktop/" + Binary + ".desktop");
@@ -1060,12 +1103,14 @@
if ( ExeLink[exenum] == "0" && ExeWebLink[exenum] == "0") {
// Create desktop link
- QDir bindir;
- bindir.mkpath( "/Programs/bin");
- runCommand("ln -fs /Programs/" + ProgDirName + "/.sbin/" + Binary + " /Programs/bin/" + Binary+ " >/dev/null 2>/dev/null");
+ QDir bindir;
+ bindir.mkpath ( "/Programs/bin");
+ runCommand("ln -fs /Programs/" + ProgDirName + "/.sbin/" + Binary + " /Programs/bin/" + Binary+ " >/dev/null 2>/dev/null");
- if ( file2.open( QIODevice::WriteOnly) ) {
+
+ if ( file2.open( QIODevice::WriteOnly | QIODevice::Text) ) {
QTextStream stream2( &file2 );
+ stream2 << "#!/usr/bin/env xdg-open\n";
stream2 << "[Desktop Entry]\n";
stream2 << "Name=" + ExeDescr[exenum] + "\n";
//stream2 << "Exec=/Programs/" + ProgDirName + "/.sbin/" + Binary + "\n";
@@ -1103,7 +1148,7 @@
}
- if ( file2.open( QIODevice::WriteOnly) ) {
+ if ( file2.open( QIODevice::WriteOnly | QIODevice::Text) ) {
QTextStream stream2( &file2 );
stream2 << "[Desktop Entry]\n";
stream2 << "Exec=kfmclient exec '" << link << "'\n";
@@ -1120,51 +1165,19 @@
}
// change owner of file
- if ( RealUserName == "root" ) {
- runCommand("chown -R root:wheel /root/Desktop/" + Binary + ".desktop" );
- } else {
- runCommand("chown -R " + RealUserName + ":" + RealUserName + " /home/" + RealUserName + "/Desktop/" + Binary + ".desktop" );
- }
+ tmp = "chown -R" + RealUserName + ":" + RealUserName + " /home/" + RealUserName + "/Desktop/" + Binary + ".desktop";
+ system(tmp.toLatin1());
+ // Set the file to 744 to avoid KDE warnings
+ tmp = "chmod 744 /home/" + RealUserName + "/Desktop/" + Binary + ".desktop";
+ system(tmp.toLatin1());
+
}
-
- if ( ExeTaskbar[exenum] == "1" && ExeWebLink[exenum] != "1" )
- {
-
- QString ShellOption;
-
- if ( RunShell[exenum] == "1" )
- {
- ShellOption = "TRUE";
- } else {
- ShellOption = "FALSE";
- }
-
-
- QFile file3( "dcop.sh");
- if ( file3.open( QIODevice::WriteOnly) ) {
- QTextStream stream3( &file3 );
- stream3 << "#!/bin/sh\n";
- stream3 << "dcop --user " + RealUserName + " kicker Panel addNonKDEAppButton \"" + ExeDescr[exenum] + "\" \"" + ExeDescr[exenum] + "\" \"/Programs/" + ProgDirName + "/.sbin/" + Binary + "\" \"" + Icon + "\" \"\" " + ShellOption + "\n";
-
- }
-
- file3.close();
-
- // Now run the dcop command
- runCommand("sh dcop.sh");
- }
-
-
-
-
-
}
-
// Checks for any custom install script that must be run
void CheckScriptSlot(void)
{
@@ -1195,164 +1208,38 @@
}
+
void slotSetupCustomRemoveScript()
{
- QString cmd;
-
// Setup our custom removal script
if ( QFile::exists( "/Programs/" + ProgDirName + "/PBI.RemoveScript.sh" ) )
{
-
- cmd = "mv /Programs/" + ProgDirName + "/PBI.RemoveScript.sh /Programs/" + ProgDirName + "/PBI.RemoveScript2.sh";
- system(cmd.toLatin1());
+ system("mv /Programs/" + ProgDirName.toLatin1() + "/PBI.RemoveScript.sh /Programs/" + ProgDirName.toLatin1() + "/PBI.RemoveScript2.sh");
}
-
+
QFile file( "/Programs/" + ProgDirName + "/PBI.RemoveScript.sh" );
if ( file.open( QIODevice::WriteOnly ) ) {
QTextStream stream( &file );
stream << "#!/bin/sh\n";
+ stream << "\nsh /Programs/" + ProgDirName + "/.sbin/uninstall-xdg-icons.sh >/dev/null 2>/dev/null\n";
- // Check if we need to put any Mime removal code into the uninstall script
- if ( createdMimeFiles == 1 )
- {
- int i = 0;
- while ( ! MimeExt[i].isEmpty() )
- {
- stream << "# Check if we have a different pcbsdbase conf\n";
- stream << "if [ -e \"/PCBSD/conf/pcbsdbase\" ]\n";
- stream << "then\n";
- stream << " BASE=`cat /PCBSD/conf/pcbsdbase`\n";
- stream << "else\n";
- stream << " BASE=/usr/local\n";
- stream << "fi\n";
+ // Run the provided removal script now
+ stream << "\nif [ -e '/Programs/" + ProgDirName + "/PBI.RemoveScript2.sh' ]\n";
+ stream << "then\n";
+ stream << " sh /Programs/" + ProgDirName + "/PBI.RemoveScript2.sh \"${@}\"\n";
+ stream << "fi\n";
+ stream << "\n";
+ stream << "rm -rf '/Programs/" + ProgDirName + "'\n";
- // Remove the xml files from the mime package database
- stream << "rm -f \"${BASE}/share/mime/packages/" << ProgramName << i << "-\"*\n";
- // Remove the hidden applnk files
- stream << "rm -f \"${BASE}/share/applnk/.hidden/" << ProgramName << i << "-\"*\n";
-
- // Remove any mentions of this entry from mimeapps.list
- stream << "cat ${BASE}/share/applications/mimeapps.list | grep -v '=" << ProgramName << i << "-' >/tmp/.mimeapps.list\n";
- stream << "mv /tmp/.mimeapps.list ${BASE}/share/applications/mimeapps.list\n";
-
- i++;
- }
-
- // Remove any created mimetypes/<icons>
- stream << "for i in `cat /Programs/" + ProgDirName + "/.iconmime`\n";
- stream << "do\n";
- stream << "if [ -h \"${BASE}/kde4/share/icons/oxygen/16x16/mimetypes/${i}\" ]\n";
- stream << "then\n";
- stream << " rm ${BASE}/kde4/share/icons/oxygen/16x16/mimetypes/${i}\n";
-
- stream << "fi\n";
- stream << "if [ -h \"${BASE}/kde4/share/icons/oxygen/48x48/mimetypes/${i}\" ]\n";
- stream << "then\n";
- stream << " rm ${BASE}/kde4/share/icons/oxygen/48x48/mimetypes/${i}\n";
-
- stream << "fi\n";
- stream << "if [ -h \"${BASE}/kde4/share/icons/oxygen/64x64/mimetypes/${i}\" ]\n";
- stream << "then\n";
- stream << " rm ${BASE}/kde4/share/icons/oxygen/64x64/mimetypes/${i}\n";
-
- stream << "fi\n";
- stream << "if [ -h \"${BASE}/kde4/share/icons/oxygen/128x128/mimetypes/${i}\" ]\n";
- stream << "then\n";
- stream << " rm ${BASE}/kde4/share/icons/oxygen/128x128/mimetypes/${i}\n";
-
- stream << "fi\n";
- stream << "done\n";
-
- // Recreate the mime database
- stream << "update-mime-database ${BASE}/share/mime\n";
- }
-
- stream << "\nif [ -e '/Programs/" + ProgDirName + "/PBI.RemoveScript2.sh' ]\n";
- stream << "then\n";
- stream << " sh /Programs/" + ProgDirName + "/PBI.RemoveScript2.sh \"${@}\"\n";
- stream << "fi\n";
- stream << "rm /usr/local/share/applications/kde/PBI-" + ProgramName+ "-* >/dev/null 2>/dev/null\n";
- stream << "rm /usr/local/share/desktop-directories/PBI-" + ProgDirName + ".directory >/dev/null 2>/dev/null\n";
- stream << "rm /usr/local/etc/xdg/menus/applications-merged/PBI-" + ProgDirName + ".merge.menu >/dev/null 2>/dev/null\n";
-
-
file.close();
- }
+ }
+ system("chmod 755 /Programs/" + ProgDirName.toLatin1() + "/PBI.RemoveScript.sh" );
- cmd = "chmod 755 /Programs/" + ProgDirName + "/PBI.RemoveScript.sh";
- system(cmd.toLatin1());
-
}
-
-void CreateMimeSlot( int MimeNum )
-{
-
- if ( MimeExt[MimeNum].isEmpty() )
- {
- // All finished with Mime Files, lets move on to checking for custom scripts now
- CheckScriptSlot();
- return;
- }
-
- QString MimeNumString;
- MimeNumString.setNum(MimeNum);
-
- // Get the binary name
- QString Binary;
- if ( ExePath[MimeProg[MimeNum]].lastIndexOf("/" ) != -1 )
- {
- Binary = ExePath[MimeProg[MimeNum]].remove(0, ExePath[MimeProg[MimeNum]].lastIndexOf("/") );
- } else {
- Binary = ExePath[MimeProg[MimeNum]];
- }
-
-
- // Get the right icon
- QString Icon;
- QString MainIcon;
-
- MainIcon = "/Programs/" + ProgDirName + "/" + DefaultIcon;
-
- if ( MimeIcon[MimeProg[MimeNum]].isEmpty() && DefaultIcon.isEmpty() )
- {
- Icon = "/Programs/.config/application.png";
- }else if (MimeIcon[MimeNum].isEmpty() ) {
- Icon = "/Programs/" + ProgDirName + "/" + DefaultIcon;
- } else {
- Icon = "/Programs/" + ProgDirName + "/" + MimeIcon[MimeProg[MimeNum]];
- }
-
- // Setup our variables we will use for the argument list
- QString MimeName = ProgramName + MimeNumString;
- QString ProgEXE = "/Programs/" + ProgDirName + "/.sbin/" + Binary;
- QString Terminal = "0";
- if ( RunShell[MimeProg[MimeNum]] == "1" )
- {
- Terminal = "1";
- }
- QString Location;
- if ( RealUserName == "root" )
- {
- Location="/root/.PBItmp";
- } else {
- Location = "/home/" + RealUserName + "/.PBItmp";
- }
-
- // Create the mime entry by calling addpbimime.sh
- QString command="./addpbimime.sh '" + MimeName + "' '" +MimeExt[MimeNum] + "' '" + ProgEXE + "' '" + Icon + "' '" + Terminal + "' '" + ProgDirName + "'" ;
- system(command.toLatin1());
-
- // Create the next Mime entry now
- MimeNum++;
- CreateMimeSlot(MimeNum);
-
-}
-
-
void runCommand( QString Command )
{
FILE *file = popen(Command.toLatin1(),"r");
More information about the Commits
mailing list