summaryrefslogtreecommitdiffabout
path: root/pwmanager
Side-by-side diff
Diffstat (limited to 'pwmanager') (more/less context) (show whitespace changes)
-rw-r--r--pwmanager/pwmanager/main.cpp1
-rw-r--r--pwmanager/pwmanager/pwm.cpp12
-rw-r--r--pwmanager/pwmanager/pwm.h8
-rw-r--r--pwmanager/pwmanager/pwmanager.pro33
-rw-r--r--pwmanager/pwmanager/pwmdoc.cpp8
-rw-r--r--pwmanager/pwmanager/pwminit.cpp16
-rw-r--r--pwmanager/pwmanager/serializer.cpp6
7 files changed, 52 insertions, 32 deletions
diff --git a/pwmanager/pwmanager/main.cpp b/pwmanager/pwmanager/main.cpp
index 3f2d055..9d1d863 100644
--- a/pwmanager/pwmanager/main.cpp
+++ b/pwmanager/pwmanager/main.cpp
@@ -158,56 +158,57 @@ int main(int argc, char *argv[])
#else
bool exitHelp = false;
if ( argc > 1 ) {
QString command = argv[1];
if ( command == "-help" ){
printf("PWM/PI command line commands:\n");
printf(" no command: Start PWM/PI in usual way\n");
printf(" -help: This output\n");
printf(" PWM/PI is exiting now. Bye!\n");
exitHelp = true;
}
}
if ( ! exitHelp ) {
PwMApplication a(argc, argv);
KGlobal::setAppName( "pwmanager" );
#ifndef DESKTOP_VERSION
//qDebug("width %d ",QApplication::desktop()->width() );
if ( QApplication::desktop()->width() > 320 )
KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons22/");
else
KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons16/");
#else
QString fileName ;
fileName = qApp->applicationDirPath () + "/kdepim/pwmanager/icons22/";
KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
QApplication::addLibraryPath ( qApp->applicationDirPath () );
#endif
KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "pwmanager")));
KPimGlobalPrefs::instance()->setGlobalConfig();
a.newInstance();
//US KAddressBookMain m ;
//US QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
/*US
#ifndef DESKTOP_VERSION
a.showMainWidget( &m );
#else
a.setMainWidget( &m );
m.resize (640, 480 );
m.show();
#endif
*/
+ qDebug("exec ");
a.exec();
}
qDebug("PWMPI: Bye! ");
#endif
}
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp
index 26a44b1..c511661 100644
--- a/pwmanager/pwmanager/pwm.cpp
+++ b/pwmanager/pwmanager/pwm.cpp
@@ -541,174 +541,174 @@ PwMView * PwM::makeNewListView(PwMDoc *doc)
{
PwMView *ret = new PwMView(this, this, doc);
ret->setFont(conf()->confGlobEntryFont());
ret->show();
return ret;
}
void PwM::close_slot()
{
close();
}
void PwM::quitButton_slot()
{
init->shutdownApp(0);
}
void PwM::save_slot()
{
save();
}
bool PwM::save()
{
if (!curDoc()->saveDocUi(curDoc()))
return false;
showStatMsg(i18n("Successfully saved data."));
updateCaption();
return true;
}
void PwM::saveAs_slot()
{
saveAs();
}
bool PwM::saveAs()
{
if (!curDoc()->saveAsDocUi(curDoc()))
return false;
showStatMsg(i18n("Successfully saved data."));
updateCaption();
return true;
}
//US ENH : changed code to run with older MOC
void PwM::addPwd_slot()
{
- addPwd_slot(0, 0);
+ addPwd_slot1(0, 0);
}
-void PwM::addPwd_slot(QString *pw, PwMDoc *_doc)
+void PwM::addPwd_slot1(QString *pw, PwMDoc *_doc)
{
PwMDoc *doc;
if (_doc) {
doc = _doc;
} else {
doc = curDoc();
}
PWM_ASSERT(doc);
doc->timer()->getLock(DocTimer::id_autoLockTimer);
#ifndef PWM_EMBEDDED
AddEntryWndImpl w;
#else
AddEntryWndImpl w(this, "addentrywndimpl");
#endif
vector<string> catList;
doc->getCategoryList(&catList);
unsigned i, size = catList.size();
for (i = 0; i < size; ++i) {
w.addCategory(catList[i].c_str());
}
w.setCurrCategory(view->getCurrentCategory());
if (pw)
w.pwLineEdit->setText(*pw);
tryAgain:
if (w.exec() == 1)
{
PwMDataItem d;
//US BUG: to initialize all values of curEntr with meaningfulldata,
// we call clear on it. Reason: Metadata will be uninitialized otherwise.
// another option would be to create a constructor for PwMDataItem
d.clear(true);
d.desc = w.getDescription().latin1();
d.name = w.getUsername().latin1();
d.pw = w.getPassword().latin1();
d.comment = w.getComment().latin1();
d.url = w.getUrl().latin1();
d.launcher = w.getLauncher().latin1();
PwMerror ret = doc->addEntry(w.getCategory(), &d);
if (ret == e_entryExists) {
KMessageBox::error(this,
i18n
("An entry with this \"Description\",\n"
"does already exist.\n"
"Please select another description."),
i18n("entry already exists."));
goto tryAgain;
} else if (ret == e_maxAllowedEntr) {
KMessageBox::error(this, i18n("The maximum possible number of\nentries"
"has been reached.\nYou can't add more entries."),
i18n("maximum number of entries"));
doc->timer()->putLock(DocTimer::id_autoLockTimer);
return;
}
}
setVirgin(false);
doc->timer()->putLock(DocTimer::id_autoLockTimer);
}
//US ENH : changed code to run with older MOC
void PwM::editPwd_slot()
{
- editPwd_slot(0,0,0);
+ editPwd_slot3(0,0,0);
}
-void PwM::editPwd_slot(const QString *category)
+void PwM::editPwd_slot1(const QString *category)
{
- editPwd_slot(category, 0, 0);
+ editPwd_slot3(category, 0, 0);
}
-void PwM::editPwd_slot(const QString *category, const int *index,
+void PwM::editPwd_slot3(const QString *category, const int *index,
PwMDoc *_doc)
{
PwMDoc *doc;
if (_doc) {
doc = _doc;
} else {
doc = curDoc();
}
PWM_ASSERT(doc);
if (doc->isDocEmpty())
return;
if (doc->isDeepLocked())
return;
doc->timer()->getLock(DocTimer::id_autoLockTimer);
unsigned int curEntryIndex;
if (index) {
curEntryIndex = *index;
} else {
if (!(view->getCurEntryIndex(&curEntryIndex))) {
printDebug("couldn't get index. Maybe we have a binary entry here.");
doc->timer()->putLock(DocTimer::id_autoLockTimer);
return;
}
}
QString curCategory;
if (category) {
curCategory = *category;
} else {
curCategory = view->getCurrentCategory();
}
PwMDataItem currItem;
if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) {
doc->timer()->putLock(DocTimer::id_autoLockTimer);
return;
}
BUG_ON(currItem.binary);
AddEntryWndImpl w;
vector<string> catList;
doc->getCategoryList(&catList);
unsigned i, size = catList.size();
for (i = 0; i < size; ++i) {
w.addCategory(catList[i].c_str());
}
w.setCurrCategory(curCategory);
w.setDescription(currItem.desc.c_str());
w.setUsername(currItem.name.c_str());
w.setPassword(currItem.pw.c_str());
diff --git a/pwmanager/pwmanager/pwm.h b/pwmanager/pwmanager/pwm.h
index fe1f7a1..116bc66 100644
--- a/pwmanager/pwmanager/pwm.h
+++ b/pwmanager/pwmanager/pwm.h
@@ -89,104 +89,106 @@ public:
/** ask the user where to save the doc
* and write the data to disk.
*/
bool saveAs();
/** force quit. Quit this window, always! Don't minimize it */
bool isForceQuit()
{ return forceQuit; }
/** set forceQuit */
void setForceQuit(bool force)
{ forceQuit = force; }
/** force minimize this window */
bool isForceMinimizeToTray()
{ return forceMinimizeToTray; }
/** set forceMinimizeToTray */
void setForceMinimizeToTray(bool force)
{ forceMinimizeToTray = force; }
public slots:
/** file/new triggered */
void new_slot();
/** file/open triggered */
//US ENH
void open_slot();
void open_slot(QString fn);
/** file/close triggered */
void close_slot();
/** file/quit triggered */
void quitButton_slot();
/** file/save triggered */
void save_slot();
/** file/saveAs triggered */
void saveAs_slot();
/** file/export/text triggered */
void exportToText();
/** file/export/gpasman triggered */
void exportToGpasman();
/** file/export/kwallet triggered */
void exportToKWallet();
/** file/import/text triggered */
bool importFromText();
/** file/import/gpasman triggered */
bool importFromGpasman();
/** file/import/kwallet triggered */
bool importKWallet();
/** file/print triggered */
void print_slot();
/** manage/add triggered */
//US ENH : changed code to run with older MOC
+
void addPwd_slot();
- void addPwd_slot(QString *pw, PwMDoc *_doc);
+ void addPwd_slot1(QString *pw, PwMDoc *_doc);
/** manage/edit triggered */
//US ENH : changed code to run with older MOC
void editPwd_slot();
- void editPwd_slot(const QString *category);
- void editPwd_slot(const QString *category = 0, const int *index = 0,
+ void editPwd_slot1(const QString *category);
+ void editPwd_slot3(const QString *category = 0, const int *index = 0,
PwMDoc *_doc = 0);
+
/** manage/delete triggered */
void deletePwd_slot();
/** execute the "Launcher" entry */
void execLauncher_slot();
/** open browser with URL entry */
void goToURL_slot();
/** manage/changeMasterPwd triggered */
void changeMasterPwd_slot();
/** lock current document */
void lockWnd_slot();
/** deeplock current document */
void deepLockWnd_slot();
/** window/unlock triggered */
void unlockWnd_slot();
/** find item */
void find_slot();
/** configure clicked */
void config_slot();
/** (de)activate the "change master pw" button in the menu-bar */
void activateMpButton(bool activate = true);
/** generate a new chipcard */
void genNewCard_slot();
/** completely erase the current card */
void eraseCard_slot();
/** returns the ID number of the current card */
void readCardId_slot();
/** make backup image of the current card */
void makeCardBackup_slot();
/** write backup image to current card */
void replayCardBackup_slot();
#ifdef PWM_EMBEDDED
void whatsnew_slot();
void showLicense_slot();
void faq_slot();
void createAboutData_slot();
void syncHowTo_slot();
#endif
protected:
/** is this window virgin? */
bool isVirgin()
{ return virgin; }
/** add/remove virginity */
void setVirgin(bool v);
/** initialize the menubar */
void initMenubar();
/** initialize the toolbar */
diff --git a/pwmanager/pwmanager/pwmanager.pro b/pwmanager/pwmanager/pwmanager.pro
index 34f7403..7f39c76 100644
--- a/pwmanager/pwmanager/pwmanager.pro
+++ b/pwmanager/pwmanager/pwmanager.pro
@@ -1,78 +1,83 @@
TEMPLATE = app
CONFIG += qt warn_on
-
-
+DESTDIR= ../../bin
TARGET = pwmpi
-OBJECTS_DIR = obj/$(PLATFORM)
-MOC_DIR = moc/$(PLATFORM)
-DESTDIR=$(QPEDIR)/bin
+include( ../../variables.pri )
-INCLUDEPATH += . ../../ ../../qtcompat ../../qtcompat/xml ../../libkdepim ../../microkde ../../microkde/kdecore ../../microkde/kdeui ../../microkde/kutils $(QPEDIR)/include
+INCLUDEPATH += . ../../ ../../libkdepim ../../microkde ../../microkde/kdecore ../../microkde/kdeui ../../microkde/kutils
DEFINES += PWM_EMBEDDED CONFIG_PWMANAGER_GCRY DESKTOP_VERSION
#enable this setting if you want debugoutput for pwmanager
#DEFINES += CONFIG_DEBUG
-LIBS += -L../libcrypt/$(PLATFORM)
+LIBS += -L../libcrypt/
+LIBS += -L../../bin/
LIBS += -lmicrokde
-LIBS += -lmicroqtcompat
LIBS += -lmicrokdepim
-LIBS += -L$(QPEDIR)/lib
-LIBS += -lqpe
LIBS += -lzlib
-#LIBS += -lbz2
-#LIBS += -lkpmicrogcrypt
-LIBS += -ljpeg
-LIBS += $(QTOPIALIB)
LIBS += -lkpmicrocipher
LIBS += -lkpmicroerror
LIBS += -lkpmicrompi
LIBS += -lstdc++
+unix:{
+OBJECTS_DIR = obj/unix
+MOC_DIR = moc/unix
+
+}
+win32:{
+
+DEFINES += _WIN32_
+OBJECTS_DIR = obj/win
+MOC_DIR = moc/win
+QMAKE_LINK += /NODEFAULTLIB:LIBC
+
+}
+
#INTERFACES = \
#addentrywnd.ui \
#configwnd.ui \
#findwnd.ui \
#getmasterpwwnd.ui \
#pwgenwnd.ui \
#setmasterpwwnd.ui \
#subtbledit.ui
#INTERFACES = \
#subtbledit.ui \
#HEADERS = \
#configuration_31compat.h \
#configuration.h \
#configwnd.h \
#configwndimpl.h \
#selftest.h
#subtbledit.h \
#subtbleditimpl.h \
#compressbzip2.h \
HEADERS = \
addentrywnd_emb.h \
addentrywndimpl.h \
base64.h \
binentrygen.h \
blowfish.h \
commentbox.h \
compiler.h \
compressgzip.h \
findwnd_emb.h \
findwndimpl.h \
genpasswd.h \
getkeycardwnd.h \
getmasterpwwnd_emb.h \
getmasterpwwndimpl.h \
globalstuff.h \
gpasmanfile.h \
htmlgen.h \
htmlparse.h \
ipc.h \
libgcryptif.h \
listobjselectwnd.h \
listviewpwm.h \
printtext.h \
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp
index e29e3d1..8869f3a 100644
--- a/pwmanager/pwmanager/pwmdoc.cpp
+++ b/pwmanager/pwmanager/pwmdoc.cpp
@@ -2284,98 +2284,98 @@ bool PwMDoc::goToURL(unsigned int category, unsigned int entryIndex)
browserProc << "konqueror" << url;
if (browserProc.start(KProcess::DontCare))
return true;
browserProc.clearArguments();
browserProc << "mozilla" << url;
if (browserProc.start(KProcess::DontCare))
return true;
browserProc.clearArguments();
browserProc << "opera" << url;
if (browserProc.start(KProcess::DontCare))
return true;
return false;
}
PwMerror PwMDoc::exportToText(const QString *file)
{
PWM_ASSERT(file);
if (QFile::exists(*file)) {
if (!QFile::remove(*file))
return e_accessFile;
}
QFile f(*file);
if (!f.open(IO_ReadWrite))
return e_openFile;
if (!unlockAll_tempoary()) {
f.close();
return e_lock;
}
// write header
string header = i18n("Password table generated by\nPwM v").latin1();
header += PACKAGE_VER;
header += i18n("\non ").latin1();
QDate currDate = QDate::currentDate();
QTime currTime = QTime::currentTime();
#ifndef PWM_EMBEDDED
header += currDate.toString("ddd MMMM d ").latin1();
header += currTime.toString("hh:mm:ss ").latin1();
#else
QString dfs = KGlobal::locale()->dateFormatShort();
bool ampm = KGlobal::locale()->use12Clock();
KGlobal::locale()->setDateFormatShort("%A %B %d");
KGlobal::locale()->setHore24Format(true);
- header += KGlobal::locale()->formatDate(currDate, true, KLocale::Userdefined);
- header += KGlobal::locale()->formatTime(currTime, true);
+ header += KGlobal::locale()->formatDate(currDate, true, KLocale::Userdefined).latin1();
+ header += KGlobal::locale()->formatTime(currTime, true).latin1();
KGlobal::locale()->setDateFormatShort(dfs);
KGlobal::locale()->setHore24Format(!ampm);
#endif
header += tostr(currDate.year());
header += "\n==============================\n\n";
#ifndef PWM_EMBEDDED
if (f.writeBlock(header.c_str(), header.length()) != (Q_LONG)header.length()) {
unlockAll_tempoary(true);
f.close();
return e_writeFile;
}
#else
if (f.writeBlock(header.c_str(), header.length()) != (long)header.length()) {
unlockAll_tempoary(true);
f.close();
return e_writeFile;
}
#endif
unsigned int i, numCat = numCategories();
unsigned int j, numEnt;
string exp;
for (i = 0; i < numCat; ++i) {
numEnt = numEntries(i);
exp = "\n== Category: ";
exp += dti.dta[i].name;
exp += " ==\n";
#ifndef PWM_EMBEDDED
if (f.writeBlock(exp.c_str(), exp.length()) != (Q_LONG)exp.length()) {
unlockAll_tempoary(true);
f.close();
return e_writeFile;
}
#else
if (f.writeBlock(exp.c_str(), exp.length()) != (long)exp.length()) {
unlockAll_tempoary(true);
f.close();
return e_writeFile;
}
#endif
for (j = 0; j < numEnt; ++j) {
exp = "\n-- ";
exp += dti.dta[i].d[j].desc;
exp += " --\n";
@@ -2973,117 +2973,117 @@ bool PwMDoc::tryDelete()
if (!saveDocUi(this))
goto out_ignore;
} else if (ret == 1) { // don't save and delete
goto out_accept;
} else { // cancel operation
goto out_ignore;
}
}
out_accept:
deleted = true;
delete this;
return true;
out_ignore:
return false;
}
#ifdef PWM_EMBEDDED
//US ENH: this is the magic function that syncronizes the this doc with the remote doc
//US it could have been defined as static, but I did not want to.
PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* syncRemote, int mode )
{
int addedPasswordsLocal = 0;
int addedPasswordsRemote = 0;
int deletedPasswordsRemote = 0;
int deletedPasswordsLocal = 0;
int changedLocal = 0;
int changedRemote = 0;
PwMSyncItem* syncItemLocal;
PwMSyncItem* syncItemRemote;
QString mCurrentSyncName = manager->getCurrentSyncName();
QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
bool fullDateRange = false;
int take;
// local->resetTempSyncStat();
QDateTime mLastSync = QDateTime::currentDateTime();
QDateTime modifiedSync = mLastSync;
unsigned int index;
//Step 1. Find syncinfo in Local file and create if not existent.
bool found = syncLocal->findSyncData(mCurrentSyncDevice, &index);
if (found == false)
{
PwMSyncItem newSyncItemLocal;
- newSyncItemLocal.syncName = mCurrentSyncDevice;
+ newSyncItemLocal.syncName = mCurrentSyncDevice.latin1();
newSyncItemLocal.lastSyncDate = mLastSync;
syncLocal->addSyncDataEntry(&newSyncItemLocal, true);
found = syncLocal->findSyncData(mCurrentSyncDevice, &index);
if (found == false) {
qDebug("PwMDoc::syncronize : newly created local sync data could not be found");
return e_syncError;
}
}
syncItemLocal = syncLocal->getSyncDataEntry(index);
qDebug("Last Sync Local %s ", syncItemLocal->lastSyncDate.toString().latin1());
//Step 2. Find syncinfo in remote file and create if not existent.
found = syncRemote->findSyncData(mCurrentSyncName, &index);
if (found == false)
{
qDebug("FULLDATE 1");
fullDateRange = true;
PwMSyncItem newSyncItemRemote;
- newSyncItemRemote.syncName = mCurrentSyncName;
+ newSyncItemRemote.syncName = mCurrentSyncName.latin1();
newSyncItemRemote.lastSyncDate = mLastSync;
syncRemote->addSyncDataEntry(&newSyncItemRemote, true);
found = syncRemote->findSyncData(mCurrentSyncName, &index);
if (found == false) {
qDebug("PwMDoc::syncronize : newly created remote sync data could not be found");
return e_syncError;
}
}
syncItemRemote = syncRemote->getSyncDataEntry(index);
qDebug("Last Sync Remote %s ", syncItemRemote->lastSyncDate.toString().latin1());
//and remove the found entry here. We will reenter it later again.
//US syncRemote->delSyncDataEntry(index, true);
if ( syncItemLocal->lastSyncDate == mLastSync ) {
qDebug("FULLDATE 2");
fullDateRange = true;
}
if ( ! fullDateRange ) {
if ( syncItemLocal->lastSyncDate != syncItemRemote->lastSyncDate ) {
fullDateRange = true;
qDebug("FULLDATE 3 %s %s", syncItemLocal->lastSyncDate.toString().latin1() , syncItemRemote->lastSyncDate.toString().latin1() );
}
}
// fullDateRange = true; // debug only!
if ( fullDateRange )
mLastSync = QDateTime::currentDateTime().addDays( -100*365);
else
mLastSync = syncItemLocal->lastSyncDate;
qDebug("*************************** ");
qDebug("mLastSync %s ",mLastSync.toString().latin1() );
QStringList er = syncRemote->getIDEntryList();
PwMDataItem* inRemote ;//= er.first();
PwMDataItem* inLocal;
unsigned int catLocal, indexLocal;
unsigned int catRemote, indexRemote;
QString uid;
manager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
int modulo = (er.count()/10)+1;
unsigned int incCounter = 0;
while ( incCounter < er.count()) {
diff --git a/pwmanager/pwmanager/pwminit.cpp b/pwmanager/pwmanager/pwminit.cpp
index 8946443..ea9e330 100644
--- a/pwmanager/pwmanager/pwminit.cpp
+++ b/pwmanager/pwmanager/pwminit.cpp
@@ -1,69 +1,70 @@
/***************************************************************************
* *
* copyright (C) 2004 by Michael Buesch *
* email: mbuesch@freenet.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License version 2 *
* as published by the Free Software Foundation. *
* *
***************************************************************************/
/***************************************************************************
* copyright (C) 2004 by Ulf Schenk
* This file is originaly based on version 1.0.1 of pwmanager
* and was modified to run on embedded devices that run microkde
*
* $Id$
**************************************************************************/
#include "pwminit.h"
#include "randomizer.h"
+#include <qdir.h>
#ifndef PWM_EMBEDDED
#include "selftest.h"
#include "configuration.h"
#else
#include "pwmprefs.h"
#endif
#include "pwm.h"
#include "pwmexception.h"
#include "pwmtray.h"
#include "pwmdoc.h"
#ifdef CONFIG_KWALLETIF
# include "kwalletemu.h"
#endif // CONFIG_KWALLETIF
#ifdef CONFIG_KEYCARD
# include "pwmkeycard.h"
#endif // CONFIG_KEYCARD
#include <qmessagebox.h>
#include <kmessagebox.h>
#ifndef PWM_EMBEDDED
#include <kcmdlineargs.h>
#include <kwin.h>
#include <dcopclient.h>
#endif
#include <kapplication.h>
#include <kiconloader.h>
#include <signal.h>
static PwMInit *sig_init_pointer;
static NOREGPARM void sig_handler(int signum)
{
switch (signum) {
case SIGINT:
case SIGTERM:
sig_init_pointer->shutdownApp(20 + signum);
break;
default:
printDebug(string("unhandled signal ")
+ tostr(signum));
}
}
@@ -83,132 +84,137 @@ PwMInit::PwMInit(PwMApplication *_app)
}
PwMInit::~PwMInit()
{
#ifndef PWM_EMBEDDED
SelfTest::cancel();
// close all open mainwnds
QValueList<PwM *>::iterator i = _mainWndList.begin(),
end = _mainWndList.end();
#else
// close all open mainwnds
QValueList<PwM *>::Iterator i = _mainWndList.begin(),
end = _mainWndList.end();
#endif
while (i != end) {
disconnect(*i, SIGNAL(closed(PwM *)),
this, SLOT(mainWndClosed(PwM *)));
delete *i;
++i;
}
_mainWndList.clear();
// close all remaining open documents
PwMDocList *_dl = PwMDoc::getOpenDocList();
vector<PwMDocList::listItem> dl = *(_dl->getList());
vector<PwMDocList::listItem>::iterator i2 = dl.begin(),
end2 = dl.end();
while (i2 != end2) {
delete (*i2).doc;
++i2;
}
#ifdef CONFIG_KWALLETIF
delete_ifnot_null(_kwalletEmu);
#endif // CONFIG_KWALLETIF
#ifdef CONFIG_KEYCARD
delete_ifnot_null(_keycard);
#endif // CONFIG_KEYCARD
delete_ifnot_null(_tray);
Randomizer::cleanup();
#ifndef PWM_EMBEDDED
Configuration::cleanup();
#endif
}
void PwMInit::initializeApp()
{
+ qDebug("PwMInit::initializeApp() ");
PWM_ASSERT(runStatus == unknown);
runStatus = init;
initPosixSignalHandler();
Randomizer::init();
#ifndef PWM_EMBEDDED
Configuration::init();
#endif
initDCOP();
initKWalletEmu();
initKeycard();
initTray();
handleCmdLineArgs();
-
+ qDebug("handle ");
bool openDeeplocked = false;
if (conf()->confGlobAutostartDeepLocked() ||
savedCmd.open_deeplocked)
openDeeplocked = true;
- if (conf()->confWndAutoMinimizeOnStart() ||
- savedCmd.minToTray) {
+ if ( false ){
+ // LR is not working
+ //if (conf()->confWndAutoMinimizeOnStart() ||
+ // savedCmd.minToTray) {
PwMDoc *newDoc = createDoc();
+ qDebug(" createDoc()");
if (!newDoc->openDocUi(newDoc,
conf()->confGlobAutoStart(),
openDeeplocked)) {
delete newDoc;
+ }
//US ENH for embedded devices: in the case of failure, open a document the default way
createMainWnd(conf()->confGlobAutoStart(),
openDeeplocked,
true,
0,
savedCmd.minimized);
- }
+ // }
} else {
createMainWnd(conf()->confGlobAutoStart(),
openDeeplocked,
true,
0,
savedCmd.minimized);
}
runStatus = running;
}
void PwMInit::shutdownApp(int exitStatus)
{
printDebug(string("PwMInit::shutdownApp(")
+ tostr(exitStatus) + ") called.");
PWM_ASSERT((runStatus == running) || (runStatus == init));
runStatus = shutdown;
QApplication::exit(exitStatus);
/* The destructor of PwMInit is called when control
* leaves main()
*/
}
void PwMInit::initPosixSignalHandler()
{
signal(SIGINT, sig_handler);
signal(SIGTERM, sig_handler);
}
void PwMInit::initDCOP()
{
#ifndef PWM_EMBEDDED
_dcopClient = app->dcopClient();
_dcopClient->setNotifications(true);
#endif
}
void PwMInit::initKWalletEmu(bool forceDisable, bool forceReload)
{
#ifdef CONFIG_KWALLETIF
if (!conf()->confGlobKwalletEmu() ||
forceDisable) {
delete_ifnot_null(_kwalletEmu);
return;
}
try {
if (_kwalletEmu && forceReload)
@@ -241,127 +247,129 @@ void PwMInit::initTray()
{
#ifdef PWM_EMBEDDED
//US ENH : embedded version does not support a tray
return;
#endif
if (!conf()->confGlobTray()) {
if (!_tray)
return;
_tray->hide();
delete_and_null(_tray);
return;
}
if (_tray)
return;
_tray = new PwMTray(this);
connect(_tray, SIGNAL(quitSelected()),
this, SLOT(removeTrayAndQuit()));
connect(_tray, SIGNAL(closed(PwMTray *)),
this, SLOT(trayIconClosed(PwMTray *)));
KIconLoader icons;
#ifndef PWM_EMBEDDED
_tray->setPixmap(icons.loadIcon(PACKAGE_NAME, KIcon::Small));
#endif
_tray->show();
// connect the signals of all open documents.
const vector<PwMDocList::listItem> *dl = PwMDoc::getOpenDocList()->getList();
vector<PwMDocList::listItem>::const_iterator i = dl->begin(),
end = dl->end();
while (i != end) {
_tray->connectDocToTray((*i).doc);
++i;
}
}
void PwMInit::removeTrayAndQuit()
{
PWM_ASSERT(_tray);
// _tray is deleted in ~PwMInit
shutdownApp(0);
}
PwM * PwMInit::createMainWnd(const QString &loadFile,
bool loadFileDeepLocked,
bool virginity,
PwMDoc *doc,
bool minimized)
{
+ qDebug("PwMInit::createMainWnd ");
PwM *newWnd;
if (!doc)
doc = createDoc();
newWnd = new PwM(this, doc, virginity);
#ifndef PWM_EMBEDDED
_mainWndList.push_back(newWnd);
#else
_mainWndList.append(newWnd);
#endif
connect(newWnd, SIGNAL(closed(PwM *)),
this, SLOT(mainWndClosed(PwM *)));
connect(newWnd, SIGNAL(gotFocus(PwM *)),
this, SLOT(setCurWidget(PwM *)));
connect(newWnd, SIGNAL(lostFocus(PwM *)),
this, SLOT(resetCurWidget()));
//US ENH
#ifndef PWM_EMBEDDED
if (minimized)
newWnd->showMinimized();
else
newWnd->show();
#else //PWM_EMBEDDED
#ifndef DESKTOP_VERSION
app->showMainWidget( newWnd );
#else //DESKTOP_VERSION
app->setMainWidget( newWnd );
newWnd->resize (640, 480 );
newWnd->show();
+ qDebug("show ");
#endif //DESKTOP_VERSION
#endif //PWM_EMBEDDED
if (loadFile != QString::null &&
loadFile != "") {
newWnd->openDoc(loadFile, loadFileDeepLocked);
}
return newWnd;
}
PwMDoc * PwMInit::createDoc()
{
PwMDoc *doc = new PwMDoc(this);
#ifdef CONFIG_KEYCARD
doc->setPwMKeyCard(keycard());
#endif
#ifdef CONFIG_KWALLETIF
if (kwalletEmu())
kwalletEmu()->connectDocSignals(doc);
#endif
if (_tray)
_tray->connectDocToTray(doc);
return doc;
}
void PwMInit::mainWndClosed(PwM *wnd)
{
bool doMinimizeToTray = false;
bool doDeleteDoc = false;
#ifndef PWM_EMBEDDED
dcopClient()->suspend();
dcopClient()->setAcceptCalls(false);
#endif
again:
if (wnd->isForceMinimizeToTray()) {
if (unlikely(!_tray)) {
/* This should not happen! If we set forceMinimizeToTray ,
* we must be sure that _tray exists.
*/
BUG();
wnd->setForceMinimizeToTray(false);
goto again;
}
diff --git a/pwmanager/pwmanager/serializer.cpp b/pwmanager/pwmanager/serializer.cpp
index 2d6498e..ed0f754 100644
--- a/pwmanager/pwmanager/serializer.cpp
+++ b/pwmanager/pwmanager/serializer.cpp
@@ -125,97 +125,101 @@ Serializer::Serializer()
{
defaultLockStat = true;
//US BUG: I needed to specify a document name. Otherwise impl will not be created for serializing
#ifndef PWM_EMBEDDED
domDoc = new QDomDocument;
#else
domDoc = new QDomDocument("mydoc");
#endif
}
Serializer::Serializer(const QCString &buffer)
{
defaultLockStat = true;
//US BUG: I needed to specify a document name. Otherwise impl will not be created for serializing
#ifndef PWM_EMBEDDED
domDoc = new QDomDocument;
#else
domDoc = new QDomDocument("mydoc");
#endif
if (!parseXml(buffer)) {
delete domDoc;
#ifndef PWM_EMBEDDED
throw PwMException(PwMException::EX_PARSE);
#else
qDebug("Serializer::Serializer : Parse Exception ");
#endif
}
}
Serializer::~Serializer()
{
delete_ifnot_null(domDoc);
}
void Serializer::clear()
{
delete_ifnot_null(domDoc);
domDoc = new QDomDocument;
}
bool Serializer::parseXml(const QCString &buffer)
{
PWM_ASSERT(domDoc);
#ifndef PWM_EMBEDDED
if (!domDoc->setContent(buffer, true))
return false;
#else
+#ifdef DESKTOP_VERSION
+ if (!domDoc->setContent(buffer, true))
+#else
if (!domDoc->setContent(buffer))
+#endif
return false;
#endif
if (!checkValid())
return false;
return true;
}
QCString Serializer::getXml()
{
PWM_ASSERT(domDoc);
#ifndef PWM_EMBEDDED
#if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0
QCString tmp(domDoc->toCString(8));
printDebug("<BEGIN Serializer::getXml() dump>\n");
cout << tmp << endl;
printDebug("<END Serializer::getXml() dump>");
#endif // DEBUG
QCString ret(domDoc->toCString(0));
ret.replace('\n', "");
return ret;
#else
#if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0
QCString tmp(" " + domDoc->toCString());
printDebug("<BEGIN Serializer::getXml() dump>\n");
qDebug(tmp);
cout << tmp << endl;
printDebug("<END Serializer::getXml() dump>");
#endif // DEBUG
QCString ret(domDoc->toCString());
ret.replace(QRegExp("\n"), "");
return ret;
#endif
}
bool Serializer::serialize(PwMItem &dta)
{
PWM_ASSERT(domDoc);
QDomElement root(genNewRoot());
QDomElement catNode(domDoc->createElement(CAT_ROOT_WR));
QDomElement syncNode(domDoc->createElement(SYNC_ROOT));
if (!addSyncData(&syncNode, dta.syncDta))
return false;
root.appendChild(syncNode);
@@ -687,94 +691,94 @@ QString Serializer::escapeEntryData(QString dta)
#else
dta.replace(QRegExp("\n"), "$>--endl--<$");
dta.replace(QRegExp("]]>"), "||>");
#endif
return dta;
}
QString Serializer::unescapeEntryData(QString dta)
{
#ifndef PWM_EMBEDDED
dta.replace("$>--endl--<$", "\n");
dta.replace("||>", "]]>");
#else
dta.replace(QRegExp("\\$>--endl--<\\$"), "\n");
dta.replace(QRegExp("||>"), "]]>");
#endif
return dta;
}
//US ENH: the following methods are getting used to write/read sync entries
/** read the syncentries in the node "n" */
bool Serializer::readSyncData(const QDomNode &n, vector<PwMSyncItem> *dta)
{
QDomNodeList nl(n.childNodes());
QDomNode cur;
QString devicename, val;
unsigned int numSync = nl.count(), i;
PwMSyncItem curSync;
bool ok = true;
if (!numSync) {
//no sync entries is a possible result
printDebug("Serializer::readSyncData(): empty");
return true;
}
for (i = 0; i < numSync; ++i) {
cur = nl.item(i);
if (cur.nodeName().left(1) == SYNC_TARGET_PREFIX) {
devicename = cur.toElement().attribute(SYNC_TARGET_NAME);
val = cur.toElement().text();
if ((val == "") || (devicename == QString::null)) {
printDebug("Serializer::readSyncData(): empty synctarget name or syncdate");
continue;
}
- curSync.syncName = devicename;
+ curSync.syncName = devicename.latin1();
#ifndef PWM_EMBEDDED
curSync.lastSyncDate = QDateTime::fromString(val, Qt::ISODate);
#else
curSync.lastSyncDate = KGlobal::locale()->readDateTime(val, KLocale::ISODate, &ok);
if (ok == false)
qDebug("Serializer::readSyncData(): could not parse syncdate:%s",val.latin1());
#endif
dta->push_back(curSync);
}
}
return true;
}
bool Serializer::addSyncData(QDomElement *e,
const vector<PwMSyncItem> &dta)
{
unsigned int numSync = dta.size(), i;
QString curId, curDeviceName;
QDomElement curSync;
QDomText text;
for (i = 0; i < numSync; ++i) {
curId = SYNC_TARGET_PREFIX;
curId += tostr(i).c_str();
curDeviceName = dta[i].syncName.c_str();
curSync = domDoc->createElement(curId);
curSync.setAttribute(SYNC_TARGET_NAME, curDeviceName);
#ifndef PWM_EMBEDDED
text = domDoc->createTextNode(dta[i].lastSyncDate.toString(Qt::ISODate));
#else
text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta[i].lastSyncDate, KLocale::ISODate));
#endif
curSync.appendChild(text);
e->appendChild(curSync);
}
return true;
}