[PC-BSD Commits] r2224 - pbibuild/pbi-source/PBIsource
svn at pcbsd.org
svn at pcbsd.org
Tue Jul 1 10:28:04 PDT 2008
Author: kris
Date: 2008-07-01 10:28:03 -0700 (Tue, 01 Jul 2008)
New Revision: 2224
Modified:
pbibuild/pbi-source/PBIsource/pbi.cpp
pbibuild/pbi-source/PBIsource/pbi.h
Log:
Updated the PBI installer to support the new MIME format KDE4 uses with
a XML trigger file
Modified: pbibuild/pbi-source/PBIsource/pbi.cpp
===================================================================
--- pbibuild/pbi-source/PBIsource/pbi.cpp 2008-07-01 17:09:37 UTC (rev 2223)
+++ pbibuild/pbi-source/PBIsource/pbi.cpp 2008-07-01 17:28:03 UTC (rev 2224)
@@ -35,9 +35,13 @@
// Lets the app know if the file-extraction has begun
ExtractStarted = 0;
- // Tell the app we are in GUI mode
- CLImode = 0;
+ // Tell the app we are in GUI mode
+ CLImode = 0;
+ // Set our flag that we have not created any Mime files yet
+ createdMimeFiles = 0;
+
+
gridLayout->setMargin(0);
gridLayout->setSpacing(0);
gridLayout2->setMargin(0);
@@ -629,6 +633,7 @@
while ( ! MimeExt[i].isEmpty() )
{
CreateMimeSlot(i);
+ createdMimeFiles=1;
i++;
}
@@ -1070,8 +1075,19 @@
void PBI::FinishedInstallSlot()
{
+
+ // Install is finished! Check if we need to recreate the mime database before we exit
+ if ( createdMimeFiles == 1)
+ {
+ // Chmod the new file
+ Chmod2 = new QProcess(this);
+ QString program2 = "update-mime-database";
+ QStringList arguments2;
+ arguments2 << "/usr/local/share/mime";
+ Chmod2->start(program2, arguments2);
+ }
- if ( CLImode == 0)
+ if ( CLImode == 0)
{
installProgress->setProgress(installProgress->totalSteps());
StatusLabel->setText(tr("Installation Finished!"));
@@ -1208,9 +1224,11 @@
Icon = "/Programs/" + ProgDirName + "/" + MimeIcon[MimeProg[MimeNum]];
}
- QFile file( "/usr/local/share/mimelnk/application/" + ProgramName + MimeNumString + ".desktop");
+ QFile file( "/usr/local/share/mime/packages/" + ProgramName + MimeNumString + ".xml");
if ( file.open( IO_WriteOnly) ) {
QTextStream stream( &file );
+
+ /*
stream << "[Desktop Entry]\n";
stream << "Comment=" + ProgramName + " File\n";
stream << "Hidden=false\n";
@@ -1218,6 +1236,18 @@
stream << "MimeType=application/" << ProgramName << MimeNum << "\n";
stream << "Patterns=" + MimeExt[MimeNum] + "\n";
stream << "Type=MimeType\n";
+ */
+
+ // Use the new mime .xml format, be sure to run update-mime-database afterwards
+ stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+ stream << "<mime-info xmlns=\"http://www.freedesktop.org/standards/shared-mime-info\">\n";
+ stream << " <mime-type type=\"application/" << ProgramName << MimeNum << "\">\n";
+ stream << " <comment xml:lang=\"en\">" << ProgramName << " File </comment>\n";
+ stream << " <glob pattern=\"" << MimeExt[MimeNum] << "\"/>\n";
+ stream << " <desktop>" << ProgramName << MimeNumString << ".desktop</desktop>\n";
+ stream << " </mime-type>\n";
+ stream << "</mime-info>\n";
+
file.close();
}
@@ -2227,9 +2257,31 @@
stream << "then\n";
stream << " sh /Programs/" + ProgDirName + "/PBI.RemoveScript2.sh \"${@}\"\n";
stream << "fi\n";
- stream << "rm -rf '" + InstallDirPath + "'";
+ stream << "rm -rf '" + InstallDirPath + "'\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() )
+ {
+ // Remove the xml file from the mime package database
+ stream << "rm -f '/usr/local/share/mime/packages/" << ProgramName << i << ".xml'\n";
+
+ // Remove the hidden applnk file
+ stream << "rm -f '/usr/local/share/applnk/.hidden/" << ProgramName << i << ".desktop'\n";
+
+ i++;
+ }
+
+ // Recreate the mime database
+ stream << "update-mime-database /usr/local/share/mime";
+
+ }
+
file.close();
}
+
system("chmod 755 /Programs/" + ProgDirName + "/PBI.RemoveScript.sh" );
FinishedInstallSlot();
Modified: pbibuild/pbi-source/PBIsource/pbi.h
===================================================================
--- pbibuild/pbi-source/PBIsource/pbi.h 2008-07-01 17:09:37 UTC (rev 2223)
+++ pbibuild/pbi-source/PBIsource/pbi.h 2008-07-01 17:28:03 UTC (rev 2224)
@@ -121,6 +121,7 @@
QString InstallDirPath;
int ChecksumFinished;
int ChecksumPassed;
+ int createdMimeFiles;
signals:
More information about the Commits
mailing list