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

9.2-releasereleng/10.0releng/10.0.1releng/10.0.2
Last change on this file since c71b68c was c71b68c, checked in by Ken Moore <ken@…>, 12 months ago

Add a bunch of error loggin to the backend processes, and also add a new dialog for displaying these error logs. Also fix the detection of an update failure.

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