root / modules / profiles / profiles.h @ 18636b4a
History | View | Annotate | Download (4.2 kB)
| 1 | /*
|
|---|---|
| 2 | * This program is free software; you can redistribute it and/or modify |
| 3 | * it under the terms of the GNU General Public License as published by |
| 4 | * the Free Software Foundation; either version 2 of the License, or |
| 5 | * (at your option) any later version. |
| 6 | */ |
| 7 | |
| 8 | #ifndef PROFILES_H
|
| 9 | #define PROFILES_H
|
| 10 | |
| 11 | #include <QtCore/QString> |
| 12 | #include <QtCore/QObject> |
| 13 | #include <QtCore/QThread> |
| 14 | #include <QtCore/QList> |
| 15 | #include <QtCore/QStringList> |
| 16 | #include <QtGui/QWidget> |
| 17 | #include <QtGui/QDialog> |
| 18 | #include <QtGui/QLabel> |
| 19 | #include <QtGui/QLineEdit> |
| 20 | #include <QtGui/QCheckBox> |
| 21 | #include <QtGui/QPushButton> |
| 22 | #include <QtGui/QListWidget> |
| 23 | #include <QtGui/QMenu> |
| 24 | #include <QtXml/QDomElement> |
| 25 | |
| 26 | #include "action.h" |
| 27 | |
| 28 | /*
|
| 29 | * ProfileConfigurationWindow |
| 30 | * okno Menedzera Profili |
| 31 | */ |
| 32 | |
| 33 | /*
|
| 34 | * Profile |
| 35 | * Klasa Profilu |
| 36 | * przechowuje dane profilu |
| 37 | */ |
| 38 | |
| 39 | class Profile |
| 40 | {
|
| 41 | public:
|
| 42 | Profile(): config(true), userlist(true), autostart(false) {}; |
| 43 | Profile(const Profile &p) : name(p.name), directory(p.directory), uin(p.uin),
|
| 44 | password(p.password), protectPassword(p.protectPassword), |
| 45 | config(p.config), userlist(p.userlist), autostart(p.autostart) {};
|
| 46 | Profile(QString name, QString dir): name(name), directory(dir), config(true), userlist(true), autostart(false) {}; |
| 47 | ~Profile() {};
|
| 48 | |
| 49 | QString name; |
| 50 | QString directory; |
| 51 | QString uin; |
| 52 | QString password; |
| 53 | QString protectPassword; |
| 54 | bool config;
|
| 55 | bool userlist;
|
| 56 | bool autostart;
|
| 57 | }; |
| 58 | |
| 59 | |
| 60 | class ProfileConfigurationWindow : public QDialog |
| 61 | {
|
| 62 | Q_OBJECT |
| 63 | public: |
| 64 | ProfileConfigurationWindow(QWidget * parent = 0, const char * name = 0, bool modal = FALSE, Qt::WindowFlags f = 0); |
| 65 | ~ProfileConfigurationWindow(); |
| 66 | void initConfiguration();
|
| 67 | void clear();
|
| 68 | void refreshList();
|
| 69 | void saveProfile(Profile p, bool update); |
| 70 | void removeProfile(QString name);
|
| 71 | // QDomElement getProfile(QString name);
|
| 72 | QListWidget *profilesList; |
| 73 | private:
|
| 74 | QLineEdit *profileName; |
| 75 | QLineEdit *profileUIN; |
| 76 | QLineEdit *profileDir; |
| 77 | QLineEdit *profilePassword; |
| 78 | QLineEdit *protectPassword; |
| 79 | QCheckBox *advancedCheck; |
| 80 | QCheckBox *configCheck; |
| 81 | QCheckBox *userlistCheck; |
| 82 | QCheckBox *autostartCheck; |
| 83 | QCheckBox *passwordProtectCheck; |
| 84 | QPushButton *saveButton; |
| 85 | QPushButton *deleteButton; |
| 86 | QPushButton *openButton; |
| 87 | QPushButton *closeButton; |
| 88 | QString profileProtectPassword; |
| 89 | |
| 90 | private slots: |
| 91 | void closeBtnPressed();
|
| 92 | void openBtnPressed();
|
| 93 | void saveBtnPressed();
|
| 94 | void deleteBtnPressed();
|
| 95 | void profileSelected(QListWidgetItem *item);
|
| 96 | void advancedChecked(bool state); |
| 97 | void configChecked(bool state); |
| 98 | void passwordProtectChecked(bool state); |
| 99 | void fillDir(const QString &s); |
| 100 | }; |
| 101 | |
| 102 | |
| 103 | /*
|
| 104 | * MyThread |
| 105 | * klasa implementujaca watek. |
| 106 | * nazwa nie jest ambitna - wiem |
| 107 | */ |
| 108 | |
| 109 | class MyThread : public QThread {
|
| 110 | public:
|
| 111 | MyThread() {};
|
| 112 | QString path; |
| 113 | QString command; |
| 114 | virtual void run();
|
| 115 | }; |
| 116 | |
| 117 | //typedef QList<MyThread *> ThreadList;
|
| 118 | |
| 119 | |
| 120 | |
| 121 | /*
|
| 122 | * ProfileManager |
| 123 | * Klasa Menedzera Profili |
| 124 | * odpowiedzialna za tworzenie okna menedzera, |
| 125 | * uruchamianie profili, etc. |
| 126 | */ |
| 127 | |
| 128 | class ProfileManager : public QObject |
| 129 | {
|
| 130 | Q_OBJECT |
| 131 | public: |
| 132 | ProfileManager(QObject *parent=0, const char *name=0); |
| 133 | ~ProfileManager(); |
| 134 | void firstRun();
|
| 135 | void runAutostarted();
|
| 136 | int runKadu(QString profilePath, QString password);
|
| 137 | static QString dirString();
|
| 138 | |
| 139 | void addProfile(Profile p);
|
| 140 | void updateProfile(Profile p);
|
| 141 | void deleteProfile(const QString &name); |
| 142 | QList<Profile> getProfileList(); |
| 143 | QStringList getProfileNames(); |
| 144 | Profile getProfile(const QString &name);
|
| 145 | |
| 146 | private:
|
| 147 | int profilePos;
|
| 148 | ProfileConfigurationWindow *dialogWindow; |
| 149 | //ThreadList thread_list;
|
| 150 | QMenu *ProfileMenu; |
| 151 | ActionDescription *profileMenuActionDescription; |
| 152 | QList<Profile> list; |
| 153 | |
| 154 | void getProfiles();
|
| 155 | |
| 156 | private slots: |
| 157 | void showConfig();
|
| 158 | void showMenu();
|
| 159 | void createProfileMenu();
|
| 160 | void openProfile(int index); |
| 161 | }; |
| 162 | |
| 163 | |
| 164 | /*
|
| 165 | * PasswordDialog |
| 166 | * Okno z zapytaniem o haslo |
| 167 | */ |
| 168 | |
| 169 | class PasswordDialog : public QDialog |
| 170 | {
|
| 171 | Q_OBJECT |
| 172 | public: |
| 173 | PasswordDialog(QDialog *parent=0, const char *name=0); |
| 174 | ~PasswordDialog(); |
| 175 | QString getPassword(); |
| 176 | |
| 177 | private:
|
| 178 | QLineEdit *password; |
| 179 | QPushButton *okButton; |
| 180 | QPushButton *cancelButton; |
| 181 | private slots: |
| 182 | void okBtnPressed();
|
| 183 | void cancelBtnPressed();
|
| 184 | }; |
| 185 | |
| 186 | |
| 187 | extern ProfileManager *profileManager;
|
| 188 | |
| 189 | #endif
|