source: src-qt4/pc-softwaremanager/pbiBackend.h @ 7cc177e

9.2-releasereleng/10.0releng/10.0.1releng/10.0.2
Last change on this file since 7cc177e was 7cc177e, checked in by Kris Moore <kris@…>, 10 months ago

Fix up all the last bits of clang / HEAD fussiness

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