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

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

Make sure that the AppCafe? browser "app" page gets the download button updated if there is a status change for the associated installed version of that app.

  • Property mode set to 100644
File size: 5.9 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        //variables - warden mode
88        QString wardenDir, wardenIP;
89        bool wardenMode;
90        //variables - filesystem watcher;
91        QFileSystemWatcher *watcher;
92        QString baseDBDir; //  This is always /var/db/pbi/
93        QString DBDir;
94        //variables - database
95        PBIDBAccess *sysDB;
96        QHash<QString, InstalledPBI> PBIHASH;
97        QHash<QString, MetaCategory> CATHASH;
98        QHash<QString, MetaPBI> APPHASH;
99        bool noRepo;
100        //variables - processes
101        ProcessManager *PMAN;
102        QString cDownload, cInstall, cRemove, cUpdate, cDownloadFile, cOther; //currently running command/pbi
103        bool sDownload, sInstall, sRemove, sUpdate; //flag that these processes were Stopped
104        QStringList PENDINGDL, PENDINGINSTALL, PENDINGREMOVAL, PENDINGUPDATE, PENDINGOTHER;
105        QString lDownload, lInstall, lRemove, lUpdate; //latest string output from process
106        //variables - other
107        QString baseDlDir, dlDir; // download/install directories
108        QString sysArch; //system architecture
109        //Configuration Management
110        bool keepDownloads;
111        QStringList autoXDG;
112        QString settingsFile, currentRepoNum; //currentRepoNum only used during initial load
113        bool saveSettings();
114        bool loadSettings();
115
116        //functions
117        QString addRootCMD(QString cmd, bool needRoot);
118        QString generateUpdateCMD(QString pbiID);
119        QString generateRemoveCMD(QString pbiID);
120        QString generateAutoUpdateCMD(QString pbiID, bool enable);
121        QString generateXDGCMD(QString pbiID, QStringList actions, bool allusers = FALSE);
122        QString generateDownloadCMD(QString appID, QString version="");
123        QString generateInstallCMD(QString appID, QString pbiID);
124        QStringList removePbiCMD(QString pbiID, QStringList list);
125        bool PBIFileNeedsRoot(QString filepath);
126       
127        //Internal functions for queuing up actions
128        void queueInstall(QString appID, QString version="");
129       
130private slots:
131        void updateDlDirPath(QString);
132       
133        //Process functions
134        void checkProcesses();
135        void slotProcessFinished(int);
136        void slotProcessMessage(int, QString);
137        void slotProcessError(int, QStringList);
138
139        // Database watcher
140        void slotSyncToDatabase(bool localChanges=TRUE);
141        void syncPBI(QString pbiID, bool useDB=TRUE);
142        void slotUpdateAllStatus();
143        void updateStatus(QString pbiID);
144        void syncCurrentRepo();
145       
146        //Filesystem Watcher
147        void startFileSystemWatcher();
148        void stopFileSystemWatcher();
149
150       
151signals:
152        void RepositoryInfoReady();
153        void NoRepoAvailable();
154        void LocalPBIChanges();
155        void PBIStatusChange(QString pbiID);
156        //Process Signals
157        void Error(QString title, QString message, QStringList log);
158        //Search results
159        void SearchComplete(QStringList, QStringList);// "best" and "rest" results lists
160        void SimilarFound(QStringList);
161};
162
163#endif
Note: See TracBrowser for help on using the repository browser.