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

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

Merge the new AppCafe? into the src-qt4 tree from the projects directory

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