~ubuntu-branches/ubuntu/wily/psi/wily-proposed

« back to all changes in this revision

Viewing changes to src/main.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2008-08-28 18:46:52 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080828184652-iiik12dl91nq7cdi
Tags: 0.12-2
Uploading to unstable (Closes: Bug#494352)

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include <qmessagebox.h>
33
33
#include <QtCrypto>
34
34
#include <QTranslator>
 
35
#include <QDir>
 
36
 
35
37
#include <stdlib.h>
36
38
#include <time.h>
37
 
#include "profiles.h"
38
39
#include "profiledlg.h"
 
40
#include "activeprofiles.h"
 
41
#include "psioptions.h"
39
42
 
40
43
#include "eventdlg.h"
41
44
#include "psicon.h"
121
124
                        QTimer::singleShot(0, this, SLOT(bail()));
122
125
                }
123
126
                else {
 
127
                        PsiOptions o;
 
128
                        if (!o.newProfile()) {
 
129
                                qWarning("ERROR: Failed to new profile default options");
 
130
                        }
 
131
 
 
132
                        o.save(pathToProfile("default") + "/options.xml");
 
133
 
124
134
                        lastProfile = activeProfile = "default";
125
135
                        autoOpen = true;
126
136
                        QTimer::singleShot(0, this, SLOT(sessionStart()));
182
192
                        continue;
183
193
                }
184
194
                else {
185
 
                        if(r == QDialog::Accepted)
 
195
                        bool again = false;
 
196
                        autoOpen = w->ck_auto->isChecked();
 
197
                        if(r == QDialog::Accepted) {
186
198
                                str = w->cb_profile->currentText();
187
 
                        autoOpen = w->ck_auto->isChecked();
 
199
                                again = !ActiveProfiles::instance()->setThisProfile(str);
 
200
                                if (again) {
 
201
                                        QMessageBox mb(QMessageBox::Question,
 
202
                                                CAP(tr("Profile already in use")),
 
203
                                                QString(tr("The \"%1\" profile is already in use.\nWould you like to activate that session now?")).arg(str),
 
204
                                                QMessageBox::Cancel);
 
205
                                        QPushButton *activate = mb.addButton(tr("Activate"), QMessageBox::AcceptRole);
 
206
                                        mb.exec();
 
207
                                        if (mb.clickedButton() == activate) {
 
208
                                                ActiveProfiles::instance()->raiseOther(str, true);
 
209
                                                quit();
 
210
                                                return;
 
211
                                        }
 
212
                                }
 
213
                        }
188
214
                        delete w;
 
215
                        if (again) {
 
216
                                str = "";
 
217
                                continue;
 
218
                        }
189
219
                        break;
190
220
                }
191
221
        }
204
234
 
205
235
void PsiMain::sessionStart()
206
236
{
 
237
        // make sure we have clean PsiOptions
 
238
        PsiOptions::reset();
207
239
        // get a PsiCon
 
240
        if (!ActiveProfiles::instance()->setThisProfile(activeProfile)) { // already running
 
241
                if (!ActiveProfiles::instance()->raiseOther(activeProfile, true))
 
242
                        QMessageBox::critical(0, tr("Error"), tr("Cannot open this profile - it is already running, but not responding"));
 
243
                quit();
 
244
                return;
 
245
        }
208
246
        pcon = new PsiCon();
209
247
        if(!pcon->init()) {
210
248
                delete pcon;
239
277
        // it must be initialized first in order for ApplicationInfo::resourcesDir() to work
240
278
        QCA::Initializer init;
241
279
        PsiApplication app(argc, argv);
 
280
        QApplication::addLibraryPath(ApplicationInfo::resourcesDir());
242
281
        QApplication::addLibraryPath(ApplicationInfo::homeDir());
243
 
        QApplication::addLibraryPath(ApplicationInfo::resourcesDir());
244
282
        QApplication::setQuitOnLastWindowClosed(false);
245
283
 
 
284
#ifdef Q_WS_MAC
 
285
        QDir dir(QApplication::applicationDirPath());
 
286
        dir.cdUp();
 
287
        dir.cd("Plugins");
 
288
        QApplication::addLibraryPath(dir.absolutePath());
 
289
#endif
 
290
 
246
291
        // Initialize QCA
247
292
        QCA::setProperty("pgp-always-trust", true);
248
293
        QCA::KeyStoreManager keystoremgr;