summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/pwmanager.pro168
-rw-r--r--pwmanager/pwmanager/pwmdoc.h2
2 files changed, 169 insertions, 1 deletions
diff --git a/pwmanager/pwmanager/pwmanager.pro b/pwmanager/pwmanager/pwmanager.pro
new file mode 100644
index 0000000..34f7403
--- a/dev/null
+++ b/pwmanager/pwmanager/pwmanager.pro
@@ -0,0 +1,168 @@
+TEMPLATE = app
+CONFIG += qt warn_on
+
+
+TARGET = pwmpi
+OBJECTS_DIR = obj/$(PLATFORM)
+MOC_DIR = moc/$(PLATFORM)
+DESTDIR=$(QPEDIR)/bin
+
+INCLUDEPATH += . ../../ ../../qtcompat ../../qtcompat/xml ../../libkdepim ../../microkde ../../microkde/kdecore ../../microkde/kdeui ../../microkde/kutils $(QPEDIR)/include
+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 += -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++
+
+#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 \
+pwgenwnd_emb.h \
+pwgenwndimpl.h \
+pwmdoc.h \
+pwmdocui.h \
+pwmexception.h \
+pwm.h \
+pwminit.h \
+pwmprefs.h \
+pwmprint.h \
+pwmtray.h \
+pwmview.h \
+pwmviewstyle_0.h \
+pwmviewstyle_1.h \
+pwmviewstyle.h \
+randomizer.h \
+rc2.h \
+rencatwnd.h \
+serializer.h \
+setmasterpwwnd_emb.h \
+setmasterpwwndimpl.h \
+sha1.h \
+waitwnd.h \
+kcmconfigs/kcmpwmconfig.h \
+kcmconfigs/pwmconfigwidget.h
+
+#sources that need not be build
+#SOURCES = \
+#advcommeditimpl.cpp \
+#configuration.cpp \
+#configwnd.cpp \
+#configwndimpl.cpp \
+#configuration_31compat.cpp \
+#htmlparse.cpp \
+#printtext.cpp \
+#selftest.cpp \
+#pwmprint.cpp \
+#spinforsignal.cpp
+#subtbledit.cpp \
+#subtbleditimpl.cpp \
+#compressbzip2.cpp
+
+
+SOURCES = \
+addentrywnd_emb.cpp \
+addentrywndimpl.cpp \
+base64.cpp \
+binentrygen.cpp \
+blowfish.cpp \
+commentbox.cpp \
+compressgzip.cpp \
+findwnd_emb.cpp \
+findwndimpl.cpp \
+genpasswd.cpp \
+getkeycardwnd.cpp \
+getmasterpwwnd_emb.cpp \
+getmasterpwwndimpl.cpp \
+globalstuff.cpp \
+gpasmanfile.cpp \
+htmlgen.cpp \
+ipc.cpp \
+libgcryptif.cpp \
+listobjselectwnd.cpp \
+listviewpwm.cpp \
+main.cpp \
+pwgenwnd_emb.cpp \
+pwgenwndimpl.cpp \
+pwm.cpp \
+pwmdoc.cpp \
+pwmdocui.cpp \
+pwmexception.cpp \
+pwminit.cpp \
+pwmprefs.cpp \
+pwmtray.cpp \
+pwmview.cpp \
+pwmviewstyle_0.cpp \
+pwmviewstyle_1.cpp \
+pwmviewstyle.cpp \
+randomizer.cpp \
+rc2.cpp \
+rencatwnd.cpp \
+serializer.cpp \
+setmasterpwwnd_emb.cpp \
+setmasterpwwndimpl.cpp \
+sha1.cpp \
+waitwnd.cpp \
+kcmconfigs/kcmpwmconfig.cpp \
+kcmconfigs/pwmconfigwidget.cpp
+
+
+
diff --git a/pwmanager/pwmanager/pwmdoc.h b/pwmanager/pwmanager/pwmdoc.h
index a6e5f58..635361a 100644
--- a/pwmanager/pwmanager/pwmdoc.h
+++ b/pwmanager/pwmanager/pwmdoc.h
@@ -1,514 +1,514 @@
/***************************************************************************
* *
* copyright (C) 2003, 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.1 of pwmanager
* and was modified to run on embedded devices that run microkde
*
* $Id$
**************************************************************************/
#ifndef __PWMDOC_H
#define __PWMDOC_H
#define PWM_FILE_VER (static_cast<char>(0x05))
#define PWM_HASH_SHA1 (static_cast<char>(0x01))
#define PWM_HASH_SHA256 (static_cast<char>(0x02))
#define PWM_HASH_SHA384 (static_cast<char>(0x03))
#define PWM_HASH_SHA512 (static_cast<char>(0x04))
#define PWM_HASH_MD5 (static_cast<char>(0x05))
#define PWM_HASH_RMD160 (static_cast<char>(0x06))
#define PWM_HASH_TIGER (static_cast<char>(0x07))
#define PWM_CRYPT_BLOWFISH (static_cast<char>(0x01))
#define PWM_CRYPT_AES128 (static_cast<char>(0x02))
#define PWM_CRYPT_AES192 (static_cast<char>(0x03))
#define PWM_CRYPT_AES256 (static_cast<char>(0x04))
#define PWM_CRYPT_3DES (static_cast<char>(0x05))
#define PWM_CRYPT_TWOFISH (static_cast<char>(0x06))
#define PWM_CRYPT_TWOFISH128 (static_cast<char>(0x07))
#define PWM_COMPRESS_NONE (static_cast<char>(0x00))
#define PWM_COMPRESS_GZIP (static_cast<char>(0x01))
#define PWM_COMPRESS_BZIP2 (static_cast<char>(0x02))
#define DEFAULT_MAX_ENTRIES (~(static_cast<unsigned int>(0)))
#define FILE_ID_HEADER "PWM_PASSWORD_FILE"
#include "pwmexception.h"
#include "pwmdocui.h"
#include <qobject.h>
#include <qtimer.h>
#include <qdatetime.h>
#include <kprocess.h>
#ifndef PWM_EMBEDDED
#include "configuration.h"
#else
#include <kapplication.h>
#include <ksyncmanager.h>
#endif
#include <string>
#include <vector>
#include <utility>
using std::vector;
using std::string;
using std::pair;
/* used in findEntry() function */
#define SEARCH_IN_DESC (1)
#define SEARCH_IN_NAME (1 << 1)
#define SEARCH_IN_PW (1 << 2)
#define SEARCH_IN_COMMENT (1 << 3)
#define SEARCH_IN_URL (1 << 4)
#define SEARCH_IN_LAUNCHER (1 << 5)
#define SEARCH_IN_ALL (SEARCH_IN_DESC | SEARCH_IN_NAME | \
SEARCH_IN_PW | SEARCH_IN_COMMENT | \
SEARCH_IN_URL | SEARCH_IN_LAUNCHER)
/** document deeplocked. Data is out for lunch to disk */
#define DOC_STAT_DEEPLOCKED (1)
/** encrypted document on disk is dirty. data has to go to disk. */
#define DOC_STAT_DISK_DIRTY (1 << 1)
/** we are using a chipcard to encrypt the data */
#define DOC_STAT_USE_CHIPCARD (1 << 2)
/** use "currentPw" to unlock. (This flag is set/unset by a timer) */
#define DOC_STAT_UNLOCK_WITHOUT_PW (1 << 3)
class PwMDoc;
class PwMView;
class QFile;
/* meta data for a PwMDataItem */
struct PwMMetaData
{
PwMMetaData()
: updateInt (0)
{ }
/** creation date of the PwMDataItem to which
* this meta data belongs.
*/
QDateTime create;
/** becomes valid on this date */
QDateTime valid;
/** expire date */
QDateTime expire;
/** update date (last updated at this date) */
QDateTime update;
/** update interval (in minutes). Time since the
* last update to remind the user to update the item.
* 0 disables.
*/
unsigned long updateInt;
//US ENH: enhancements of the filestructure
/* each entry gets a unique id assigned */
string uniqueid;
void clear()
{
create = QDateTime();
expire = QDateTime();
update = QDateTime();
updateInt = 0;
- uniqueid = KApplication::randomString(8);
+ uniqueid = KApplication::randomString(8).latin1();
}
inline bool isValid() const
{
if (valid.isNull())
return true;
return (valid < QDateTime::currentDateTime());
}
inline bool isExpired() const
{
if (expire.isNull())
return false;
return (expire < QDateTime::currentDateTime());
}
inline bool isUpdateIntOver() const
{
if (updateInt == 0 ||
update.isNull())
return false;
QDateTime d(update);
return (d.addSecs(updateInt * 60) < QDateTime::currentDateTime());
}
};
struct PwMDataItem
{
PwMDataItem()
: lockStat (true)
, listViewPos (-1)
, binary (false)
, rev (0)
{ }
/** password description */
string desc;
/** user-name */
string name;
/** the password itself */
string pw;
/** some comment */
string comment;
/** an URL string */
string url;
/** launcher. Can be executed as a system() command */
string launcher;
/** locking status. If locked (true), pw is not emitted through getEntry() */
bool lockStat;
/** position of this item in main "list-view"
* If -1, the position is not yet specified and should be appended to the list
*/
int listViewPos;
/** does this entry contain binary data? */
bool binary;
/** meta data for this data item. */
PwMMetaData meta;
/** data revision counter. This counter can be used
* to easily, efficiently determine if this data item
* has changed since some time.
* This counter is incremented on every update.
*/
unsigned int rev;
void clear(bool clearMeta = true)
{
/* NOTE: Don't use .clear() here to be
* backward compatible with gcc-2 (Debian Woody)
*/
desc = "";
name = "";
pw = "";
comment = "";
url = "";
launcher = "";
lockStat = true;
listViewPos = -1;
binary = false;
if (clearMeta)
meta.clear();
}
//US ENH: we need this operator to compare two items if we have no unique ids
//available. Generaly this happens before the first sync
bool PwMDataItem::operator==( const PwMDataItem &a ) const
{
//qDebug("oper==%s", a.desc.c_str());
if ( desc != a.desc ) return false;
if ( name != a.name ) return false;
if ( pw != a.pw ) return false;
if ( comment != a.comment ) return false;
if ( url != a.url ) return false;
if ( launcher != a.launcher ) return false;
//all other field will not be checked.
return true;
}
};
struct PwMCategoryItem
{
/** all PwMDataItems (all passwords) within this category */
vector<PwMDataItem> d;
/** category name/description */
string name;
void clear()
{
d.clear();
name = "";
}
};
struct PwMSyncItem
{
string syncName;
QDateTime lastSyncDate;
void clear()
{
lastSyncDate = QDateTime();
syncName = "";
}
};
struct PwMItem
{
vector<PwMCategoryItem> dta;
vector<PwMSyncItem> syncDta;
void clear()
{
dta.clear();
syncDta.clear();
}
};
/** "Function Object" for sort()ing PwMDataItem::listViewPos */
class dta_lvp_greater
{
public:
bool operator() (const pair<unsigned int, unsigned int> &d1,
const pair<unsigned int, unsigned int> &d2)
{
return d1.second > d2.second;
}
};
/** list of PwMDoc documents and it's IDs */
class PwMDocList
{
public:
struct listItem
{
/** document filename (known as ID, here) */
string docId;
/** pointer to the document class */
PwMDoc *doc;
};
PwMDocList() {}
/** add a new item to the list */
void add(PwMDoc *doc, const string &id);
/** changes the contents of an existing item */
void edit(PwMDoc *doc, const string &newId);
/** remove the given item */
void del(PwMDoc *doc);
/** get the item at index */
listItem getAt(int index)
{ return docList[index]; }
/** find an entry with this id */
bool find(const string &id, listItem *ret = 0);
/** returns a copy of the list */
const vector<listItem>* getList() const
{ return &docList; }
/** returns a new unique number to extend the name of
* an unnamed document.
*/
static unsigned int getNewUnnamedNumber()
{ return unnamedDocCnt++; }
protected:
/* Hm, I think we shouldn't really use a "list" here, should we?
* So I decided to actually use a vector.
*/
vector<listItem> docList;
/** This value is used to get a new number for yet unnamed
* documents. It is incremented on every request. So it's
* theoretically possible to overflow it, but... :)
*/
static unsigned int unnamedDocCnt;
};
/** implements timers for the document */
class DocTimer : public QObject
{
Q_OBJECT
public:
enum TimerIDs
{
id_mpwTimer,
id_autoLockTimer,
id_metaCheckTimer
};
public:
DocTimer(PwMDoc *_doc);
~DocTimer();
/** start the timer */
void start(TimerIDs timer);
/** stop the timer */
void stop(TimerIDs timer);
/** get the lock for a timer.
* This lock is a recursive lock. When a lock is
* held, the timer will be stopped and timeout is
* guaranteed to not happen
*/
void getLock(TimerIDs timer);
/** put a recursive timer lock */
void putLock(TimerIDs timer);
protected slots:
/** timeout slot for the mpw timer */
void mpwTimeout();
/** timeout slot for the autoLock timer */
void autoLockTimeout();
/** timeout slot for the metaCheck timer */
void metaCheckTimeout();
protected:
/** pointer to the document associated with this timer. */
PwMDoc *doc;
/** timer object for mpw timer */
QTimer *mpwTimer;
/** timer object for the autoLock timer */
QTimer *autoLockTimer;
/** timer object for the metaCheck timer */
QTimer *metaCheckTimer;
/** lock counter for the mpw timer */
unsigned int mpwLock;
/** lock counter for the autoLock timer */
unsigned int autoLockLock;
/** lock counter for the metaCheck timer */
unsigned int metaCheckLock;
};
/** Document class for PwM */
//US ENH: derived from KSyncInterfaces, to get called by PwM when a sync is required.
// But PwMDoc is handling the sync by itself.
class PwMDoc : public PwMDocUi, public KSyncInterface
{
Q_OBJECT
friend class DocTimer;
public:
/** construtor */
PwMDoc(QObject* parent = 0, const char *name = 0);
/** destructor */
~PwMDoc();
/** returns a pointer to a list of all open documents */
static PwMDocList* getOpenDocList()
{ return &openDocList; }
/** flag document dirty. dta changed */
void flagDirty()
{
setDocStatFlag(DOC_STAT_DISK_DIRTY);
emitDataChanged(this);
}
/** modified? */
bool isDirty()
{ return getDocStatFlag(DOC_STAT_DISK_DIRTY); }
/** save document to disk */
PwMerror saveDoc(char compress, const QString *file = 0);
/** read document from file.
* "openLocked is must be set to either of these values:
* 0 == open with all entries unlocked
* 1 == open with all entries locked
* 2 == open deep-locked
*/
PwMerror openDoc(const QString *file, int openLocked);
/** export document to ascii-textfile */
PwMerror exportToText(const QString *file);
/** export document to gpasman / kpasman file */
PwMerror exportToGpasman(const QString *file);
/** import document from ascii-textfile */
PwMerror importFromText(const QString *file, int format = -1);
/** import document from gpasman / kpasman file */
PwMerror importFromGpasman(const QString *file);
/** add new entry */
PwMerror addEntry(const QString &category, PwMDataItem *d,
bool dontFlagDirty = false, bool updateMeta = true);
/** add new category. This function doesn't flag the document dirty! */
PwMerror addCategory(const QString &category, unsigned int *categoryIndex,
bool checkIfExist = true);
/** rename an existing category */
bool renameCategory(const QString &category, const QString &newName);
/** rename an existing category */
bool renameCategory(unsigned int category, const QString &newName,
bool dontFlagDirty = false);
/** delete an existing category */
bool delCategory(const QString &category);
/** delete an existing category */
bool delCategory(unsigned int category, bool dontFlagDirty = false);
/** returns a list of all category-names */
void getCategoryList(vector<string> *list);
/** returns a list of all category-names */
void getCategoryList(QStringList *list);
/** returns a list of all entry-descs in the given category */
void getEntryList(const QString &category, QStringList *list);
/** returns a list of all entry-descs in the given category */
void getEntryList(const QString &category, vector<string> *list);
/** returns a list of all entry-descs in the given category */
void getEntryList(unsigned int category, vector<string> *list);
/** returns a list of all entry-descs in the given category */
void getEntryList(unsigned int category, QStringList *list);
/** delete entry */
bool delEntry(const QString &category, unsigned int index, bool dontFlagDirty = false);
/** delete entry */
bool delEntry(unsigned int category, unsigned int index, bool dontFlagDirty = false);
/** edit entry */
bool editEntry(const QString &oldCategory, const QString &newCategory,
unsigned int index, PwMDataItem *d, bool updateMeta = true);
/** edit entry */
bool editEntry(unsigned int oldCategory, const QString &newCategory,
unsigned int index, PwMDataItem *d, bool updateMeta = true);
/** finds the category with the "name" and return it's index */
bool findCategory(const QString &name, unsigned int *index);
/** search for an entry "find" and check while searching only for
* the data-fields specified by "searchIn". To set the "searchIn"
* value, we may use one or more of the SEARCH_IN_* defines at
* the top of this header-file. It returns the positions of all
* matched entries in "foundPositions". If "breakAfterFound" is true,
* the function terminates after the first occurence of the entry
* and doesn't go on searching. So foundPositions->size() is never
* > 1 if breakAfterFound is true.
*/
void findEntry(unsigned int category, PwMDataItem find, unsigned int searchIn,
vector<unsigned int> *foundPositions, bool breakAfterFound = false,
bool caseSensitive = true, bool exactWordMatch = true,
bool sortByLvp = false);
/** see the above funtion. This function allows to set the category by name. */
void findEntry(const QString &category, PwMDataItem find, unsigned int searchIn,
vector<unsigned int> *foundPositions, bool breakAfterFound = false,
bool caseSensitive = true, bool exactWordMatch = true,
bool sortByLvp = false);
/** returns number of entries */
unsigned int numEntries(const QString &category);
unsigned int numEntries(unsigned int category)
{ return dti.dta[category].d.size(); }
/** returns number of categories */
unsigned int numCategories()
{ return dti.dta.size(); }
/** returns the name of the category at "index" */
const string* getCategory(unsigned int index)
{ return (&(dti.dta[index].name)); }
/** returns the data of item at "index".
* It unlocks the entry if it's locked and unlockIfLocked is true.
* If the entry is locked, but unlockIfLocked is false, it'll not return
* the pw.
*/
bool getEntry(const QString &category, unsigned int index,
PwMDataItem *d, bool unlockIfLocked = false);
bool getEntry(unsigned int category, unsigned int index,
PwMDataItem *d, bool unlockIfLocked = false);
/** returns the comment-string by looking at the category
* and the listViewPos
*/
PwMerror getCommentByLvp(const QString &category, int listViewPos,
string *foundComment);
/** checks if a password is already available. (currentPw) */
bool isPwAvailable()
{ return (currentPw != ""); }
/** un/lock entry at "index". If needed, ask for password. */
bool lockAt(const QString &category, unsigned int index,
bool lock = true);
bool lockAt(unsigned int category, unsigned int index,
bool lock = true);
/** returns the lock-status at "index" */