[PC-BSD Commits] r2236 - pbibuild/pbi-source/PBIsource
svn at pcbsd.org
svn at pcbsd.org
Wed Jul 2 08:42:31 PDT 2008
Author: kris
Date: 2008-07-02 08:42:13 -0700 (Wed, 02 Jul 2008)
New Revision: 2236
Modified:
pbibuild/pbi-source/PBIsource/PBI.pro
pbibuild/pbi-source/PBIsource/pbi.cpp
pbibuild/pbi-source/PBIsource/pbi.h
Log:
Updated the PBI installer to use the new addpbimime.sh script during install
Modified: pbibuild/pbi-source/PBIsource/PBI.pro
===================================================================
--- pbibuild/pbi-source/PBIsource/PBI.pro 2008-07-02 14:07:43 UTC (rev 2235)
+++ pbibuild/pbi-source/PBIsource/PBI.pro 2008-07-02 15:42:13 UTC (rev 2236)
@@ -3,7 +3,7 @@
CONFIG += qt warn_on release
-LIBS += -lkdecore -lkio -lkdeui -Ikdelibs
+LIBS += -L/usr/local/kde4/lib -lkdecore -lkio -lkdeui -Ikdelibs
HEADERS += pbi.h
Modified: pbibuild/pbi-source/PBIsource/pbi.cpp
===================================================================
--- pbibuild/pbi-source/PBIsource/pbi.cpp 2008-07-02 14:07:43 UTC (rev 2235)
+++ pbibuild/pbi-source/PBIsource/pbi.cpp 2008-07-02 15:42:13 UTC (rev 2236)
@@ -629,18 +629,15 @@
// Check if we need to create any mime icons
- i = 0;
- while ( ! MimeExt[i].isEmpty() )
+ if ( ! MimeExt[0].isEmpty() )
{
- CreateMimeSlot(i);
+ workingMime = 0;
createdMimeFiles=1;
- i++;
+ CreateMimeSlot(0);
+ } else {
+ // Check if there is a custom script to be run
+ CheckScriptSlot();
}
-
-
-
- // Check if there is a custom script to be run
- CheckScriptSlot();
@@ -1195,7 +1192,15 @@
void PBI::CreateMimeSlot( int MimeNum )
{
+ if ( MimeExt[MimeNum].isEmpty() )
+ {
+ // All finished with Mime Files, lets move on to checking for custom scripts now
+ CheckScriptSlot();
+ return;
+ }
+ StatusLabel->setText(tr("Registering file associations..."));
+
QString MimeNumString;
MimeNumString.setNum(MimeNum);
@@ -1204,12 +1209,12 @@
if ( ExePath[MimeProg[MimeNum]].lastIndexOf("/" ) != -1 )
{
Binary = ExePath[MimeProg[MimeNum]].remove(0, ExePath[MimeProg[MimeNum]].lastIndexOf("/") );
- } else {
- Binary = ExePath[MimeProg[MimeNum]];
- }
+ } else {
+ Binary = ExePath[MimeProg[MimeNum]];
+ }
- // Get the right icon
+ // Set the right icon for this mime entry
QString Icon;
QString MainIcon;
@@ -1223,71 +1228,40 @@
} else {
Icon = "/Programs/" + ProgDirName + "/" + MimeIcon[MimeProg[MimeNum]];
}
-
- 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";
- stream << "Icon=" + Icon + "\n";
- 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();
- }
-
- QFile file2( "/usr/local/share/applnk/.hidden/" + ProgramName + MimeNumString + ".desktop");
- if ( file2.open( IO_WriteOnly) ) {
- QTextStream stream2( &file2 );
- stream2 << "[Desktop Entry]\n";
- stream2 << "Exec=/Programs/" + ProgDirName + "/.sbin/" +Binary + "\n";
- stream2 << "Icon=" + Icon + "\n";
- stream2 << "InitialPreference=1\n";
- stream2 << "MimeType=application/" << ProgramName << MimeNum << "\n";
- stream2 << "Name=" + Binary + "\n";
- if ( RunShell[MimeProg[MimeNum]] == "1" )
- {
- stream2 << "Terminal=true\n";
- }
-
- stream2 << "Type=Application\n";
-
- file2.close();
- }
-
- // Chmod the new file
- Chmod2 = new QProcess(this);
- QString program2 = "chmod";
- QStringList arguments2;
- arguments2 << "755" << "/usr/local/share/applnk/.hidden/" + ProgramName + MimeNumString + ".desktop";
-
- Chmod2->start(program2, arguments2);
-
+ // 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";
+ }
- // Chmod the new file
- Chmod = new QProcess(this);
- QString program = "chmod";
+ // Create the mime entry by calling addpbimime.sh
+ MimeProc = new QProcess(this);
+ QString program = "bash";
QStringList arguments;
- arguments << "755" << "/usr/local/share/applnk/applications/" + ProgramName + MimeNumString + ".desktop";
+ arguments << Location + "/addpbimime.sh" << MimeName << MimeExt[MimeNum] << ProgEXE << Icon << Terminal ;
+ connect( MimeProc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotMimeProcFinished(int, QProcess::ExitStatus) ) );
+ MimeProc->start(program, arguments);
+ //QMessageBox::information( this, ProgramName, arguments.join(",") );
- Chmod->start(program, arguments);
+}
+// Slot to grab the exit status of a mime creation, and kick off the next one
+void PBI::slotMimeProcFinished(int exitCode, QProcess::ExitStatus exitStatus)
+{
+ workingMime++;
+ CreateMimeSlot(workingMime);
}
@@ -2265,12 +2239,16 @@
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 xml files from the mime package database
+ stream << "rm -f '/usr/local/share/mime/packages/" << ProgramName << i << "-'*\n";
- // Remove the hidden applnk file
- stream << "rm -f '/usr/local/share/applnk/.hidden/" << ProgramName << i << ".desktop'\n";
+ // Remove the hidden applnk files
+ stream << "rm -f '/usr/local/share/applnk/.hidden/" << ProgramName << i << "-'*\n";
+ // Remove any mentions of this entry from mimeapps.list
+ stream << "cat /usr/local/share/applications/mimeapps.list | grep -v '=" << ProgramName << i << "-' >/tmp/.mimeapps.list\n";
+ stream << "mv /tmp/.mimeapps.list /usr/local/share/applications/mimeapps.list\n";
+
i++;
}
Modified: pbibuild/pbi-source/PBIsource/pbi.h
===================================================================
--- pbibuild/pbi-source/PBIsource/pbi.h 2008-07-02 14:07:43 UTC (rev 2235)
+++ pbibuild/pbi-source/PBIsource/pbi.h 2008-07-02 15:42:13 UTC (rev 2236)
@@ -62,6 +62,7 @@
void slotRecheckChecksumFinished();
void slotSetupScriptFinished(int exitCode, QProcess::ExitStatus exitStatus);
void slotUnTarFinished(int exitCode, QProcess::ExitStatus exitStatus);
+ void slotMimeProcFinished(int exitCode, QProcess::ExitStatus exitStatus);
void slotExtractProcFinished(int exitCode, QProcess::ExitStatus exitStatus);
void slotChecksumProcFinished(int exitCode, QProcess::ExitStatus exitStatus);
void readFirstRunOutput(int exitCode, QProcess::ExitStatus exitStatus);
@@ -81,6 +82,7 @@
QProcess *CopyLibs;
QProcess *Chmod;
QProcess *Chmod2;
+ QProcess *MimeProc;
QProcess *Link;
QProcess *chown;
QProcess *CheckRoot;
@@ -122,6 +124,7 @@
int ChecksumFinished;
int ChecksumPassed;
int createdMimeFiles;
+ int workingMime;
signals:
More information about the Commits
mailing list