source: src-qt4/pc-softwaremanager/pbiBackend.h @ 32be23f

releng/10.0.1releng/10.0.2releng/10.0.3
Last change on this file since 32be23f was 32be23f, checked in by Ken Moore <ken@…>, 7 months ago

Clean up the AppCafe? browser home page - now just have a toolbutton to browser categories, and instead put recommended applications on the home page (new defaultrecommendations.txt resource). These recommendations can be automatically updated later if we add that ability for the repo to include an additional file with this information.

  • Property mode set to 100644
File size: 6.1 KB
Line 
1#ifndef _APPCAFE_PBI_BACKEND_H
2#define _APPCAFE_PBI_BACKEND_H
3
4/*  TERMINOLOGY NOTE:
5        "PBI" refers to locally installed applications
6        "APP" refers to available applications in the repo database
7        "CAT" refers to available categories in the repo database
8*/
9#include <QFileSystemWatcher>
10#include <QString>
11#include <QStringList>
12#include <QHash>
13#include <QTimer>
14#include <QFile>
15#include <QDir>
16#include <QDebug>
17#include <QDate>
18#include <QMessageBox>
19
20#include "containers.h"
21#include "extras.h"
22#include "pbiDBAccess.h"
23#include "processManager.h"
24#include "configDialog.h"
25
26class PBIBackend : public QObject{
27        Q_OBJECT
28
29public:
30        //Initializations
31        PBIBackend(QWidget *parent = 0);
32        ~PBIBackend(){}
33        // Clean Start/Stop functions
34        void setWardenMode(QString dir, QString ip);
35        bool start();
36        int numInstalled, numAvailable;
37        //Search variables for public slot inputs
38        QString searchTerm;
39        QString searchSimilar;
40        // Main Listing functions
41        QStringList installedList(); //return unique ID's of all installed PBI's
42        QStringList browserCategories(); //return list of available browser categories
43        QStringList browserApps( QString catID ); //list all apps in the given category
44        QStringList getRecentApps(); //list all recent applications/update
45        QStringList getRecommendations(); //list all PC-BSD recommended applications
46        bool safeToQuit(); //return FALSE if there are process running/waiting
47        // Local/Repo Interaction
48        QString isInstalled(QString appID); //returns pbiID that is installed (if possible);
49        QString upgradeAvailable(QString pbiID); //returns appID for PBI upgrade (if available)
50        // PBI Actions
51        void cancelActions(QStringList pbiID); //cancel any pending/current operations
52        void upgradePBI(QStringList pbiID); //start upgrade process for list of PBI's
53        void removePBI(QStringList pbiID); //start the removal process
54        void installApp(QStringList appID); //[install/upgrade/downgrade] application from the repo (as appropriate)
55        void installPBIFromFile(QStringList files); //[install/upgrade/downgrade] application from file
56        void addDesktopIcons(QStringList pbiID, bool allusers); // add XDG desktop icons
57        void addMenuIcons(QStringList pbiID, bool allusers); // add XDG menu icons
58        void addPaths(QStringList pbiID, bool allusers); // create path links
59        void addMimeTypes(QStringList pbiID, bool allusers); //add XDG Mime type associations
60        void rmDesktopIcons(QStringList pbiID, bool allusers); // remove XDG desktop icons
61        void rmMenuIcons(QStringList pbiID, bool allusers); // remove XDG menu icons
62        void rmPaths(QStringList pbiID, bool allusers); // remove path links
63        void rmMimeTypes(QStringList pbiID, bool allusers); //remove XDG Mime type associations
64        void enableAutoUpdate(QString pbiID, bool enable); //enable/disable auto-updating
65       
66        // Information Retrieval
67        QStringList PBIInfo( QString pbiID, QStringList infoList);
68        QStringList CatInfo( QString catID, QStringList infoList);
69        QStringList AppInfo( QString appID, QStringList infoList);
70        QString currentAppStatus( QString appID , bool rawstatus = false);
71        bool isWorking(QString pbiID);
72        QStringList pbiBinList(QString pbiID);
73        QString pbiToAppID(QString pbiID);
74       
75        //Configuration Management
76        void openConfigurationDialog();
77       
78        //Import/Export PBI lists
79        bool exportPbiListToFile(QString filepath);
80        bool importPbiListFromFile(QString filepath);
81       
82public slots:
83        void startAppSearch(); //get list of apps containing the search string (SIGNAL OUTPUT ONLY)
84        void startSimilarSearch(); //get list of apps that are similar to the input app
85       
86private:
87        QWidget *parentWidget;
88        QTimer *watchTimer;
89        //variables - warden mode
90        QString wardenDir, wardenIP;
91        bool wardenMode;
92        //variables - filesystem watcher;
93        QFileSystemWatcher *watcher;
94        QString baseDBDir; //  This is always /var/db/pbi/
95        QString DBDir;
96        //variables - database
97        PBIDBAccess *sysDB;
98        QHash<QString, InstalledPBI> PBIHASH;
99        QHash<QString, MetaCategory> CATHASH;
100        QHash<QString, MetaPBI> APPHASH;
101        bool noRepo;
102        //variables - processes
103        ProcessManager *PMAN;
104        QString cDownload, cInstall, cRemove, cUpdate, cDownloadFile, cOther; //currently running command/pbi
105        bool sDownload, sInstall, sRemove, sUpdate; //flag that these processes were Stopped
106        QStringList PENDINGDL, PENDINGINSTALL, PENDINGREMOVAL, PENDINGUPDATE, PENDINGOTHER;
107        QString lDownload, lInstall, lRemove, lUpdate; //latest string output from process
108        //variables - other
109        QString baseDlDir, dlDir; // download/install directories
110        QString sysArch; //system architecture
111        //Configuration Management
112        bool keepDownloads;
113        QStringList autoXDG;
114        QString settingsFile, currentRepoNum; //currentRepoNum only used during initial load
115        bool saveSettings();
116        bool loadSettings();
117
118        //functions
119        QString addRootCMD(QString cmd, bool needRoot);
120        QString generateUpdateCMD(QString pbiID);
121        QString generateRemoveCMD(QString pbiID);
122        QString generateAutoUpdateCMD(QString pbiID, bool enable);
123        QString generateXDGCMD(QString pbiID, QStringList actions, bool allusers = FALSE);
124        QString generateDownloadCMD(QString appID, QString version="");
125        QString generateInstallCMD(QString appID, QString pbiID);
126        QStringList removePbiCMD(QString pbiID, QStringList list);
127        bool PBIFileNeedsRoot(QString filepath);
128       
129        //Internal functions for queuing up actions
130        void queueInstall(QString appID, QString version="");
131       
132private slots:
133        void updateDlDirPath(QString);
134        void slotWatcherNotification();
135
136        //Process functions
137        void checkProcesses();
138        void slotProcessFinished(int);
139        void slotProcessMessage(int, QString);
140        void slotProcessError(int, QStringList);
141
142        // Database watcher
143        void slotSyncToDatabase(bool localChanges=TRUE);
144        void syncPBI(QString pbiID, bool useDB=TRUE);
145        void slotUpdateAllStatus();
146        void updateStatus(QString pbiID);
147        void syncCurrentRepo();
148       
149        //Filesystem Watcher
150        void startFileSystemWatcher();
151        void stopFileSystemWatcher();
152
153       
154signals:
155        void RepositoryInfoReady();
156        void NoRepoAvailable();
157        void LocalPBIChanges();
158        void PBIStatusChange(QString pbiID);
159        //Process Signals
160        void Error(QString title, QString message, QStringList log);
161        //Search results
162        void SearchComplete(QStringList, QStringList);// "best" and "rest" results lists
163        void SimilarFound(QStringList);
164};
165
166#endif
Note: See TracBrowser for help on using the repository browser.