Skip to content
Browse files

Add the first backend functions for EasyPBI to pull information from …

…the pkgng repo instead of requiring a local copy of the FreeBSD ports tree. Just missing the ability to read the pkg-plist within a package now.
  • Loading branch information...
1 parent f15ae5d commit 7a4b57bbccafcd244a64c871d49e060083c1869d @beanpole135 beanpole135 committed
Showing with 46 additions and 6 deletions.
  1. +39 −0 src-qt4/EasyPBI/backend.cpp
  2. +7 −6 src-qt4/EasyPBI/backend.h
View
39 src-qt4/EasyPBI/backend.cpp
@@ -33,3 +33,42 @@ QIcon Backend::icon(QString icon){
return QIcon(iconPath);
}
+
+QStringList Backend::getCmdOutput(QString cmd){
+ QProcess *proc = new QProcess;
+ proc->setProcessChannelMode(QProcess::MergedChannels);
+ proc->start(cmd);
+ while(!proc->waitForFinished(300)){
+ QCoreApplication::processEvents();
+ }
+ QStringList out = QString(proc->readAllStandardOutput()).split("\n");
+ delete proc;
+ return out;
+}
+
+// ====================
+// PACKAGE DATABASE TOOLS
+// ====================
+QStringList Backend::getPkgList(){
+ //Generate an alphabetized list of all available packages on the repo
+ //format: <category>/<pkgname>
+ QString cmd = "pkg search -o \"/\"";
+ QStringList result = getCmdOutput(cmd);
+ return result;
+}
+
+QStringList Backend::getPkgInfo(QString pkgname){
+ //Function to query the package repository and pull down information about a particular package
+ //Output: <name>, <port>, <maintainer>, <website>
+ QString cmd = "pkg rquery \"%n\\n%o\\n%m\\n%w\" "+pkgname;
+ QStringList out = Backend::getCmdOutput(cmd);
+ return out;
+}
+
+QStringList Backend::getPkgOpts(QString pkgname){
+ //Function to query the package repository and pull down information about a particular package
+ //Output: <name>, <port>, <maintainer>, <website>
+ QString cmd = "pkg rquery \"%Ok=%Ov\" "+pkgname;
+ QStringList out = Backend::getCmdOutput(cmd);
+ return out;
+}
View
13 src-qt4/EasyPBI/backend.h
@@ -4,17 +4,18 @@
#include <QString>
#include <QDebug>
#include <QIcon>
+#include <QProcess>
+#include <QCoreApplication>
class Backend{
-
-private:
-
-
public:
static QIcon icon(QString);
-
-
+ static QStringList getCmdOutput(QString cmd); //Run a command and return the output
+ //Package database query functions
+ static QStringList getPkgList(); //output format: <category>/<pkgname>
+ static QStringList getPkgInfo(QString pkgname); //output format: [<name>, <port>, <maintainer>, <website>]
+ static QStringList getPkgOpts(QString pkgname); //output format: <option>=<off/on>
};
#endif

0 comments on commit 7a4b57b

Please sign in to comment.
Something went wrong with that request. Please try again.