summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-11-28 05:53:55 (UTC)
committer zautrix <zautrix>2005-11-28 05:53:55 (UTC)
commit29c3ed5181b8a33aac73eec90956819b71641048 (patch) (side-by-side diff)
tree8733a18a337b28545ccda5e178cab1b1977314d5
parentc09ac6c4c77ee1ed50cd9d86a6798eebdede3991 (diff)
downloadkdepimpi-29c3ed5181b8a33aac73eec90956819b71641048.zip
kdepimpi-29c3ed5181b8a33aac73eec90956819b71641048.tar.gz
kdepimpi-29c3ed5181b8a33aac73eec90956819b71641048.tar.bz2
sync
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--pwmanager/pwmanager/pwm.cpp4
-rw-r--r--pwmanager/pwmanager/pwm.h2
-rw-r--r--pwmanager/pwmanager/pwmdoc.cpp2
-rw-r--r--pwmanager/pwmanager/pwmdoc.h2
4 files changed, 5 insertions, 5 deletions
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp
index e12dc49..8373850 100644
--- a/pwmanager/pwmanager/pwm.cpp
+++ b/pwmanager/pwmanager/pwm.cpp
@@ -1472,128 +1472,128 @@ void PwM::category_slot()
w.setCurrCategory(view->getCurrentCategory());
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);
}
void PwM::whatsnew_slot()
{
KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
}
void PwM::showLicense_slot()
{
KApplication::showLicence();
}
void PwM::faq_slot()
{
KApplication::showFile( "PWM/Pi FAQ", "kdepim/pwmanager/pwmanagerFAQ.txt" );
}
void PwM::syncHowTo_slot()
{
KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
}
void PwM::createAboutData_slot()
{
QString version;
#include <../version>
;
QMessageBox::about( this, "About PwManager/Pi",
"PwManager/Platform-independent\n"
"(PWM/Pi) " +version + " - " +
#ifdef DESKTOP_VERSION
"Desktop Edition\n"
#else
"PDA-Edition\n"
"for: Zaurus 5500 / 7x0 / 8x0\n"
#endif
"(c) 2004 Ulf Schenk\n"
"(c) 2004 Lutz Rogowski\n"
"(c) 1997-2004, The KDE PIM Team\n"
"(c) Michael Buesch - main programming\nand current maintainer\nmbuesch@freenet.de\n"
"Matt Scifo - mscifo@o1.com\n"
"Elias Probst - elias.probst@gmx.de\n"
"George Staikos - staikos@kde.org\n"
"Matthew Palmer - mjp16@uow.edu.au\n"
"Olivier Sessink - gpasman@nl.linux.org\n"
"The libgcrypt developers -\nBlowfish and SHA1 algorithms\nftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/\n"
"Troy Engel - tengel@sonic.net\n"
"Wickey - wickey@gmx.at\n"
"Ian MacGregor - original documentation author.\n"
);
}
//this are the overwritten callbackmethods from the syncinterface
-bool PwM::sync(KSyncManager* manager, QString filename, int mode)
+bool PwM::sync(KSyncManager* manager, QString filename, int mode,QString resource)
{
PWM_ASSERT(curDoc());
- bool ret = curDoc()->sync(manager, filename, mode);
+ bool ret = curDoc()->sync(manager, filename, mode,resource);
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();
//US curDoc()->sync sets the dirtyFlag in case the sync was successfull.
save();
}
return ret;
}
void PwM::removeSyncInfo( QString syncProfile)
{
qDebug("PWM:removeSyncInfo for profile %s ", syncProfile.latin1());
curDoc()->removeSyncInfo( syncProfile );
//US curDoc()->removeSyncInfo sets the dirtyFlag.
}
#endif
#ifndef PWM_EMBEDDED
#include "pwm.moc"
#endif
diff --git a/pwmanager/pwmanager/pwm.h b/pwmanager/pwmanager/pwm.h
index 2d1b854..c4bbb4e 100644
--- a/pwmanager/pwmanager/pwm.h
+++ b/pwmanager/pwmanager/pwm.h
@@ -186,115 +186,115 @@ public slots:
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 */
void initToolbar();
/** initialize the window-metrics */
void initMetrics();
/** close-event */
void closeEvent(QCloseEvent *e);
/** creates a new PwM-ListView and returns it */
PwMView * makeNewListView(PwMDoc *doc);
/** Window hide-event */
void hideEvent(QHideEvent *);
/** is this window minimized? */
bool isMinimized()
{
#ifndef PWM_EMBEDDED
#if KDE_VERSION >= KDE_MAKE_VERSION(3, 2, 0)
return KWin::windowInfo(winId()).isMinimized();
#else // KDE_VERSION
return KWin::info(winId()).isIconified();
#endif // KDE_VERSION
#else
return false;
#endif
}
/** window got the focus */
void focusInEvent(QFocusEvent *e);
/** update the caption string */
void updateCaption();
#ifdef CONFIG_KWALLETIF
/** check if kwalletemu is enabled and ask the user what to do */
bool checkAndAskForKWalletEmu();
#endif // CONFIG_KWALLETIF
protected slots:
/** doc got closed */
void docClosed(PwMDoc *doc);
signals:
/** window got closed (by user or someone else) */
void closed(PwM *wnd);
/** window got the focus (was brought to foreground) */
void gotFocus(PwM *wnd);
/** window lost the focus */
void lostFocus(PwM *wnd);
protected:
/** pointer to the view active in this KMainWindow */
PwMView *view;
/** pointer to the init class */
PwMInit *init;
/** has this window already lost its virginity?
* Means is there an open working document
*/
bool virgin;
/** "file" popup-menu */
KPopupMenu *filePopup;
/** "manage" popup-menu */
KPopupMenu *managePopup;
#ifdef CONFIG_KEYCARD
/** "chipcard" popup-menu */
KPopupMenu *chipcardPopup;
#endif // CONFIG_KEYCARD
/** "view" popup-menu */
KPopupMenu *viewPopup;
/** "options" popup-menu */
KPopupMenu *optionsPopup;
/** "help" popup-menu */
KPopupMenu *helpPopup;
/** "export" popup-menu */
KPopupMenu *exportPopup;
/** "import" popup-menu */
KPopupMenu *importPopup;
/** force quit this window? */
bool forceQuit;
/** force minimize this window to the tray */
bool forceMinimizeToTray;
private:
#ifdef PWM_EMBEDDED
//this are the overwritten callbackmethods from the syncinterface
- virtual bool sync(KSyncManager* manager, QString filename, int mode);
+ virtual bool sync(KSyncManager* manager, QString filename, int mode,QString resource);
virtual void removeSyncInfo( QString syncProfile);
// LR *******************************
// sync stuff!
QPopupMenu *syncPopup;
KSyncManager* syncManager;
#endif
};
#endif
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp
index 1f3c58b..b58d7e2 100644
--- a/pwmanager/pwmanager/pwmdoc.cpp
+++ b/pwmanager/pwmanager/pwmdoc.cpp
@@ -3351,193 +3351,193 @@ int PwMDoc::takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime
//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
if ( full ) {
bool equ = ( (*local) == (*remote) );
if ( equ ) {
//qDebug("equal ");
if ( mode < SYNC_PREF_FORCE_LOCAL )
return 0;
}//else //debug only
//qDebug("not equal %s %s ", local->desc.c_str(), remote->desc.c_str());
}
int result;
bool localIsNew;
//qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
if ( full && mode < SYNC_PREF_NEWEST )
mode = SYNC_PREF_ASK;
switch( mode ) {
case SYNC_PREF_LOCAL:
if ( lastSync > remoteMod )
return 1;
if ( lastSync > localMod )
return 2;
return 1;
break;
case SYNC_PREF_REMOTE:
if ( lastSync > remoteMod )
return 1;
if ( lastSync > localMod )
return 2;
return 2;
break;
case SYNC_PREF_NEWEST:
if ( localMod > remoteMod )
return 1;
else
return 2;
break;
case SYNC_PREF_ASK:
//qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
if ( lastSync > remoteMod )
return 1;
if ( lastSync > localMod )
return 2;
localIsNew = localMod >= remoteMod;
//qDebug("conflict! ************************************** ");
{
PwMDataItemChooser acd ( *local,*remote, localIsNew , 0/*this*/ );
result = acd.executeD(localIsNew);
return result;
}
break;
case SYNC_PREF_FORCE_LOCAL:
return 1;
break;
case SYNC_PREF_FORCE_REMOTE:
return 2;
break;
default:
// SYNC_PREF_TAKE_BOTH not implemented
break;
}
return 0;
}
void PwMDoc::removeSyncInfo( QString syncProfile)
{
bool res, found;
unsigned int count, i;
if ( syncProfile.isEmpty() ) {
count = numSyncDataEntries();
for (i = count; count > 0; count-- ) {
res = delSyncDataEntry(i-1, false);
if (res == false) {
qDebug("PwMDoc::removeSyncInfo: could not remove syncprofile");
}
}
} else {
found = findSyncData(syncProfile, &count);
if (found == true)
{
res = delSyncDataEntry(count, false);
if (res == false) {
qDebug("PwMDoc::removeSyncInfo: could not remove %s", syncProfile.latin1());
}
}
}
}
//this are the overwritten callbackmethods from the syncinterface
-bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode)
+bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode, QString resource)
{
QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
//1) unlock local file first if necessary (ask for password)
if (this->isDeepLocked()) {
PwMerror ret = this->deepLock(false);
if (ret != e_success)
return false;
}
//2) construct and open a new doc on the stack(automatic cleanup of remote file).
PwMDoc syncTarget(this, "synctarget");
PwMDoc* pSyncTarget = &syncTarget;
PwMerror err = pSyncTarget->openDoc(&filename, 1 /*== open with all entries locked*/);
if (err == e_alreadyOpen) {
PwMDocList::listItem li;
if (getOpenDocList()->find(filename.latin1(), &li))
pSyncTarget = li.doc;
else {
qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1());
return false;
}
}
else if (err != e_success) {
qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1());
return false;
}
qDebug("PWM file loaded %s,sync mode %d",filename.latin1(), mode );
//3) unlock remote file first if necessary (ask for password)
if (pSyncTarget->isDeepLocked()) {
PwMerror ret = pSyncTarget->deepLock(false);
if (ret != e_success)
return false;
}
err = syncronize(manager, this, pSyncTarget, mode );
if (err == e_success) {
if ( manager->mWriteBackFile ) {
qDebug("Saving remote PWManager file");
err = pSyncTarget->saveDoc(conf()->confGlobCompression());
if (err != e_success) {
qDebug("PwmDoc::sync: Sync failed. Error %i while storing file %s",err, filename.latin1());
return false;
}
}
flagDirty();
return true;
}
else {
return false;
}
}
#endif
bool PwMDoc::findSyncData(const QString &syncname, unsigned int *index)
{
vector<PwMSyncItem>::iterator i = dti.syncDta.begin(),
end = dti.syncDta.end();
while (i != end) {
if ((*i).syncName == syncname.latin1()) {
if (index) {
*index = i - dti.syncDta.begin();
}
return true;
}
++i;
}
return false;
};
/** add new syncdataentry */
PwMerror PwMDoc::addSyncDataEntry(PwMSyncItem *d, bool dontFlagDirty)
{
PWM_ASSERT(d);
if (isDeepLocked()) {
PwMerror ret;
ret = deepLock(false);
if (ret != e_success)
return e_lock;
}
unsigned int index;
const QString tmp = d->syncName.c_str();
diff --git a/pwmanager/pwmanager/pwmdoc.h b/pwmanager/pwmanager/pwmdoc.h
index 45dd729..144831f 100644
--- a/pwmanager/pwmanager/pwmdoc.h
+++ b/pwmanager/pwmanager/pwmdoc.h
@@ -703,131 +703,131 @@ protected:
/** pointer to the list-view, using this document.
* As there can only be one list-view per doc, we
* don't need a list here.
*/
PwMView *listView;
/** unnamedNum is used to store the "unnamed counter"
* for this document, while it's unnamed. If it's 0,
* we have to get a new unique one.
*/
unsigned int unnamedNum;
/** is this doc going to be deleted (executing in destructor context) */
bool deleted;
/** document timer */
DocTimer *_timer;
/** lock counter for the "dataChanged" signal */
unsigned int dataChangedLock;
/** list of all open documents */
static PwMDocList openDocList;
protected:
/** serialize "dta" and return it in "d". */
bool serializeDta(string *d);
/** de-serialize "d" and overwrite "dta" */
bool deSerializeDta(const string *d, bool entriesLocked);
/** write header to file */
PwMerror writeFileHeader(char keyHash, char dataHash, char crypt, char compress,
QString *pw, QFile *f);
/** write data-hash to file */
PwMerror writeDataHash(char dataHash, string *d, QFile *f);
/** check header. Read header info and verify key-hash and filever.
* returns length of header in "headerLength" */
PwMerror checkHeader(char *cryptAlgo, QString *pw, char *compress,
unsigned int *headerLength, char *dataHashType,
string *dataHash, QFile *f);
/** check the data-hash */
PwMerror checkDataHash(char dataHashType, const string *dataHash, const string *dataStream);
/** encrypt data "d" and write to "filename" */
PwMerror encrypt(string *d, const QString *pw, QFile *f, char algo,
char _hashalgo //US BUG: pass _hashalgo because we need it in hashPassphrase
);
/** read data from file beginning at "pos", decrypt and return it */
PwMerror decrypt(string *d, unsigned int pos, const QString *pw, char algo,
char _hashalgo, //US BUG: pass _hashalgo because we need it in hashPassphrase
QFile *f);
/** compress the data */
bool compressDta(string *d, char algo);
/** uncompress the data */
bool decompressDta(string *d, char algo);
/** internal import function for a text-file generated by PwM.
* If this is not a valid PwM-exported file, it returns e_fileFormat */
PwMerror importText_PwM(const QString *file);
/** PwM-text-import helper function to extract the name/pw/comment out
* of one entry-line */
bool textExtractEntry_PwM(const char *in, ssize_t in_size, string *out);
/** compare two strings */
bool compareString(const string &s1, const string &s2, bool caseSensitive,
bool exactWordMatch);
/** clears all document-data */
void clearDoc();
/** delete all empty categories */
void delAllEmptyCat(bool dontFlagDirty);
/** set a document status flag */
void setDocStatFlag(unsigned int statFlag)
{ curDocStat |= statFlag; }
/** unset a document status flag */
void unsetDocStatFlag(unsigned int statFlag)
{ curDocStat &= ~statFlag; }
/** get a document status flag */
bool getDocStatFlag(unsigned int statFlag) const
{ return (curDocStat & statFlag); }
/** set the "currentPassword" */
void setCurrentPw(const QString &pw)
{
currentPw = pw;
setDocStatFlag(DOC_STAT_DISK_DIRTY);
}
/** make a backup-copy of the given file */
bool backupFile(const QString &filePath);
/** copy a file from src to dst */
bool copyFile(const QString &src, const QString &dst);
public:
#ifdef PWM_EMBEDDED
//US ENH: this is the magic function that syncronizes the local doc with the remote doc.
PwMerror syncronize(KSyncManager* manager, PwMDoc* syncLocal, PwMDoc* syncRemote, int mode );
//takePwMDataItem returns the following values
// 0 equal
// 1 take local
// 2 take remote
// 3 cancel
int takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full );
//the following methods are the overwritten callbackmethods from the syncinterface
- virtual bool sync(KSyncManager* manager, QString filename, int mode);
+ virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource);
virtual void removeSyncInfo( QString syncProfile);
#endif
//US ENH: helpermethods to return a whole category entry
/** returns a pointer to the categoryitem */
PwMCategoryItem* getCategoryEntry(unsigned int index)
{ return &(dti.dta[index]); }
private:
//US ENH: helpermethods to access the sync data for a certain syncname.
// It returns the syncdatas index
bool findSyncData(const QString &syncname, unsigned int *index);
/** add new syncdataentry */
PwMerror addSyncDataEntry(PwMSyncItem *d, bool dontFlagDirty = false);
/** returns a pointer to the syncdata */
PwMSyncItem* getSyncDataEntry(unsigned int index)
{ return &(dti.syncDta[index]); }
/** delete entry */
bool delSyncDataEntry(unsigned int index, bool dontFlagDirty = false);
/** returns number of categories */
unsigned int numSyncDataEntries()
{ return dti.syncDta.size(); }
PwMDataItem* findEntryByID(const QString &uid, unsigned int *category, unsigned int *index);
QStringList getIDEntryList();
};
#endif