Changeset 93032ef


Ignore:
Timestamp:
Dec 6, 2013 8:33:39 AM (4 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, releng/10.0, releng/10.0.1
Children:
0ebf4c2
Parents:
ca9d4b3
Message:

Add the beginnings of the XDG and MIME support for the new EasyPBI module class.

Location:
src-qt4/EasyPBI
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/EasyPBI/PBIModule.cpp

    rca9d4b3 r93032ef  
    1313  //Valid Scripts 
    1414  scriptValues << "pre-pbicreate.sh" << "pre-install.sh" << "post-install.sh" << "pre-remove.sh"; 
     15  //valid XDG values 
     16  xdgValues << 
     17  //valid MIME values 
     18  mimeValues <<  
    1519         
    1620  HASH.clear(); //Make sure the hash is currently empty 
     
    109113void PBIModule::loadConfig(){ 
    110114//Read the designated pbi.conf and store the variables 
    111   QFile file(basePath+"/pbi.conf"); 
    112   if( !file.open(QIODevice::ReadOnly | QIODevice::Text)){ 
    113     qDebug() << "Warning: Unable to load "+basePath+"/pbi.conf"; 
    114     return; 
    115   } 
    116   QTextStream in(&file); 
    117   while(!in.atEnd()){ 
     115  QStringList contents = readFile(basePath+"/pbi.conf"); 
     116  for(int i=0; i<contents.length(); i++){ 
    118117    //see if the current line conains a desired variable and save it 
    119     QString line = in.readLine(); 
     118    QString line = contents[i]; 
    120119    if(!line.startsWith("#") && !line.startsWith("export")){ //Ignore commented out lines 
    121120      //Pull apart the variable and the value 
    122121      QString var = line.section("=\"",0,0,QString::SectionSkipEmpty).trimmed(); 
    123122      QString val = line.section("=\"",1,50).section("#",0,0,QString::SectionSkipEmpty).section(";",0,0,QString::SectionSkipEmpty).trimmed(); 
    124         while( !val.endsWith("\"") && !in.atEnd() ){ 
    125           line = in.readLine(); 
     123        while( !val.endsWith("\"") && i<contents.length() ){ 
     124          i++; 
     125          line = contents[i]; 
    126126          val.append("\n"+line.section("#",0,0).section(";",0,0).trimmed(); 
    127127        } 
     
    134134    } 
    135135  } 
    136   file.close();  
    137136} 
    138137 
     
    356355  return out;    
    357356} 
     357 
     358QStringList PBIModule::generateXDGFileContents(QString name, QString gName, QString exec, \ 
     359                QString iconResourcePath, QString mimetype, bool runAsRoot, bool invisible, \ 
     360                bool useTerminal){ 
     361  QStringList contents; 
     362  contents << "#!/usr/bin/env"; 
     363  contents << "[Desktop Entry]"; 
     364  contents << "Value=1.0"; 
     365  contents << "Type=Application"; 
     366  contents << "Name="+name; 
     367  contents << "GenericName="+gName; 
     368  if(runAsRoot){ 
     369    contents << "Exec=pc-su %%PBI_EXEDIR%%/"+exec; 
     370  }else{ 
     371    contents << "Exec=%%PBI_EXEDIR%%/"+exec; 
     372  } 
     373  contents << "Path=%%PBI_APPDIR%%"; 
     374  contents << "Icon=%%PBI_APPDIR%%/"+iconResourcePath; 
     375  contents << "StartupNotify=true"; 
     376  if(invisible){ 
     377    contents << "NoDisplay=true"; 
     378  } 
     379  if(useTerminal){ 
     380    contents << "Terminal=true"; 
     381  } 
     382  if(!mimetype.isEmpty()){ 
     383    contents << "MimeType="+mimetype; 
     384  } 
     385  return contents; 
     386} 
  • src-qt4/EasyPBI/PBIModule.h

    rca9d4b3 r93032ef  
    4747         
    4848        //XDG files 
     49        QStringList validXdgText(); 
     50        QString xdgText(QString); 
     51        QStringList xdgTextL(QStringList); 
     52        void setXdgText(QString,QString); 
     53        void setXdgTextL(QStringList, QStringList); 
     54         
     55        QStringList validXdgEnables(); 
     56        void xdgEnabled(QString); 
     57        void setXdgEnabled(QString, bool); 
     58         
     59        QStringList listXdgDesktopFiles(); 
     60        QStringList listXdgMenuFiles(); 
     61        bool saveXdgDesktop(QString fileName); 
     62        bool saveXdgMenu(QString fileName); 
     63        bool removeXdgDesktop(QString fileName); 
     64        bool removeXdgMenu(QString fileName); 
     65        bool loadXdgDesktop(QString fileName); 
     66        bool loadXdgMenu(QString filename); 
     67         
     68        QStringList listMimeFiles(); 
     69        QStringList validMimeValues(); 
     70        QString mimeText(QString); 
     71        QStringList mimeTextL(QStringList); 
     72        void setMimeText(QString, QString); 
     73        void setMimeTextL(QStringList, QStringList); 
    4974         
    5075        //External Links 
    5176 
    5277        //General Utilities 
    53         bool createFile(QString,QStringList); 
    54         QStringList readFile(QString); 
     78        static bool createFile(QString,QStringList); 
     79        static QStringList readFile(QString); 
     80        static QStringList filesInDir(QString); 
     81        static QStringList generateXDGFileContents(QString,QString,QString,QString,QString, bool, bool, bool); 
    5582 
    5683private: 
    5784        QHash<QString, QVariant> HASH; 
    58         QStringList CTextValues, CBoolValues, CIntValues, scriptValues; 
     85        QStringList CTextValues, CBoolValues, CIntValues, scriptValues, xdgValues, mimeValues; 
    5986        QString basePath, version; 
    6087 
Note: See TracChangeset for help on using the changeset viewer.