summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-10-18 02:55:13 (UTC)
committer ulf69 <ulf69>2004-10-18 02:55:13 (UTC)
commit2fd3f09238a624b1a91793d43b5f3653e2b34763 (patch) (side-by-side diff)
tree07cff893e261ad594ff44d7ab2e8e457a88d6390
parent4e7fac5fdb4c0dace10cada64f036c56bb29fe58 (diff)
downloadkdepimpi-2fd3f09238a624b1a91793d43b5f3653e2b34763.zip
kdepimpi-2fd3f09238a624b1a91793d43b5f3653e2b34763.tar.gz
kdepimpi-2fd3f09238a624b1a91793d43b5f3653e2b34763.tar.bz2
*** empty log message ***
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--bin/kdepim/pwmanager/pwmanagerFAQ.txt38
-rw-r--r--pwmanager/pwmanager/pwm.cpp57
-rw-r--r--pwmanager/pwmanager/pwm.h8
-rw-r--r--pwmanager/pwmanager/pwmdoc.cpp85
-rw-r--r--pwmanager/pwmanager/pwmdoc.h37
-rw-r--r--pwmanager/pwmanager/pwmview.cpp92
-rw-r--r--pwmanager/pwmanager/pwmview.h25
-rw-r--r--pwmanager/pwmanager/serializer.cpp86
8 files changed, 300 insertions, 128 deletions
diff --git a/bin/kdepim/pwmanager/pwmanagerFAQ.txt b/bin/kdepim/pwmanager/pwmanagerFAQ.txt
index 7bfe368..a28f07b 100644
--- a/bin/kdepim/pwmanager/pwmanagerFAQ.txt
+++ b/bin/kdepim/pwmanager/pwmanagerFAQ.txt
@@ -1,9 +1,17 @@
Q:
-What is PWM/Pi
+What is PWM/Pi?
Q:
For which platform is PWM/Pi available?
Q:
-Can I exchange the password files from PWM/Pi and PwManager
+Can I exchange the password files from PWM/Pi and PwManager?
+Q:
+Does Export/Import keep sync information in place?
+Q:
+Can PWM/Pi sync categories?
+Q:
+Which crypto, hash and compress algorithm is applied to the remote file
+while syncing?
+
*************************************************************************
Q:
@@ -32,8 +40,30 @@ to 1.0.1 of PwManager.
However, Michael will integrate our changes into a PwManager release
1.1, and the password files of that release will then be interchangable
with PWM/Pi
-
-
+*************************************************************************
+Q:
+Does Export/Import keep sync information in place
+A:
+Exporting data from PwManager removes all sync related information
+(Meta information) from the data. Because of that, a subsequent import
+results in "new" entries that will be handled as new entries when
+syncing them with an existing password file.
+*************************************************************************
+Q:
+Can PWM/Pi sync categories?
+A:
+No. PWM/Pi does not sync categories. It syncs all pw entries of the file
+without checking for the entries categories.
+A sync operation does not move modified entries from one category to another.
+Only if the sync operation has to create a new pw entry, it checks for the
+existance of the category and creates it if not existent.
+*************************************************************************
+Q:
+Which crypto, hash and compress algorithm is applied to the remote file
+while syncing?
+A: The sync operation applies the local crypt, hash and compress algorithm
+to both, the local and remote copy of the passwordfile and with thus
+overwrites the settings of the remote PwManager application.
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp
index 014e809..57b4432 100644
--- a/pwmanager/pwmanager/pwm.cpp
+++ b/pwmanager/pwmanager/pwm.cpp
@@ -132,7 +132,8 @@ enum {
enum {
BUTTON_POPUP_HELP_LICENSE = 0,
BUTTON_POPUP_HELP_FAQ,
- BUTTON_POPUP_HELP_ABOUT
+ BUTTON_POPUP_HELP_ABOUT,
+ BUTTON_POPUP_HELP_SYNC
};
#endif
@@ -156,7 +157,7 @@ enum {
PwM::PwM(PwMInit *_init, PwMDoc *doc,
bool virginity,
QWidget *parent, const char *name)
- : KMainWindow(parent, name)
+ : KMainWindow(parent, "HALLO")
, forceQuit (false)
, forceMinimizeToTray (false)
{
@@ -358,6 +359,10 @@ void PwM::initMenubar()
SLOT(createAboutData_slot()), 0,
BUTTON_POPUP_HELP_ABOUT);
+ helpPopup->insertItem(i18n("&Sync HowTo"), this,
+ SLOT(syncHowTo_slot()), 0,
+ BUTTON_POPUP_HELP_SYNC);
+
#endif
menuBar()->insertItem(i18n("&Help"), helpPopup);
@@ -609,6 +614,12 @@ void PwM::addPwd_slot(QString *pw, PwMDoc *_doc)
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();
@@ -619,14 +630,14 @@ void PwM::addPwd_slot(QString *pw, PwMDoc *_doc)
if (ret == e_entryExists) {
KMessageBox::error(this,
i18n
- ("An entry with this \"Description\", "
+ ("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 entries "
- "has been reached. You can't add more entries."),
+ 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;
@@ -1287,6 +1298,13 @@ void PwM::faq_slot()
KApplication::showFile( "PWM/Pi FAQ", "kdepim/pwmanager/pwmanagerFAQ.txt" );
}
+void PwM::syncHowTo_slot()
+{
+ qDebug("PwM::syncHowTo_slot");
+ KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
+}
+
+
void PwM::createAboutData_slot()
{
QString version;
@@ -1326,37 +1344,18 @@ bool PwM::sync(KSyncManager* manager, QString filename, int mode)
bool ret = curDoc()->sync(manager, filename, mode);
+ qDebug("PwM::sync save now: ret=%i", ret);
+
if (ret == true) {
//US BUG: what can we call here to update the view of the current doc?
//mViewManager->refreshView();
- }
-
- return ret;
-}
-//called by the syncmanager to indicate that the work has to be marked as dirty.
-void PwM::sync_setModified()
-{
- PWM_ASSERT(curDoc());
- curDoc()->sync_setModified();
-}
-
-//called by the syncmanager to ask if the dirty flag is set.
-bool PwM::sync_isModified()
-{
- PWM_ASSERT(curDoc());
- return curDoc()->sync_isModified();
+ //US curDoc()->sync sets the dirtyFlag in case the sync was successfull.
+ save();
}
-//called by the syncmanager to indicate that the work has to be saved.
-void PwM::sync_save()
-{
- PWM_ASSERT(curDoc());
- return curDoc()->sync_save();
+ return ret;
}
-
-
-
#endif
diff --git a/pwmanager/pwmanager/pwm.h b/pwmanager/pwmanager/pwm.h
index 7c6bf0d..6ed9d34 100644
--- a/pwmanager/pwmanager/pwm.h
+++ b/pwmanager/pwmanager/pwm.h
@@ -177,6 +177,7 @@ public slots:
void showLicense_slot();
void faq_slot();
void createAboutData_slot();
+ void syncHowTo_slot();
#endif
protected:
@@ -272,13 +273,6 @@ protected:
//this are the overwritten callbackmethods from the syncinterface
virtual bool sync(KSyncManager* manager, QString filename, int mode);
- //called by the syncmanager to indicate that the work has to marked as dirty.
- virtual void sync_setModified();
- //called by the syncmanager to ask if the dirty flag is set.
- virtual bool sync_isModified();
- //called by the syncmanager to indicate that the work has to be saved.
- virtual void sync_save();
-
// LR *******************************
// sync stuff!
QPopupMenu *syncPopup;
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp
index 0ac5517..2a7b11d 100644
--- a/pwmanager/pwmanager/pwmdoc.cpp
+++ b/pwmanager/pwmanager/pwmdoc.cpp
@@ -487,7 +487,8 @@ PwMerror PwMDoc::saveDoc(char compress, const QString *file)
}
}
ret = e_success;
- printDebug(string("writing file { compress: ")
+ printDebug(string("writing file { name: ")
+ + filename.latin1() + " compress: "
+ tostr(static_cast<int>(compress)) + " cryptAlgo: "
+ tostr(static_cast<int>(cryptAlgo)) + " hashAlgo: "
+ tostr(static_cast<int>(hashAlgo))
@@ -605,7 +606,9 @@ PwMerror PwMDoc::writeFileHeader(char keyHash, char dataHash, char crypt, char c
{
PWM_ASSERT(pw);
PWM_ASSERT(f);
- PWM_ASSERT(listView);
+ //US ENH: or maybe a bug: checking here for listView does not make sense because we do not check anywhere else
+ //Wenn I sync, I open a doc without a view => listView is 0 => Assertion
+ //US PWM_ASSERT(listView);
if (f->writeBlock(FILE_ID_HEADER, strlen(FILE_ID_HEADER)) !=
static_cast<Q_LONG>(strlen(FILE_ID_HEADER))) {
return e_writeFile;
@@ -2804,10 +2807,19 @@ void PwMDoc::ensureLvp()
if (isDocEmpty())
return;
+ //US ENH BUG: when using syncronizing, this way of sorting
+ //is not sufficient, because there might be empty spaces
+ // at the beginning. But this algorythm only can add elements
+ //to the end.The result are crashes because of listoverflows
+ //we need something to fill all gaps.
vector< vector<PwMDataItem>::iterator > undefined;
+ vector< vector<PwMDataItem>::iterator > sorted;
vector< vector<PwMDataItem>::iterator >::iterator undefBegin,
undefEnd,
undefI;
+ vector< vector<PwMDataItem>::iterator >::iterator sortedBegin,
+ sortedEnd,
+ sortedI;
vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(),
catEnd = dti.dta.end(),
catI = catBegin;
@@ -2826,10 +2838,24 @@ void PwMDoc::ensureLvp()
tmpLvp = entrI->listViewPos;
if (tmpLvp == -1)
undefined.push_back(entrI);
- else if (tmpLvp > lvpTop)
- lvpTop = tmpLvp;
+ else
+ sorted[tmpLvp] = entrI;
+ //US else if (tmpLvp > lvpTop)
+ //US lvpTop = tmpLvp;
++entrI;
}
+
+ //now we have all undefied in the collection. Now insert the existing
+ sortedBegin = sorted.begin();
+ sortedEnd = sorted.end();
+ sortedI = sortedBegin;
+
+ while (sortedI != sortedEnd) {
+ tmpLvp = (*sortedI)->listViewPos;
+ undefined[tmpLvp] = *sortedI;
+ ++sortedI;
+ }
+
undefBegin = undefined.begin();
undefEnd = undefined.end();
undefI = undefBegin;
@@ -2848,6 +2874,16 @@ QString PwMDoc::getTitle()
* this document is valid (open).
*/
QString title(getFilename());
+
+ //US ENH: The whole filename on PDAs is too long. So use only the last characters
+ if (QApplication::desktop()->width() < 640)
+ {
+ if (title.length() > 30)
+ title = "..." + title.right(30);
+
+ }
+
+
if (title.isEmpty()) {
if (unnamedNum == 0) {
unnamedNum = PwMDocList::getNewUnnamedNumber();
@@ -2927,7 +2963,7 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s
}
syncItemLocal = syncLocal->getSyncDataEntry(index);
- qDebug("Last Sync %s ", syncItemLocal->lastSyncDate.toString().latin1());
+ 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);
@@ -2947,6 +2983,7 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s
}
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);
@@ -2959,8 +2996,8 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s
if ( ! fullDateRange ) {
if ( syncItemLocal->lastSyncDate != syncItemRemote->lastSyncDate ) {
- // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
- //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
+ // qDebug("set fulldate to true %s %s" ,syncItemLocal->lastSyncDate.toString().latin1(), syncItemRemote->lastSyncDate.toString().latin1() );
+ // qDebug("%d %d %d %d ", syncItemLocal->lastSyncDate.time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
fullDateRange = true;
qDebug("FULLDATE 3 %s %s", syncItemLocal->lastSyncDate.toString().latin1() , syncItemRemote->lastSyncDate.toString().latin1() );
}
@@ -2973,7 +3010,7 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s
qDebug("*************************** ");
- // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
+ qDebug("mLastSync %s ",mLastSync.toString().latin1() );
QStringList er = syncRemote->getIDEntryList();
PwMDataItem* inRemote ;//= er.first();
PwMDataItem* inLocal;
@@ -3001,7 +3038,7 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s
PWM_ASSERT(inRemote);
if ( inLocal != 0 ) { // maybe conflict - same uid in both files
if ( (take = takePwMDataItem( inLocal, inRemote, mLastSync, mode, fullDateRange) ) ) {
- //qDebug("take %d %s ", take, inL.summary().latin1());
+ qDebug("take %d %s ", take, inLocal->desc.c_str());
if ( take == 3 )
return e_syncError;
if ( take == 1 ) {// take local
@@ -3052,6 +3089,7 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s
if ( incCounter % modulo == 0 )
manager->showProgressBar(incCounter);
uid = el[ incCounter ];
+ qDebug("sync uid %s from local file", uid.latin1());
inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal );
inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote );
@@ -3132,16 +3170,16 @@ int PwMDoc::takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime
//qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod);
//qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
- //full = true; //debug only
+ full = true; //debug only
if ( full ) {
- bool equ = true;//US ( (*local) == (*remote) );
+ bool equ = ( (*local) == (*remote) );
if ( equ ) {
- //qDebug("equal ");
+ qDebug("equal ");
if ( mode < SYNC_PREF_FORCE_LOCAL )
return 0;
- }//else //debug only
- //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
+ }else //debug only
+ qDebug("not equal %s %s ", local->desc.c_str(), remote->desc.c_str());
}
int result;
@@ -3215,7 +3253,7 @@ bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode)
return false;
}
- //2) construct and open a new doc on the stack(automatic cleanup) for remote file.
+ //2) construct and open a new doc on the stack(automatic cleanup of remote file).
PwMDoc syncTarget(this, "synctarget");
PwMDoc* pSyncTarget = &syncTarget;
@@ -3267,23 +3305,6 @@ bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode)
}
}
-//called by the syncmanager to indicate that the work has to marked as dirty.
-void PwMDoc::sync_setModified()
-{
- flagDirty();
-}
-
-//called by the syncmanager to ask if the dirty flag is set.
-bool PwMDoc::sync_isModified()
-{
- return isDirty();
-}
-
-//called by the syncmanager to indicate that the work has to be saved.
-void PwMDoc::sync_save()
-{
- saveDoc(conf()->confGlobCompression());
-}
#endif
diff --git a/pwmanager/pwmanager/pwmdoc.h b/pwmanager/pwmanager/pwmdoc.h
index 2e9547e..6a1dd30 100644
--- a/pwmanager/pwmanager/pwmdoc.h
+++ b/pwmanager/pwmanager/pwmdoc.h
@@ -130,16 +130,6 @@ struct PwMMetaData
uniqueid = KApplication::randomString(8);
}
- PwMMetaData& operator = (const PwMMetaData& x)
- {
- create = x.create;
- expire = x.expire;
- update = x.update;
- updateInt = x.updateInt;
- uniqueid = x.uniqueid;
- return *this;
- }
-
inline bool isValid() const
{
if (valid.isNull())
@@ -217,10 +207,26 @@ struct PwMDataItem
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;
+ }
+ //US ENH:this operator is used to copy an elements data during syncronization
+ //Attention: listViewPos will not be copied. So the position will stay the same.
PwMDataItem& operator = (const PwMDataItem& x)
{
- qDebug("oper=%s", x.desc.c_str());
+ // qDebug("oper=%s", x.desc.c_str());
desc = x.desc;
name = x.name;
pw = x.pw;
@@ -228,7 +234,7 @@ struct PwMDataItem
url = x.url;
launcher = x.launcher;
lockStat = x.lockStat;
- listViewPos = x.listViewPos;
+ //Do not copy listViewPos!!! listViewPos = x.listViewPos;
binary = x.binary;
meta = x.meta;
rev = x.rev;
@@ -774,13 +780,6 @@ protected:
//the following methods are the overwritten callbackmethods from the syncinterface
virtual bool sync(KSyncManager* manager, QString filename, int mode);
- //called by the syncmanager to indicate that the work has to be marked as dirty.
- virtual void sync_setModified();
- //called by the syncmanager to ask if the dirty flag is set.
- virtual bool sync_isModified();
- //called by the syncmanager to indicate that the work has to be saved.
- virtual void sync_save();
-
#endif
private:
//US ENH: helpermethods to access the sync data for a certain syncname.
diff --git a/pwmanager/pwmanager/pwmview.cpp b/pwmanager/pwmanager/pwmview.cpp
index e23ce25..e53124f 100644
--- a/pwmanager/pwmanager/pwmview.cpp
+++ b/pwmanager/pwmanager/pwmview.cpp
@@ -456,11 +456,91 @@ void PwMView::copyCommentToClip()
PwM::copyToClipboard(d.comment.c_str());
}
+/************************************************************************
+ *
+ *
+ *
+ ************************************************************************/
+
+
+PwMDataItemView::PwMDataItemView( QWidget *parent, const char *name )
+ : QTextBrowser( parent, name )
+
+
+{
+//US setWrapPolicy( QTextEdit::AtWordBoundary );
+ setLinkUnderline( false );
+ // setVScrollBarMode( QScrollView::AlwaysOff );
+ //setHScrollBarMode( QScrollView::AlwaysOff );
+
+//US QStyleSheet *sheet = styleSheet();
+//US QStyleSheetItem *link = sheet->item( "a" );
+//US link->setColor( KGlobalSettings::linkColor() );
+
+}
+
+void PwMDataItemView::setPwMDataItem( const PwMDataItem& a )
+
+{
+ mItem = a;
+ // clear view
+ setText( QString::null );
+
+
+ QString dynamicPart;
+ QString format = "<tr><td align=\"right\"><b>%1</b></td>"
+ "<td align=\"left\">%2</td></tr>";
+
+ dynamicPart += format
+ .arg( i18n("Description") )
+ .arg( mItem.desc.c_str() );
+ dynamicPart += format
+ .arg( i18n("Name") )
+ .arg( mItem.name.c_str() );
+
+ dynamicPart += format
+ .arg( i18n("Password") )
+ .arg( mItem.pw.c_str() );
+
+ QString comment(mItem.pw.c_str());
+ dynamicPart += format
+ .arg( i18n("Comment") )
+ .arg( comment.replace( QRegExp("\n"), "<br>" ) );
+
+ dynamicPart += format
+ .arg( i18n("URL") )
+ .arg( mItem.url.c_str() );
+
+ dynamicPart += format
+ .arg( i18n("Launcher") )
+ .arg( mItem.launcher.c_str() );
+
+ QString mText = "<table><td colspan=\"2\">&nbsp;</td>";
+
+ mText += dynamicPart;
+ mText += "</table>";
+
+ // at last display it...
+ setText( mText );
+
+}
+
+PwMDataItem PwMDataItemView::pwmdataitem() const
+{
+ return mItem;
+}
+
+/************************************************************************
+ *
+ *
+ *
+ ************************************************************************/
-PwMDataItemChooser::PwMDataItemChooser( PwMDataItem loc, PwMDataItem rem, bool takeloc, QWidget *parent, const char *name ) : KDialogBase(parent,name,
- true ,i18n("Conflict! Please choose Entry!"),Ok|User1|Close,Close, false)
+PwMDataItemChooser::PwMDataItemChooser( PwMDataItem loc, PwMDataItem rem, bool takeloc, QWidget *parent, const char *name )
+ : KDialogBase(parent, name, true ,
+ i18n("Conflict! Please choose Entry!"),Ok|User1|Close,Close, false)
{
findButton( Close )->setText( i18n("Cancel Sync"));
findButton( Ok )->setText( i18n("Remote"));
@@ -478,15 +558,15 @@ PwMDataItemChooser::PwMDataItemChooser( PwMDataItem loc, PwMDataItem rem, bool t
QLabel* lab = new QLabel( i18n("Local Entry"), subframe );
if ( takeloc )
lab->setBackgroundColor(Qt::green.light() );
- // AddresseeView * av = new AddresseeView( subframe );
- // av->setAddressee( loc );
+ PwMDataItemView * av = new PwMDataItemView( subframe );
+ av->setPwMDataItem( loc );
subframe = new QVBox( topframe );
bl->addWidget(subframe );
lab = new QLabel( i18n("Remote Entry"), subframe );
if ( !takeloc )
lab->setBackgroundColor(Qt::green.light() );
- // av = new AddresseeView( subframe );
- // av->setAddressee( rem );
+ av = new PwMDataItemView( subframe );
+ av->setPwMDataItem( rem );
QObject::connect(findButton( Ok ),SIGNAL(clicked()),this, SLOT(slot_remote()));
QObject::connect(this,SIGNAL(user1Clicked()),this, SLOT(slot_local()));
#ifndef DESKTOP_VERSION
diff --git a/pwmanager/pwmanager/pwmview.h b/pwmanager/pwmanager/pwmview.h
index 75cce51..e42b17a 100644
--- a/pwmanager/pwmanager/pwmview.h
+++ b/pwmanager/pwmanager/pwmview.h
@@ -41,6 +41,7 @@
#include <qevent.h>
#include <qfont.h>
#include <qobject.h>
+#include <qtextbrowser.h>
#include <vector>
#include <string>
@@ -149,6 +150,30 @@ private:
};
+//US ENH basic widget to view an password entry. We need it for the sync stuff.
+//But might be oif interest for other functionalities as well.
+class PwMDataItemView : public QTextBrowser
+{
+ public:
+ PwMDataItemView( QWidget *parent = 0, const char *name = 0 );
+
+ /**
+ Sets the PwMDataItem object. It is displayed immediately.
+
+ @param a The PwMDataItem object.
+ */
+ void setPwMDataItem( const PwMDataItem& a );
+
+ /**
+ Returns the current PwMDataItem object.
+ */
+ PwMDataItem pwmdataitem() const;
+
+ private:
+ PwMDataItem mItem;
+};
+
+
//US ENH we need this chooser when syncing results in a conflict
class PwMDataItemChooser : public KDialogBase
{
diff --git a/pwmanager/pwmanager/serializer.cpp b/pwmanager/pwmanager/serializer.cpp
index 203f82c..5c6568f 100644
--- a/pwmanager/pwmanager/serializer.cpp
+++ b/pwmanager/pwmanager/serializer.cpp
@@ -27,7 +27,7 @@
#endif
/* enable/disable serializer debugging (0/1) */
-#define SERIALIZER_DEBUG 0
+#define SERIALIZER_DEBUG 1
/* use the old xml tags for writing (0/1) */
#define USE_OLD_TAGS 0
/* write a CDATA section (0/1) */
@@ -304,6 +304,10 @@ bool Serializer::readEntries(const QDomNode &n,
QDomNode cur;
unsigned int numEntr = nl.count(), i;
PwMDataItem curEntr;
+ //US BUG: to initialize all values of curEntr with meaningfulldata,
+ // we call clear on it. Reason: Information in the file we will read might be incomplete.
+ // e.g. the metadata is missing.
+ curEntr.clear(true);
dta->clear();
for (i = 0; i < numEntr; ++i) {
@@ -401,36 +405,42 @@ bool Serializer::extractMeta(const QDomNode &n,
cur = cur.nextSibling();
continue;
}
+
+ //US BUG: The transformation of an empty date into an ISO date and back is different on different systems/compilers.
+ //because of that it is possible that here some values are not set, which means they are null.
+ //US ENH: at the same moment we need backwardcompatibility. So older versions might have stored invalid dates.
+
+ QDateTime dtval; //dtval should be invalid by definition.
+
+ if ((name == META_CREATE_DATE) ||
+ (name == META_VALID_DATE) ||
+ (name == META_EXPIRE_DATE) ||
+ (name == META_UPDATE_DATE))
+ {
+ //qDebug("Serializer::extractMeta:: val:%s, empty:%i, length:%i",val.utf8(), val.isEmpty(), val.length());
+
#ifndef PWM_EMBEDDED
- if (name == META_CREATE_DATE) {
- dta->create = QDateTime::fromString(val, Qt::ISODate);
- } else if (name == META_VALID_DATE) {
- dta->valid = QDateTime::fromString(val, Qt::ISODate);
- } else if (name == META_EXPIRE_DATE) {
- dta->expire = QDateTime::fromString(val, Qt::ISODate);
- } else if (name == META_UPDATE_DATE) {
- dta->update = QDateTime::fromString(val, Qt::ISODate);
- } else if (name == META_UPDATE_INT) {
- dta->updateInt = strtoul(val.latin1(), 0, 10);
- } else if (name == META_UNIQUEID) {
- dta->uniqueid = unescapeEntryData(val).latin1();
- } else {
- printDebug(string("extractMeta(): invalid: ")
- + name.latin1());
- }
+ dtval = QDateTime::fromString(val, Qt::ISODate);
#else
+ bool ok;
+ dtval = KGlobal::locale()->readDateTime(val, KLocale::ISODate, &ok);
+
+ if (ok == false)
+ qDebug("Serializer::extractMeta invalid date or time !!!!!!!!!!!!!");
+#endif
+ //if the parsed data is wrong, dtval should be invalid at this time.
- bool ok = true;
+ }
if (name == META_CREATE_DATE) {
- dta->create = KGlobal::locale()->readDateTime(val, KLocale::ISODate, &ok);
+ dta->create = dtval;
} else if (name == META_VALID_DATE) {
- dta->valid = KGlobal::locale()->readDateTime(val, KLocale::ISODate, &ok);
+ dta->valid = dtval;
} else if (name == META_EXPIRE_DATE) {
- dta->expire = KGlobal::locale()->readDateTime(val, KLocale::ISODate, &ok);
+ dta->expire = dtval;
} else if (name == META_UPDATE_DATE) {
- dta->update = KGlobal::locale()->readDateTime(val, KLocale::ISODate, &ok);
+ dta->update = dtval;
} else if (name == META_UPDATE_INT) {
dta->updateInt = strtoul(val.latin1(), 0, 10);
} else if (name == META_UNIQUEID) {
@@ -440,11 +450,6 @@ bool Serializer::extractMeta(const QDomNode &n,
+ name.latin1());
}
- if (ok == false)
- qDebug("Serializer::extractMeta invalid date or time !!!!!!!!!!!!!");
-
-
-#endif
cur = cur.nextSibling();
}
return true;
@@ -604,6 +609,10 @@ bool Serializer::writeMeta(QDomElement *e,
QDomText text;
QDomElement tag;
+ //US BUG!!!: The transformation of an empty date into an ISO date is different on different systems/compilers.
+ //So do not transform an empty value at all.
+ if (dta.create.isValid())
+ {
tag = domDoc->createElement(META_CREATE_DATE);
#ifndef PWM_EMBEDDED
text = domDoc->createTextNode(dta.create.toString(Qt::ISODate));
@@ -612,7 +621,12 @@ bool Serializer::writeMeta(QDomElement *e,
#endif
tag.appendChild(text);
e->appendChild(tag);
+ }
+ //US BUG!!!: The transformation of an empty date into an ISO date is different on different systems/compilers.
+ //So do not transform an empty value at all.
+ if (dta.valid.isValid())
+ {
tag = domDoc->createElement(META_VALID_DATE);
#ifndef PWM_EMBEDDED
text = domDoc->createTextNode(dta.valid.toString(Qt::ISODate));
@@ -621,7 +635,12 @@ bool Serializer::writeMeta(QDomElement *e,
#endif
tag.appendChild(text);
e->appendChild(tag);
+ }
+ //US BUG!!!: The transformation of an empty date into an ISO date is different on different systems/compilers.
+ //So do not transform an empty value at all.
+ if (dta.expire.isValid())
+ {
tag = domDoc->createElement(META_EXPIRE_DATE);
#ifndef PWM_EMBEDDED
text = domDoc->createTextNode(dta.expire.toString(Qt::ISODate));
@@ -630,7 +649,12 @@ bool Serializer::writeMeta(QDomElement *e,
#endif
tag.appendChild(text);
e->appendChild(tag);
+ }
+ //US BUG!!!: The transformation of an empty date into an ISO date is different on different systems/compilers.
+ //So do not transform an empty value at all.
+ if (dta.update.isValid())
+ {
tag = domDoc->createElement(META_UPDATE_DATE);
#ifndef PWM_EMBEDDED
text = domDoc->createTextNode(dta.update.toString(Qt::ISODate));
@@ -639,6 +663,7 @@ bool Serializer::writeMeta(QDomElement *e,
#endif
tag.appendChild(text);
e->appendChild(tag);
+ }
tag = domDoc->createElement(META_UPDATE_INT);
text = domDoc->createTextNode(tostr(dta.updateInt).c_str());
@@ -672,7 +697,7 @@ QString Serializer::unescapeEntryData(QString dta)
dta.replace("$>--endl--<$", "\n");
dta.replace("||>", "]]>");
#else
- dta.replace(QRegExp("$>--endl--<$"), "\n");
+ dta.replace(QRegExp("\\$>--endl--<\\$"), "\n");
dta.replace(QRegExp("||>"), "]]>");
#endif
return dta;
@@ -730,7 +755,7 @@ bool Serializer::addSyncData(QDomElement *e,
{
unsigned int numSync = dta.size(), i;
QString curId, curDeviceName;
- QDomElement curSync, curSyncDate;
+ QDomElement curSync;
QDomText text;
for (i = 0; i < numSync; ++i) {
@@ -745,8 +770,7 @@ bool Serializer::addSyncData(QDomElement *e,
#else
text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta[i].lastSyncDate, KLocale::ISODate));
#endif
- curSyncDate.appendChild(text);
- curSync.appendChild(curSyncDate);
+ curSync.appendChild(text);
e->appendChild(curSync);