source: src-qt4/pc-softwaremanager/pbiBackend.h @ 9cbf5aa

releng/10.0.1releng/10.0.2
Last change on this file since 9cbf5aa was 9cbf5aa, checked in by Ken Moore <ken@…>, 5 months ago

Fix up the browser app page status notifications with the new backend process class.

  • Property mode set to 100644
File size: 6.0 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        bool safeToQuit(); //return FALSE if there are process running/waiting
46        // Local/Repo Interaction
47        QString isInstalled(QString appID); //returns pbiID that is installed (if possible);
48        QString upgradeAvailable(QString pbiID); //returns appID for PBI upgrade (if available)
49        // PBI Actions
50        void cancelActions(QStringList pbiID); //cancel any pending/current operations
51        void upgradePBI(QStringList pbiID); //start upgrade process for list of PBI's
52        void removePBI(QStringList pbiID); //start the removal process
53        void installApp(QStringList appID); //[install/upgrade/downgrade] application from the repo (as appropriate)
54        void installPBIFromFile(QStringList files); //[install/upgrade/downgrade] application from file
55        void addDesktopIcons(QStringList pbiID, bool allusers); // add XDG desktop icons
56        void addMenuIcons(QStringList pbiID, bool allusers); // add XDG menu icons
57        void addPaths(QStringList pbiID, bool allusers); // create path links
58        void addMimeTypes(QStringList pbiID, bool allusers); //add XDG Mime type associations
59        void rmDesktopIcons(QStringList pbiID, bool allusers); // remove XDG desktop icons
60        void rmMenuIcons(QStringList pbiID, bool allusers); // remove XDG menu icons
61        void rmPaths(QStringList pbiID, bool allusers); // remove path links
62        void rmMimeTypes(QStringList pbiID, bool allusers); //remove XDG Mime type associations
63        void enableAutoUpdate(QString pbiID, bool enable); //enable/disable auto-updating
64       
65        // Information Retrieval
66        QStringList PBIInfo( QString pbiID, QStringList infoList);
67        QStringList CatInfo( QString catID, QStringList infoList);
68        QStringList AppInfo( QString appID, QStringList infoList);
69        QString currentAppStatus( QString appID , bool rawstatus = false);
70        bool isWorking(QString pbiID);
71        QStringList pbiBinList(QString pbiID);
72        QString pbiToAppID(QString pbiID);
73       
74        //Configuration Management
75        void openConfigurationDialog();
76       
77        //Import/Export PBI lists
78        bool exportPbiListToFile(QString filepath);
79        bool importPbiListFromFile(QString filepath);
80       
81public slots:
82        void startAppSearch(); //get list of apps containing the search string (SIGNAL OUTPUT ONLY)
83        void startSimilarSearch(); //get list of apps that are similar to the input app
84       
85private:
86        QWidget *parentWidget;
87        QTimer *watchTimer;
88        //variables - warden mode
89        QString wardenDir, wardenIP;
90        bool wardenMode;
91        //variables - filesystem watcher;
92        QFileSystemWatcher *watcher;
93        QString baseDBDir; //  This is always /var/db/pbi/
94        QString DBDir;
95        //variables - database
96        PBIDBAccess *sysDB;
97        QHash<QString, InstalledPBI> PBIHASH;
98        QHash<QString, MetaCategory> CATHASH;
99        QHash<QString, MetaPBI> APPHASH;
100        bool noRepo;
101        //variables - processes
102        ProcessManager *PMAN;
103        QString cDownload, cInstall, cRemove, cUpdate, cDownloadFile, cOther; //currently running command/pbi
104        bool sDownload, sInstall, sRemove, sUpdate; //flag that these processes were Stopped
105        QStringList PENDINGDL, PENDINGINSTALL, PENDINGREMOVAL, PENDINGUPDATE, PENDINGOTHER;
106        QString lDownload, lInstall, lRemove, lUpdate; //latest string output from process
107        //variables - other
108        QString baseDlDir, dlDir; // download/install directories
109        QString sysArch; //system architecture
110        //Configuration Management
111        bool keepDownloads;
112        QStringList autoXDG;
113        QString settingsFile, currentRepoNum; //currentRepoNum only used during initial load
114        bool saveSettings();
115        bool loadSettings();
116
117        //functions
118        QString addRootCMD(QString cmd, bool needRoot);
119        QString generateUpdateCMD(QString pbiID);
120        QString generateRemoveCMD(QString pbiID);
121        QString generateAutoUpdateCMD(QString pbiID, bool enable);
122        QString generateXDGCMD(QString pbiID, QStringList actions, bool allusers = FALSE);
123        QString generateDownloadCMD(QString appID, QString version="");
124        QString generateInstallCMD(QString appID, QString pbiID);
125        QStringList removePbiCMD(QString pbiID, QStringList list);
126        bool PBIFileNeedsRoot(QString filepath);
127       
128        //Internal functions for queuing up actions
129        void queueInstall(QString appID, QString version="");
130       
131private slots:
132        void updateDlDirPath(QString);
133        void slotWatcherNotification();
134
135        //Process functions
136        void checkProcesses();
137        void slotProcessFinished(int);
138        void slotProcessMessage(int, QString);
139        void slotProcessError(int, QStringList);
140
141        // Database watcher
142        void slotSyncToDatabase(bool localChanges=TRUE);
143        void syncPBI(QString pbiID, bool useDB=TRUE);
144        void slotUpdateAllStatus();
145        void updateStatus(QString pbiID);
146        void syncCurrentRepo();
147       
148        //Filesystem Watcher
149        void startFileSystemWatcher();
150        void stopFileSystemWatcher();
151
152       
153signals:
154        void RepositoryInfoReady();
155        void NoRepoAvailable();
156        void LocalPBIChanges();
157        void PBIStatusChange(QString pbiID);
158        //Process Signals
159        void Error(QString title, QString message, QStringList log);
160        //Search results
161        void SearchComplete(QStringList, QStringList);// "best" and "rest" results lists
162        void SimilarFound(QStringList);
163};
164
165#endif
Note: See TracBrowser for help on using the repository browser.