summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp5
-rw-r--r--kaddressbook/kabcore.h1
-rw-r--r--korganizer/calendarview.cpp6
-rw-r--r--korganizer/calendarview.h1
-rw-r--r--libkdepim/ksyncmanager.h1
-rw-r--r--pwmanager/pwmanager/pwm.cpp6
-rw-r--r--pwmanager/pwmanager/pwm.h1
-rw-r--r--pwmanager/pwmanager/pwmdoc.cpp5
-rw-r--r--pwmanager/pwmanager/pwmdoc.h1
9 files changed, 26 insertions, 1 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 2a3334e..efae874 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2429,483 +2429,488 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i
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! ************************************** ");
{
KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , 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;
}
bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
{
bool syncOK = true;
int addedAddressee = 0;
int addedAddresseeR = 0;
int deletedAddresseeR = 0;
int deletedAddresseeL = 0;
int changedLocal = 0;
int changedRemote = 0;
QString mCurrentSyncName = syncManager->getCurrentSyncName();
QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
//QPtrList<Addressee> el = local->rawAddressees();
Addressee addresseeR;
QString uid;
int take;
Addressee addresseeL;
Addressee addresseeRSync;
Addressee addresseeLSync;
// KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
//KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
bool fullDateRange = false;
local->resetTempSyncStat();
mLastAddressbookSync = QDateTime::currentDateTime();
QDateTime modifiedCalendar = mLastAddressbookSync;;
addresseeLSync = getLastSyncAddressee();
qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
if ( !addresseeR.isEmpty() ) {
addresseeRSync = addresseeR;
remote->removeAddressee(addresseeR );
} else {
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
addresseeRSync = addresseeLSync ;
} else {
qDebug("FULLDATE 1");
fullDateRange = true;
Addressee newAdd;
addresseeRSync = newAdd;
addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
addresseeRSync.setRevision( mLastAddressbookSync );
addresseeRSync.setCategories( i18n("SyncAddressee") );
}
}
if ( addresseeLSync.revision() == mLastAddressbookSync ) {
qDebug("FULLDATE 2");
fullDateRange = true;
}
if ( ! fullDateRange ) {
if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
// 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());
fullDateRange = true;
qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
}
}
// fullDateRange = true; // debug only!
if ( fullDateRange )
mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
else
mLastAddressbookSync = addresseeLSync.revision();
// for resyncing if own file has changed
// PENDING fixme later when implemented
#if 0
if ( mCurrentSyncDevice == "deleteaftersync" ) {
mLastAddressbookSync = loadedFileVersion;
qDebug("setting mLastAddressbookSync ");
}
#endif
//qDebug("*************************** ");
// qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
QStringList er = remote->uidList();
Addressee inR ;//= er.first();
Addressee inL;
syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
int modulo = (er.count()/10)+1;
int incCounter = 0;
while ( incCounter < er.count()) {
if (syncManager->isProgressBarCanceled())
return false;
if ( incCounter % modulo == 0 )
syncManager->showProgressBar(incCounter);
uid = er[ incCounter ];
bool skipIncidence = false;
if ( uid.left(19) == QString("last-syncAddressee-") )
skipIncidence = true;
QString idS,OidS;
qApp->processEvents();
if ( !skipIncidence ) {
inL = local->findByUid( uid );
inR = remote->findByUid( uid );
//inL.setResource( 0 );
//inR.setResource( 0 );
if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
if ( !inL.resource() || inL.resource()->includeInSync() ) {
if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) {
//qDebug("take %d %s ", take, inL.summary().latin1());
if ( take == 3 )
return false;
if ( take == 1 ) {// take local
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
local->insertAddressee( inL, false );
idS = inR.externalUID();
OidS = inR.originalExternalUID();
}
else
idS = inR.IDStr();
remote->removeAddressee( inR );
inR = inL;
inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
inR.setOriginalExternalUID( OidS );
inR.setExternalUID( idS );
} else {
inR.setIDStr( idS );
}
inR.setResource( 0 );
remote->insertAddressee( inR , false);
++changedRemote;
} else { // take == 2 take remote
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
if ( inR.revision().date().year() < 2004 )
inR.setRevision( modifiedCalendar );
}
idS = inL.IDStr();
local->removeAddressee( inL );
inL = inR;
inL.setIDStr( idS );
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
}
inL.setResource( 0 );
local->insertAddressee( inL , false );
++changedLocal;
}
}
}
} else { // no conflict
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
QString des = addresseeLSync.note();
if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
remote->insertAddressee( inR, false );
++deletedAddresseeR;
} else {
inR.setRevision( modifiedCalendar );
remote->insertAddressee( inR, false );
inL = inR;
inL.setResource( 0 );
local->insertAddressee( inL , false);
++addedAddressee;
}
} else {
if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
inR.setRevision( modifiedCalendar );
remote->insertAddressee( inR, false );
inR.setResource( 0 );
local->insertAddressee( inR, false );
++addedAddressee;
} else {
// pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
remote->removeAddressee( inR );
++deletedAddresseeR;
}
}
}
}
++incCounter;
}
er.clear();
QStringList el = local->uidList();
modulo = (el.count()/10)+1;
syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
incCounter = 0;
while ( incCounter < el.count()) {
qApp->processEvents();
if (syncManager->isProgressBarCanceled())
return false;
if ( incCounter % modulo == 0 )
syncManager->showProgressBar(incCounter);
uid = el[ incCounter ];
bool skipIncidence = false;
if ( uid.left(19) == QString("last-syncAddressee-") )
skipIncidence = true;
if ( !skipIncidence ) {
inL = local->findByUid( uid );
if ( !inL.resource() || inL.resource()->includeInSync() ) {
inR = remote->findByUid( uid );
if ( inR.isEmpty() ) {
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
// pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
local->removeAddressee( inL );
++deletedAddresseeL;
} else {
if ( ! syncManager->mWriteBackExistingOnly ) {
inL.removeID(mCurrentSyncDevice );
++addedAddresseeR;
inL.setRevision( modifiedCalendar );
local->insertAddressee( inL, false );
inR = inL;
inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
inR.setResource( 0 );
remote->insertAddressee( inR, false );
}
}
} else {
if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
// pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
local->removeAddressee( inL );
++deletedAddresseeL;
} else {
if ( ! syncManager->mWriteBackExistingOnly ) {
++addedAddresseeR;
inL.setRevision( modifiedCalendar );
local->insertAddressee( inL, false );
inR = inL;
inR.setResource( 0 );
remote->insertAddressee( inR, false );
}
}
}
}
}
}
++incCounter;
}
el.clear();
syncManager->hideProgressBar();
mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
// get rid of micro seconds
QTime t = mLastAddressbookSync.time();
mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
addresseeLSync.setRevision( mLastAddressbookSync );
addresseeRSync.setRevision( mLastAddressbookSync );
addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
addresseeRSync.setNote( "" ) ;
addresseeLSync.setNote( "" );
if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
remote->insertAddressee( addresseeRSync, false );
local->insertAddressee( addresseeLSync, false );
QString mes;
mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR );
if ( syncManager->mShowSyncSummary ) {
KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") );
}
qDebug( mes );
return syncOK;
}
//this is a overwritten callbackmethods from the syncinterface
bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
{
//pending prepare addresseeview for output
//pending detect, if remote file has REV field. if not switch to external sync
mGlobalSyncMode = SYNC_MODE_NORMAL;
QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
AddressBook abLocal(filename,"syncContact");
bool syncOK = false;
if ( abLocal.load() ) {
qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
bool external = false;
bool isXML = false;
if ( filename.right(4) == ".xml") {
mGlobalSyncMode = SYNC_MODE_EXTERNAL;
isXML = true;
abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
} else {
external = !manager->mIsKapiFile;
if ( external ) {
qDebug("Setting vcf mode to external ");
mGlobalSyncMode = SYNC_MODE_EXTERNAL;
AddressBook::Iterator it;
for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
(*it).setID( mCurrentSyncDevice, (*it).uid() );
(*it).computeCsum( mCurrentSyncDevice );
}
}
}
//AddressBook::Iterator it;
//QStringList vcards;
//for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
// qDebug("Name %s ", (*it).familyName().latin1());
//}
syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
if ( syncOK ) {
if ( syncManager->mWriteBackFile )
{
if ( external )
abLocal.removeSyncAddressees( !isXML);
qDebug("Saving remote AB ");
if ( ! abLocal.saveAB())
qDebug("Error writing back AB to file ");
if ( isXML ) {
// afterwrite processing
abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
}
}
}
setModified();
}
if ( syncOK )
mViewManager->refreshView();
return syncOK;
}
+void KABCore::removeSyncInfo( QString syncProfile)
+{
+ qDebug("removeSyncInfo for profile %s ", syncProfile.latin1());
+
+}
//this is a overwritten callbackmethods from the syncinterface
bool KABCore::syncExternal(KSyncManager* manager, QString resource)
{
if ( resource == "phone" )
return syncPhone();
disableBR( true );
QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
AddressBook abLocal( resource,"syncContact");
bool syncOK = false;
if ( abLocal.load() ) {
qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
mGlobalSyncMode = SYNC_MODE_EXTERNAL;
abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
if ( syncOK ) {
if ( syncManager->mWriteBackFile ) {
abLocal.removeSyncAddressees( false );
abLocal.saveAB();
abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
}
}
setModified();
}
if ( syncOK )
mViewManager->refreshView();
disableBR( false );
return syncOK;
}
void KABCore::message( QString m )
{
topLevelWidget()->setCaption( m );
mMessageTimer->start( 15000, true );
}
bool KABCore::syncPhone()
{
QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
QString fileName = getPhoneFile();
if ( !PhoneAccess::readFromPhone( fileName) ) {
message(i18n("Phone access failed!"));
return false;
}
AddressBook abLocal( fileName,"syncContact");
bool syncOK = false;
{
abLocal.importFromFile( fileName );
qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
mGlobalSyncMode = SYNC_MODE_EXTERNAL;
abLocal.preparePhoneSync( mCurrentSyncDevice, true );
abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
if ( syncOK ) {
if ( syncManager->mWriteBackFile ) {
abLocal.removeSyncAddressees( true );
abLocal.saveABphone( fileName );
abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
//abLocal.preparePhoneSync( mCurrentSyncDevice, false );
abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
}
}
setModified();
}
if ( syncOK )
mViewManager->refreshView();
return syncOK;
}
void KABCore::getFile( bool success )
{
if ( ! success ) {
message( i18n("Error receiving file. Nothing changed!") );
return;
}
int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
if ( count )
setModified( true );
message( i18n("Pi-Sync successful!") );
mViewManager->refreshView();
}
void KABCore::syncFileRequest()
{
mAddressBook->export2File( sentSyncFile() );
}
QString KABCore::sentSyncFile()
{
#ifdef DESKTOP_VERSION
return locateLocal( "tmp", "copysyncab.vcf" );
#else
return QString( "/tmp/copysyncab.vcf" );
#endif
}
void KABCore::setCaptionBack()
{
mMessageTimer->stop();
topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
}
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index fcbe1e8..a288505 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -101,402 +101,403 @@ class KABCore : public QWidget, public KSyncInterface
void saveSettings();
/**
Returns a pointer to the StdAddressBook of the application.
*/
KABC::AddressBook *addressBook() const;
/**
Returns a pointer to the KConfig object of the application.
*/
static KConfig *config();
/**
Returns a pointer to the global KActionCollection object. So
other classes can register their actions easily.
*/
KActionCollection *actionCollection() const;
/**
Returns the current search field of the Incremental Search Widget.
*/
KABC::Field *currentSearchField() const;
/**
Returns the uid list of the currently selected contacts.
*/
QStringList selectedUIDs() const;
/**
Displays the ResourceSelectDialog and returns the selected
resource or a null pointer if no resource was selected by
the user.
*/
KABC::Resource *requestResource( QWidget *parent );
#ifndef KAB_EMBEDDED
static KAboutData *createAboutData();
#endif //KAB_EMBEDDED
#ifdef KAB_EMBEDDED
inline QPopupMenu* getImportMenu() { return ImportMenu;}
inline QPopupMenu* getExportMenu() { return ExportMenu;}
#endif //KAB_EMBEDDED
public slots:
#ifdef KAB_EMBEDDED
void createAboutData();
#endif //KAB_EMBEDDED
void showLicence();
void faq();
void whatsnew() ;
void synchowto() ;
void writeToPhone();
/**
Is called whenever a contact is selected in the view.
*/
void setContactSelected( const QString &uid );
/**
Opens the preferred mail composer with all selected contacts as
arguments.
*/
void sendMail();
/**
Opens the preferred mail composer with the given contacts as
arguments.
*/
void sendMail( const QString& email );
void mailVCard();
void mailVCard(const QStringList& uids);
/**
Beams the "WhoAmI contact.
*/
void beamMySelf();
void beamVCard();
void export2phone();
void beamVCard(const QStringList& uids);
void beamDone( Ir *ir );
/**
Starts the preferred web browser with the given URL as argument.
*/
void browse( const QString& url );
/**
Select all contacts in the view.
*/
void selectAllContacts();
/**
Deletes all selected contacts from the address book.
*/
void deleteContacts();
/**
Deletes given contacts from the address book.
@param uids The uids of the contacts, which shall be deleted.
*/
void deleteContacts( const QStringList &uids );
/**
Copys the selected contacts into clipboard for later pasting.
*/
void copyContacts();
/**
Cuts the selected contacts and stores them for later pasting.
*/
void cutContacts();
/**
Paste contacts from clipboard into the address book.
*/
void pasteContacts();
/**
Paste given contacts into the address book.
@param list The list of addressee, which shall be pasted.
*/
void pasteContacts( KABC::Addressee::List &list );
/**
Sets the whoAmI contact, that is used by many other programs to
get personal information about the current user.
*/
void setWhoAmI();
/**
Displays the category dialog and applies the result to all
selected contacts.
*/
void setCategories();
/**
Sets the field list of the Incremental Search Widget.
*/
void setSearchFields( const KABC::Field::List &fields );
/**
Search with the current search field for a contact, that matches
the given text, and selects it in the view.
*/
void incrementalSearch( const QString& text );
/**
Marks the address book as modified.
*/
void setModified();
/**
Marks the address book as modified without refreshing the view.
*/
void setModifiedWOrefresh();
/**
Marks the address book as modified concerning the argument.
*/
void setModified( bool modified );
/**
Returns whether the address book is modified.
*/
bool modified() const;
/**
Called whenever an contact is modified in the contact editor
dialog or the quick edit.
*/
void contactModified( const KABC::Addressee &addr );
/**
DCOP METHODS.
*/
void addEmail( QString addr );
void importVCard( const KURL& url, bool showPreview );
void importVCard( const QString& vCard, bool showPreview );
void newContact();
QString getNameByPhone( const QString& phone );
/**
END DCOP METHODS
*/
/**
Saves the contents of the AddressBook back to disk.
*/
void save();
/**
Undos the last command using the undo stack.
*/
void undo();
/**
Redos the last command that was undone, using the redo stack.
*/
void redo();
/**
Shows the edit dialog for the given uid. If the uid is QString::null,
the method will try to find a selected addressee in the view.
*/
void editContact( const QString &uid /*US = QString::null*/ );
//US added a second method without defaultparameter
void editContact2();
/**
Shows or edits the detail view for the given uid. If the uid is QString::null,
the method will try to find a selected addressee in the view.
*/
void executeContact( const QString &uid /*US = QString::null*/ );
/**
Launches the configuration dialog.
*/
void openConfigDialog();
/**
Launches the ldap search dialog.
*/
void openLDAPDialog();
/**
Creates a KAddressBookPrinter, which will display the print
dialog and do the printing.
*/
void print();
/**
Registers a new GUI client, so plugins can register its actions.
*/
void addGUIClient( KXMLGUIClient *client );
void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid);
void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid);
void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid);
signals:
void contactSelected( const QString &name );
void contactSelected( const QPixmap &pixmap );
public slots:
void recieve(QString cmsg );
void getFile( bool success );
void syncFileRequest();
void setDetailsVisible( bool visible );
void setDetailsToState();
// void slotSyncMenu( int );
private slots:
void receive( const QCString& cmsg, const QByteArray& data );
void toggleBeamReceive( );
void disableBR(bool);
void setJumpButtonBarVisible( bool visible );
void setCaptionBack();
void importFromOL();
void extensionModified( const KABC::Addressee::List &list );
void extensionChanged( int id );
void clipboardDataChanged();
void updateActionMenu();
void configureKeyBindings();
void removeVoice();
#ifdef KAB_EMBEDDED
void configureResources();
#endif //KAB_EMBEDDED
void slotEditorDestroyed( const QString &uid );
void configurationChanged();
void addressBookChanged();
private:
bool mBRdisabled;
#ifndef DESKTOP_VERSION
QCopChannel* infrared;
#endif
QTimer *mMessageTimer;
void initGUI();
void initActions();
QString getPhoneFile();
AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent,
const char *name = 0 );
KXMLGUIClient *mGUIClient;
KABC::AddressBook *mAddressBook;
ViewManager *mViewManager;
// QSplitter *mDetailsSplitter;
KDGanttMinimizeSplitter *mExtensionBarSplitter;
ViewContainer *mDetails;
KDGanttMinimizeSplitter* mMiniSplitter;
XXPortManager *mXXPortManager;
JumpButtonBar *mJumpButtonBar;
IncSearchWidget *mIncSearchWidget;
ExtensionManager *mExtensionManager;
KCMultiDialog *mConfigureDialog;
#ifndef KAB_EMBEDDED
LDAPSearchDialog *mLdapSearchDialog;
#endif //KAB_EMBEDDED
// QDict<AddresseeEditorDialog> mEditorDict;
AddresseeEditorDialog *mEditorDialog;
bool mReadWrite;
bool mModified;
bool mIsPart;
bool mMultipleViewsAtOnce;
//US file menu
KAction *mActionMail;
KAction *mActionBeam;
KToggleAction *mActionBR;
KAction *mActionExport2phone;
KAction* mActionPrint;
KAction* mActionNewContact;
KAction *mActionSave;
KAction *mActionEditAddressee;
KAction *mActionMailVCard;
KAction *mActionBeamVCard;
KAction *mActionQuit;
//US edit menu
KAction *mActionCopy;
KAction *mActionCut;
KAction *mActionPaste;
KAction *mActionSelectAll;
KAction *mActionUndo;
KAction *mActionRedo;
KAction *mActionDelete;
//US settings menu
KAction *mActionConfigResources;
KAction *mActionConfigKAddressbook;
KAction *mActionConfigShortcuts;
KAction *mActionConfigureToolbars;
KAction *mActionKeyBindings;
KToggleAction *mActionJumpBar;
KToggleAction *mActionDetails;
KAction *mActionWhoAmI;
KAction *mActionCategories;
KAction *mActionAboutKAddressbook;
KAction *mActionLicence;
KAction *mActionFaq;
KAction *mActionWN;
KAction *mActionSyncHowto;
KAction *mActionDeleteView;
QPopupMenu *viewMenu;
QPopupMenu *filterMenu;
QPopupMenu *settingsMenu;
QPopupMenu *changeMenu;
//US QAction *mActionSave;
QPopupMenu *ImportMenu;
QPopupMenu *ExportMenu;
//LR additional methods
KAction *mActionRemoveVoice;
KAction * mActionImportOL;
#ifndef KAB_EMBEDDED
KAddressBookService *mAddressBookService;
#endif //KAB_EMBEDDED
class KABCorePrivate;
KABCorePrivate *d;
//US bool mBlockSaveFlag;
#ifdef KAB_EMBEDDED
KAddressBookMain *mMainWindow; // should be the same like mGUIClient
#endif //KAB_EMBEDDED
//this are the overwritten callbackmethods from the syncinterface
virtual bool sync(KSyncManager* manager, QString filename, int mode);
virtual bool syncExternal(KSyncManager* manager, QString resource);
+ virtual void removeSyncInfo( QString syncProfile);
bool syncPhone();
void message( QString m );
// LR *******************************
// sync stuff!
QString sentSyncFile();
QPopupMenu *syncMenu;
KSyncManager* syncManager;
int mGlobalSyncMode;
bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode);
KABC::Addressee getLastSyncAddressee();
QDateTime mLastAddressbookSync;
int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full );
// *********************
};
#endif
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 2ccccfa..af01625 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -3383,384 +3383,390 @@ void CalendarView::showDates(const DateList &selectedDates)
}
QString selDates;
selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
if (selectedDates.first() < selectedDates.last() )
selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
}
QPtrList<CalFilter> CalendarView::filters()
{
return mFilters;
}
void CalendarView::editFilters()
{
// kdDebug() << "CalendarView::editFilters()" << endl;
CalFilter *filter = mFilters.first();
while(filter) {
kdDebug() << " Filter: " << filter->name() << endl;
filter = mFilters.next();
}
mDialogManager->showFilterEditDialog(&mFilters);
}
void CalendarView::toggleFilter()
{
showFilter(! mFilterView->isVisible());
}
KOFilterView *CalendarView::filterView()
{
return mFilterView;
}
void CalendarView::selectFilter( int fil )
{
mFilterView->setSelectedFilter( fil );
}
void CalendarView::showFilter(bool visible)
{
if (visible) mFilterView->show();
else mFilterView->hide();
}
void CalendarView::toggleFilerEnabled( )
{
mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
if ( !mFilterView->filtersEnabled() )
topLevelWidget()->setCaption( i18n("Filter disabled ") );
}
void CalendarView::updateFilter()
{
CalFilter *filter = mFilterView->selectedFilter();
if (filter) {
if (mFilterView->filtersEnabled()) {
topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
filter->setEnabled(true);
}
else filter->setEnabled(false);
mCalendar->setFilter(filter);
updateView();
}
}
void CalendarView::filterEdited()
{
mFilterView->updateFilters();
updateFilter();
writeSettings();
}
void CalendarView::takeOverEvent()
{
Incidence *incidence = currentSelection();
if (!incidence) return;
incidence->setOrganizer(KOPrefs::instance()->email());
incidence->recreate();
incidence->setReadOnly(false);
updateView();
}
void CalendarView::takeOverCalendar()
{
// TODO: Create Calendar::allIncidences() function and use it here
QPtrList<Event> events = mCalendar->events();
for(uint i=0; i<events.count(); ++i) {
events.at(i)->setOrganizer(KOPrefs::instance()->email());
events.at(i)->recreate();
events.at(i)->setReadOnly(false);
}
QPtrList<Todo> todos = mCalendar->todos();
for(uint i=0; i<todos.count(); ++i) {
todos.at(i)->setOrganizer(KOPrefs::instance()->email());
todos.at(i)->recreate();
todos.at(i)->setReadOnly(false);
}
QPtrList<Journal> journals = mCalendar->journals();
for(uint i=0; i<journals.count(); ++i) {
journals.at(i)->setOrganizer(KOPrefs::instance()->email());
journals.at(i)->recreate();
journals.at(i)->setReadOnly(false);
}
updateView();
}
void CalendarView::showIntro()
{
kdDebug() << "To be implemented." << endl;
}
QWidgetStack *CalendarView::viewStack()
{
return mRightFrame;
}
QWidget *CalendarView::leftFrame()
{
return mLeftFrame;
}
DateNavigator *CalendarView::dateNavigator()
{
return mNavigator;
}
KDateNavigator* CalendarView::dateNavigatorWidget()
{
return mDateNavigator;
}
void CalendarView::toggleDateNavigatorWidget()
{
if (mDateNavigator->isVisible())
mDateNavigator->hide();
else
mDateNavigator->show();
}
void CalendarView::addView(KOrg::BaseView *view)
{
mViewManager->addView(view);
}
void CalendarView::showView(KOrg::BaseView *view)
{
mViewManager->showView(view, mLeftFrame->isVisible());
}
Incidence *CalendarView::currentSelection()
{
return mViewManager->currentSelection();
}
void CalendarView::toggleAllDaySize()
{
/*
if ( KOPrefs::instance()->mAllDaySize > 47 )
KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
else
KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
*/
viewManager()->agendaView()->toggleAllDay();
}
void CalendarView::toggleExpand()
{
// if ( mLeftFrame->isHidden() ) {
// mLeftFrame->show();
// emit calendarViewExpanded( false );
// } else {
// mLeftFrame->hide();
// emit calendarViewExpanded( true );
// }
globalFlagBlockAgenda = 1;
emit calendarViewExpanded( !mLeftFrame->isHidden() );
globalFlagBlockAgenda = 5;
mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
//mViewManager->showView( 0, true );
}
void CalendarView::calendarModified( bool modified, Calendar * )
{
setModified( modified );
}
Todo *CalendarView::selectedTodo()
{
Incidence *incidence = currentSelection();
if ( incidence && incidence->type() == "Todo" ) {
return static_cast<Todo *>( incidence );
}
incidence = mTodoList->selectedIncidences().first();
if ( incidence && incidence->type() == "Todo" ) {
return static_cast<Todo *>( incidence );
}
return 0;
}
void CalendarView::dialogClosing(Incidence *in)
{
// mDialogList.remove(in);
}
void CalendarView::showIncidence()
{
Incidence *incidence = currentSelection();
if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
if ( incidence ) {
ShowIncidenceVisitor v;
v.act( incidence, this );
}
}
void CalendarView::editIncidenceDescription()
{
mFlagEditDescription = true;
editIncidence();
mFlagEditDescription = false;
}
void CalendarView::editIncidence()
{
// qDebug("editIncidence() ");
Incidence *incidence = currentSelection();
if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
if ( incidence ) {
EditIncidenceVisitor v;
v.act( incidence, this );
}
}
void CalendarView::deleteIncidence()
{
Incidence *incidence = currentSelection();
if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
if ( incidence ) {
deleteIncidence(incidence);
}
}
void CalendarView::showIncidence(Incidence *incidence)
{
if ( incidence ) {
ShowIncidenceVisitor v;
v.act( incidence, this );
}
}
void CalendarView::editIncidence(Incidence *incidence)
{
if ( incidence ) {
EditIncidenceVisitor v;
v.act( incidence, this );
}
}
void CalendarView::deleteIncidence(Incidence *incidence)
{
//qDebug(" CalendarView::deleteIncidence ");
if ( incidence ) {
DeleteIncidenceVisitor v;
v.act( incidence, this );
}
}
void CalendarView::lookForOutgoingMessages()
{
OutgoingDialog *ogd = mDialogManager->outgoingDialog();
ogd->loadMessages();
}
void CalendarView::lookForIncomingMessages()
{
IncomingDialog *icd = mDialogManager->incomingDialog();
icd->retrieve();
}
bool CalendarView::removeCompletedSubTodos( Todo* t )
{
bool deleteTodo = true;
QPtrList<Incidence> subTodos;
Incidence *aTodo;
subTodos = t->relations();
for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
if (! removeCompletedSubTodos( (Todo*) aTodo ))
deleteTodo = false;
}
if ( deleteTodo ) {
if ( t->isCompleted() ) {
checkExternalId( t );
mCalendar->deleteTodo( t );
changeTodoDisplay( t,KOGlobals::EVENTDELETED );
}
else
deleteTodo = false;
}
return deleteTodo;
}
void CalendarView::purgeCompleted()
{
int result = KMessageBox::warningContinueCancel(this,
i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
if (result == KMessageBox::Continue) {
QPtrList<Todo> todoCal;
QPtrList<Todo> rootTodos;
//QPtrList<Incidence> rel;
Todo *aTodo;//, *rTodo;
Incidence *rIncidence;
bool childDelete = false;
bool deletedOne = true;
todoCal = calendar()->todos();
for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
if ( !aTodo->relatedTo() )
rootTodos.append( aTodo );
}
for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
removeCompletedSubTodos( aTodo );
}
updateView();
}
}
void CalendarView::slotCalendarChanged()
{
;
}
NavigatorBar *CalendarView::navigatorBar()
{
return mNavigatorBar;
}
void CalendarView::keyPressEvent ( QKeyEvent *e)
{
//qDebug(" alendarView::keyPressEvent ");
e->ignore();
}
bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
{
// mSyncManager = manager;
mSyncKDE = false;
if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
qDebug("SyncKDE request detected!");
mSyncKDE = true;
}
mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
mCurrentSyncName = mSyncManager->getCurrentSyncName();
return syncCalendar( filename, mode );
}
bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
{
mSyncKDE = false;
//mSyncManager = manager;
mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
mCurrentSyncName = mSyncManager->getCurrentSyncName();
if ( resource == "sharp" )
syncExternal( 0 );
if ( resource == "phone" )
syncExternal( 1 );
// pending setmodified
return true;
}
void CalendarView::setSyncManager(KSyncManager* manager)
{
mSyncManager = manager;
}
+
+void CalendarView::removeSyncInfo( QString syncProfile)
+{
+ qDebug("removeSyncInfo for profile %s ", syncProfile.latin1());
+
+}
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 2818ee9..acc20d6 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -84,522 +84,523 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
Q_OBJECT
public:
/**
Constructs a new calendar view widget.
@param calendar calendar document
@param parent parent window
@param name Qt internal widget object name
*/
CalendarView( CalendarResources *calendar, QWidget *parent = 0,
const char *name = 0 );
CalendarView( Calendar *calendar, QWidget *parent = 0,
const char *name = 0 );
virtual ~CalendarView();
Calendar *calendar() { return mCalendar; }
KOViewManager *viewManager();
KODialogManager *dialogManager();
QDate startDate();
QDate endDate();
QWidgetStack *viewStack();
QWidget *leftFrame();
NavigatorBar *navigatorBar();
DateNavigator *dateNavigator();
KDateNavigator *dateNavigatorWidget();
void addView(KOrg::BaseView *);
void showView(KOrg::BaseView *);
KOEventViewerDialog* getEventViewerDialog();
Incidence *currentSelection();
signals:
void tempDisableBR(bool);
/** This todo has been modified */
void todoModified(Todo *, int);
/** when change is made to options dialog, the topwidget will catch this
* and emit this signal which notifies all widgets which have registered
* for notification to update their settings. */
void configChanged();
/** emitted when the topwidget is closing down, so that any attached
child windows can also close. */
void closingDown();
/** emitted right before we die */
void closed(QWidget *);
/** Emitted when state of modified flag changes */
void modifiedChanged(bool);
void signalmodified();
/** Emitted when state of read-only flag changes */
void readOnlyChanged(bool);
/** Emitted when the unit of navigation changes */
void changeNavStringPrev(const QString &);
void changeNavStringNext(const QString &);
/** Emitted when state of events selection has changed and user is organizer*/
void organizerEventsSelected(bool);
/** Emitted when state of events selection has changed and user is attendee*/
void groupEventsSelected(bool);
/**
Emitted when an incidence gets selected. If the selection is cleared the
signal is emitted with 0 as argument.
*/
void incidenceSelected( Incidence * );
/** Emitted, when a todoitem is selected or deselected. */
void todoSelected( bool );
/**
Emitted, when clipboard content changes. Parameter indicates if paste
is possible or not.
*/
void pasteEnabled(bool);
/** Emitted, when the number of incoming messages has changed. */
void numIncomingChanged(int);
/** Emitted, when the number of outgoing messages has changed. */
void numOutgoingChanged(int);
/** Send status message, which can e.g. be displayed in the status bar. */
void statusMessage(const QString &);
void calendarViewExpanded( bool );
void updateSearchDialog();
public slots:
void showOpenError();
void watchSavedFile();
void recheckTimerAlarm();
void checkNextTimerAlarm();
void addAlarm(const QDateTime &qdt, const QString &noti );
void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
void removeAlarm(const QDateTime &qdt, const QString &noti );
/** options dialog made a changed to the configuration. we catch this
* and notify all widgets which need to update their configuration. */
void updateConfig();
void insertBirthdays(const QString& uid, const QStringList& birthdayList,
const QStringList& anniversaryList, const QStringList& realNameList,
const QStringList& emailList, const QStringList& assembledNameList,
const QStringList& uidList);
/**
Load calendar from file \a filename. If \a merge is true, load
calendar into existing one, if it is false, clear calendar, before
loading. Return true, if calendar could be successfully loaded.
*/
bool openCalendar(QString filename, bool merge=false);
bool syncCalendar(QString filename,int mode = 0 );
/**
Save calendar data to file. Return true if calendar could be
successfully saved.
*/
bool saveCalendar(QString filename);
/**
Close calendar. Clear calendar data and reset views to display an empty
calendar.
*/
void closeCalendar();
/** Archive old events of calendar */
void archiveCalendar();
void showIncidence();
void editIncidence();
void editIncidenceDescription();
void deleteIncidence();
void cloneIncidence();
void moveIncidence();
void beamIncidence();
void toggleCancelIncidence();
/** create an editeventwin with supplied date/time, and if bool is true,
* make the event take all day. */
void newEvent(QDateTime, QDateTime, bool allDay = false);
void newEvent(QDateTime fh);
void newEvent(QDate dt);
/** create new event without having a date hint. Takes current date as
default hint. */
void newEvent();
void newFloatingEvent();
/** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
void showIncidence(Incidence *);
/** Create an editor for the supplied incidence. It calls the correct editXXX method*/
void editIncidence(Incidence *);
/** Delete the supplied incidence. It calls the correct deleteXXX method*/
void deleteIncidence(Incidence *);
void cloneIncidence(Incidence *);
void cancelIncidence(Incidence *);
/** Create an editor for the supplied event. */
void editEvent(Event *);
/** Delete the supplied event. */
void deleteEvent(Event *);
/** Delete the event with the given unique ID. Returns false, if event wasn't
found. */
bool deleteEvent(const QString &uid);
/** Create a read-only viewer dialog for the supplied event. */
void showEvent(Event *);
void editJournal(Journal *);
void showJournal(Journal *);
void deleteJournal(Journal *);
/** Create an editor dialog for a todo */
void editTodo(Todo *);
/** Create a read-only viewer dialog for the supplied todo */
void showTodo(Todo *);
/** create new todo */
void newTodo();
/** create new todo with a parent todo */
void newSubTodo();
/** create new todo with a parent todo */
void newSubTodo(Todo *);
/** Delete todo */
void deleteTodo(Todo *);
/** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
* emitted as result. */
void checkClipboard();
/** using the KConfig associated with the kapp variable, read in the
* settings from the config file.
*/
void readSettings();
/** write current state to config file. */
void writeSettings();
/** read settings for calendar filters */
void readFilterSettings(KConfig *config);
/** write settings for calendar filters */
void writeFilterSettings(KConfig *config);
/** passes on the message that an event has changed to the currently
* activated view so that it can make appropriate display changes. */
void changeEventDisplay(Event *, int);
void changeIncidenceDisplay(Incidence *, int);
void changeTodoDisplay(Todo *, int);
void eventAdded(Event *);
void eventChanged(Event *);
void eventToBeDeleted(Event *);
void eventDeleted();
void todoAdded(Todo *);
void todoChanged(Todo *);
void todoToBeDeleted(Todo *);
void todoDeleted();
void updateView(const QDate &start, const QDate &end);
void updateView();
/** Full update of visible todo views */
void updateTodoViews();
void updateUnmanagedViews();
/** cut the current appointment to the clipboard */
void edit_cut();
/** copy the current appointment(s) to the clipboard */
void edit_copy();
/** paste the current vobject(s) in the clipboard buffer into calendar */
void edit_paste();
/** edit viewing and configuration options. */
void edit_options();
/**
Functions for printing, previewing a print, and setting up printing
parameters.
*/
void print();
void printSetup();
void printPreview();
/** Export as iCalendar file */
void exportICalendar();
/** Export as vCalendar file */
bool exportVCalendar( QString fn);
/** pop up a dialog to show an existing appointment. */
void appointment_show();
/**
* pop up an Appointment Dialog to edit an existing appointment. Get
* information on the appointment from the list of unique IDs that is
* currently in the View, called currIds.
*/
void appointment_edit();
/**
* pop up dialog confirming deletion of currently selected event in the
* View.
*/
void appointment_delete();
/** mails the currently selected event to a particular user as a vCalendar
attachment. */
void action_mail();
/* frees a subtodo from it's relation */
void todo_unsub( Todo * );
void todo_resub( Todo * parent, Todo * sub );
/** Take ownership of selected event. */
void takeOverEvent();
/** Take ownership of all events in calendar. */
void takeOverCalendar();
/** query whether or not the calendar is "dirty". */
bool isModified();
/** set the state of calendar. Modified means "dirty", i.e. needing a save. */
void setModified(bool modified=true);
/** query if the calendar is read-only. */
bool isReadOnly();
/** set state of calendar to read-only */
void setReadOnly(bool readOnly=true);
void eventUpdated(Incidence *);
/* iTIP scheduling actions */
void schedule_publish(Incidence *incidence = 0);
void schedule_request(Incidence *incidence = 0);
void schedule_refresh(Incidence *incidence = 0);
void schedule_cancel(Incidence *incidence = 0);
void schedule_add(Incidence *incidence = 0);
void schedule_reply(Incidence *incidence = 0);
void schedule_counter(Incidence *incidence = 0);
void schedule_declinecounter(Incidence *incidence = 0);
void schedule_publish_freebusy(int daysToPublish = 30);
void openAddressbook();
void editFilters();
void toggleFilerEnabled();
QPtrList<CalFilter> filters();
void toggleFilter();
void showFilter(bool visible);
void updateFilter();
void filterEdited();
void selectFilter( int );
KOFilterView *filterView();
void showIntro();
/** Move the curdatepient view date to today */
void goToday();
/** Move to the next date(s) in the current view */
void goNext();
/** Move to the previous date(s) in the current view */
void goPrevious();
/** Move to the next date(s) in the current view */
void goNextMonth();
/** Move to the previous date(s) in the current view */
void goPreviousMonth();
void toggleExpand();
void toggleDateNavigatorWidget();
void toggleAllDaySize();
void dialogClosing(Incidence *);
/** Look for new messages in the inbox */
void lookForIncomingMessages();
/** Look for new messages in the outbox */
void lookForOutgoingMessages();
void processMainViewSelection( Incidence * );
void processTodoListSelection( Incidence * );
void processIncidenceSelection( Incidence * );
void purgeCompleted();
bool removeCompletedSubTodos( Todo* );
void slotCalendarChanged();
bool importBday();
bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
bool importQtopia( const QString &categoriesFile,
const QString &datebookFile,
const QString &tasklistFile );
void syncExternal( int mode );
void slotSelectPickerDate( QDate ) ;
void showDatePicker( ) ;
void moveIncidence(Incidence *) ;
void beamIncidence(Incidence *) ;
void beamCalendar() ;
void beamFilteredCalendar() ;
void beamIncidenceList(QPtrList<Incidence>) ;
void manageCategories();
int addCategories();
void removeCategories();
void setSyncDevice( QString );
void setSyncName( QString );
protected slots:
void timerAlarm();
void suspendAlarm();
void beamDone( Ir *ir );
/** Select a view or adapt the current view to display the specified dates. */
void showDates( const KCal::DateList & );
void selectWeekNum ( int );
public:
// show a standard warning
// returns KMsgBox::yesNoCancel()
int msgCalModified();
virtual bool sync(KSyncManager* manager, QString filename, int mode);
virtual bool syncExternal(KSyncManager* manager, QString resource);
+ virtual void removeSyncInfo( QString syncProfile);
void setSyncManager(KSyncManager* manager);
void setLoadedFileVersion(QDateTime);
bool checkFileVersion(QString fn);
bool checkFileChanged(QString fn);
Event* getLastSyncEvent();
/** Adapt navigation units correpsonding to step size of navigation of the
* current view.
*/
void adaptNavigationUnits();
bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
//Attendee* getYourAttendee(Event *event);
protected:
void schedule(Scheduler::Method, Incidence *incidence = 0);
// returns KMsgBox::OKCandel()
int msgItemDelete();
void showEventEditor();
void showTodoEditor();
void writeLocale();
Todo *selectedTodo();
private:
bool mSyncKDE;
KSyncManager* mSyncManager;
AlarmDialog * mAlarmDialog;
QString mAlarmNotification;
QString mSuspendAlarmNotification;
QTimer* mSuspendTimer;
QTimer* mAlarmTimer;
QTimer* mRecheckAlarmTimer;
void computeAlarm( QString );
void startAlarm( QString, QString );
void setSyncEventsReadOnly();
QDateTime loadedFileVersion;
void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
void checkExternalId( Incidence * inc );
int mGlobalSyncMode;
QString mCurrentSyncDevice;
QString mCurrentSyncName;
KOBeamPrefs* beamDialog;
void init();
int mDatePickerMode;
bool mFlagEditDescription;
QDateTime mLastCalendarSync;
void createPrinter();
void calendarModified( bool, Calendar * );
CalPrinter *mCalPrinter;
QSplitter *mPanner;
QSplitter *mLeftSplitter;
QWidget *mLeftFrame;
QWidgetStack *mRightFrame;
KDatePicker* mDatePicker;
QVBox* mDateFrame;
NavigatorBar *mNavigatorBar;
KDateNavigator *mDateNavigator; // widget showing small month view.
KOFilterView *mFilterView;
ResourceView *mResourceView;
// calendar object for this viewing instance
Calendar *mCalendar;
CalendarResourceManager *mResourceManager;
FileStorage *mStorage;
DateNavigator *mNavigator;
KOViewManager *mViewManager;
KODialogManager *mDialogManager;
// Calendar filters
QPtrList<CalFilter> mFilters;
// various housekeeping variables.
bool mModified; // flag indicating if calendar is modified
bool mReadOnly; // flag indicating if calendar is read-only
QDate mSaveSingleDate;
Incidence *mSelectedIncidence;
Incidence *mMoveIncidence;
KOTodoView *mTodoList;
KOEventEditor * mEventEditor;
KOTodoEditor * mTodoEditor;
KOEventViewerDialog * mEventViewerDialog;
void keyPressEvent ( QKeyEvent *e) ;
//QMap<Incidence*,KOIncidenceEditor*> mDialogList;
};
class CalendarViewVisitor : public Incidence::Visitor
{
public:
CalendarViewVisitor() : mView( 0 ) {}
bool act( Incidence *incidence, CalendarView *view )
{
mView = view;
return incidence->accept( *this );
}
protected:
CalendarView *mView;
};
class ShowIncidenceVisitor : public CalendarViewVisitor
{
protected:
bool visit( Event *event ) { mView->showEvent( event ); return true; }
bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
bool visit( Journal * j ) { mView->showJournal( j );return true; }
};
class EditIncidenceVisitor : public CalendarViewVisitor
{
protected:
bool visit( Event *event ) { mView->editEvent( event ); return true; }
bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
bool visit( Journal *j ) { mView->editJournal( j); return true; }
};
class DeleteIncidenceVisitor : public CalendarViewVisitor
{
protected:
bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
};
#endif
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 4a610fa..af4f1ab 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -1,211 +1,212 @@
/*
This file is part of KDE-Pim/Pi.
Copyright (c) 2004 Ulf Schenk
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
$Id$
*/
#ifndef _KSYNCMANAGER_H
#define _KSYNCMANAGER_H
#include <qobject.h>
#include <qstring.h>
#include <qsocket.h>
#include <qdatetime.h>
#include <qserversocket.h>
#include <qtextstream.h>
#include <qregexp.h>
class QPopupMenu;
class KSyncProfile;
class KPimPrefs;
class QWidget;
class KSyncManager;
class KSyncInterface;
class QProgressBar;
class KServerSocket : public QServerSocket
{
Q_OBJECT
public:
KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 );
void newConnection ( int socket ) ;
void setFileName( QString fn ) {mFileName = fn;};
signals:
void file_received( bool );
void request_file();
void saveFile();
void endConnect();
private slots:
void discardClient();
void readClient();
void readBackFileFromSocket();
private :
bool blockRC;
void send_file();
void get_file();
void end_connect();
QDialog* mSyncActionDialog;
QSocket* mSocket;
QString mPassWord;
QString mFileName;
QTime piTime;
QString piFileString;
};
class KCommandSocket : public QObject
{
Q_OBJECT
public:
enum state { successR, errorR, successW, errorW, errorTO, quiet };
KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 );
void readFile( QString );
void writeFile( QString );
void sendStop();
signals:
void commandFinished( KCommandSocket*, int );
private slots:
void startReadFileFromSocket();
void readFileFromSocket();
void deleteSocket();
void writeFileToSocket();
private :
QSocket* mSocket;
QString mPassWord;
Q_UINT16 mPort;
QString mHost;
QString mFileName;
QTimer* mTimerSocket;
int mRetVal;
QTime mTime;
QString mFileString;
bool mFirst;
};
class KSyncManager : public QObject
{
Q_OBJECT
public:
enum TargetApp {
KOPI = 0,
KAPI = 1,
PWMPI = 2 };
KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu);
~KSyncManager() ;
void multiSync( bool askforPrefs );
bool blockSave() { return mBlockSaveFlag; }
void setBlockSave(bool sa) { mBlockSaveFlag = sa; }
void setDefaultFileName( QString s) { mDefFileName = s ;}
QString defaultFileName() { return mDefFileName ;}
QString syncFileName();
void enableQuick( bool ask = true);
QString getCurrentSyncDevice() { return mCurrentSyncDevice; }
QString getCurrentSyncName() { return mCurrentSyncName; }
void showProgressBar(int percentage, QString caption = QString::null, int total=100);
void hideProgressBar();
bool isProgressBarCanceled();
// sync stuff
QString mLocalMachineName;
QStringList mExternSyncProfiles;
QStringList mSyncProfileNames;
bool mAskForPreferences;
bool mShowSyncSummary;
bool mIsKapiFile;
bool mWriteBackExistingOnly;
int mSyncAlgoPrefs;
bool mWriteBackFile;
int mWriteBackInFuture;
QString mPhoneDevice;
QString mPhoneConnection;
QString mPhoneModel;
QString mPassWordPiSync;
QString mActiveSyncPort;
QString mActiveSyncIP ;
signals:
void save();
void request_file();
void getFile( bool );
public slots:
void slotSyncMenu( int );
void deleteCommandSocket(KCommandSocket*s, int state);
void readFileFromSocket();
void fillSyncMenu();
private:
void syncPi();
KServerSocket * mServerSocket;
KPimPrefs* mPrefs;
QString mDefFileName;
QString mCurrentSyncDevice;
QString mCurrentSyncName;
void quickSyncLocalFile();
bool syncWithFile( QString fn , bool quick );
void syncLocalFile();
void syncPhone();
void syncSharp();
void syncKDE();
bool syncExternalApplication(QString);
int mCurrentSyncProfile ;
void syncRemote( KSyncProfile* prof, bool ask = true);
bool edit_sync_options();
bool edit_pisync_options();
int ringSync();
QString getPassword( );
bool mPisyncFinished;
bool mBlockSaveFlag;
QWidget* mParent;
KSyncInterface* mImplementation;
TargetApp mTargetApp;
QPopupMenu* mSyncMenu;
QProgressBar* bar;
private slots:
void confSync();
};
class KSyncInterface
{
public :
+ virtual void removeSyncInfo( QString syncProfile) = 0;
virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0;
virtual bool syncExternal(KSyncManager* manager, QString resource)
{
// empty implementation, because some syncable applications do not
// have an external(sharpdtm) syncmode, like pwmanager.
return false;
}
};
#endif
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp
index 2b8f2fa..6ae6e28 100644
--- a/pwmanager/pwmanager/pwm.cpp
+++ b/pwmanager/pwmanager/pwm.cpp
@@ -1083,390 +1083,396 @@ bool PwM::importCsv()
"opened.)"),
i18n("Import into This Document?"))
== KMessageBox::No) {
// import the data to a new window.
PwM *newInstance = init->createMainWnd();
bool ok = newInstance->importCsv();
if (!ok) {
newInstance->setForceQuit(true);
delete_and_null(newInstance);
}
return ok;
}
}
QString filename = KFileDialog::getOpenFileName("*.csv", i18n("*|CSV Text File"), this);
if (filename.isEmpty())
return false;
curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
if (!csv.importData(filename, curDoc())) {
curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
showStatMsg(i18n("CSV file import failed."));
return false;
}
curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
KMessageBox::information(this,
i18n("Successfully imported the CSV data\n"
"into the current document."), i18n("Successfully Imported"));
showStatMsg(i18n("Successfully imported"));
setVirgin(false);
return true;
}
void PwM::exportToKWallet()
{
#ifdef CONFIG_KWALLETIF
if (!checkAndAskForKWalletEmu())
return;
PWM_ASSERT(curDoc());
if (curDoc()->isDocEmpty()) {
KMessageBox::information(this,
i18n
("Sorry, there's nothing to export.\n"
"Please first add some passwords."),
i18n("nothing to do"));
init->initKWalletEmu();
return;
}
curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
KWalletIf walletIf(this);
if (walletIf.kwalletExport(curDoc())) {
KMessageBox::information(this,
i18n("Successfully exported the data of the current "
"document to KWallet."),
i18n("Successfully exported data."));
showStatMsg(i18n("Successfully exported data."));
}
init->initKWalletEmu();
curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
#endif // CONFIG_KWALLETIF
}
bool PwM::importFromGpasman()
{
if (!isVirgin()) {
if (KMessageBox::questionYesNo(this,
i18n("Do you want to import the data\n"
"into the current document? (If you\n"
"select \"no\", a new document will be\n"
"opened.)"),
i18n("import into this document?"))
== KMessageBox::No) {
// import the data to a new window.
PwM *newInstance = init->createMainWnd();
bool ok = newInstance->importFromGpasman();
if (!ok) {
newInstance->setForceQuit(true);
delete_and_null(newInstance);
}
return ok;
}
}
curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
PwMerror ret;
QString path(KFileDialog::getOpenFileName(QString::null,
i18n("*|Gpasman or Kpasman file"), this));
if (path == "")
goto cancelImport;
ret = curDoc()->importFromGpasman(&path);
if (ret == e_wrongPw) {
if (KMessageBox::questionYesNo(this,
i18n
("This is probably the wrong master-password\n"
"you have typed in.\n"
"There is no real way to determine the\n"
"correctness of the password in the Gpasman\n"
"file-format. But I think this\n"
"password ist wrong.\n"
"Do you want to continue nevertheless?"),
i18n("password error"))
== KMessageBox::No) {
goto cancelImport;
}
} else if (ret != e_success) {
KMessageBox::error(this,
i18n("Could not import file!\n"
"Do you have permission to read this file?"),
i18n("import failed"));
goto cancelImport;
}
setVirgin(false);
curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
return true;
cancelImport:
curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
return false;
}
#ifdef CONFIG_KWALLETIF
bool PwM::checkAndAskForKWalletEmu()
{
if (init->kwalletEmu()) {
/* KWallet emulation is enabled. We can't import/export
* data from/to it, while emulation is active.
*/
if (KMessageBox::questionYesNo(this,
i18n("KWallet emulation is enabled.\n"
"You can't import or export data from/to "
"the original KWallet, while the emulation "
"is active.\n"
"Do you want to tempoarly disable the KWallet emulation?"),
i18n("Tempoarly disable KWallet emulation?"))
== KMessageBox::Yes) {
init->initKWalletEmu(true);
PWM_ASSERT(!init->kwalletEmu());
return true;
}
return false;
}
return true;
}
#endif // CONFIG_KWALLETIF
bool PwM::importKWallet()
{
#ifdef CONFIG_KWALLETIF
if (!checkAndAskForKWalletEmu())
return false;
KWalletIf walletIf(this);
if (!isVirgin()) {
if (KMessageBox::questionYesNo(this,
i18n("Do you want to import the data "
"into the current document? (If you "
"select \"no\", a new document will be "
"opened.)"),
i18n("import into this document?"))
== KMessageBox::No) {
// import the data to a new window.
PwM *newInstance = init->createMainWnd();
bool ok = newInstance->importKWallet();
if (!ok) {
newInstance->setForceQuit(true);
delete_and_null(newInstance);
goto exit_fail;
} else {
goto exit_ok;
}
}
}
curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
if (!walletIf.kwalletImport(curDoc())) {
curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
showStatMsg(i18n("KWallet import failed"));
goto exit_fail;
}
KMessageBox::information(this,
i18n("Successfully imported the KWallet data "
"into the current document."),
i18n("successfully imported"));
showStatMsg(i18n("successfully imported"));
setVirgin(false);
curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
exit_ok:
init->initKWalletEmu();
return true;
exit_fail:
init->initKWalletEmu();
#endif // CONFIG_KWALLETIF
return false;
}
void PwM::print_slot()
{
curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
#ifndef PWM_EMBEDDED
PwMPrint p(curDoc(), this);
p.printNow();
#else
qDebug("PwM::print_slot , PRINTING IS NOT IMPLEMENTED");
#endif
curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
}
void PwM::genNewCard_slot()
{
#ifdef CONFIG_KEYCARD
init->keycard()->genNewCard();
#endif
}
void PwM::eraseCard_slot()
{
#ifdef CONFIG_KEYCARD
init->keycard()->eraseCard();
#endif
}
void PwM::readCardId_slot()
{
#ifdef CONFIG_KEYCARD
init->keycard()->displayKey();
#endif
}
void PwM::makeCardBackup_slot()
{
#ifdef CONFIG_KEYCARD
init->keycard()->makeBackupImage();
#endif
}
void PwM::replayCardBackup_slot()
{
#ifdef CONFIG_KEYCARD
init->keycard()->replayBackupImage();
#endif
}
void PwM::execLauncher_slot()
{
PWM_ASSERT(curDoc());
if (curDoc()->isDeepLocked())
return;
unsigned int curEntryIndex;
if (!view->getCurEntryIndex(&curEntryIndex))
return;
bool ret = curDoc()->execLauncher(view->getCurrentCategory(),
curEntryIndex);
if (ret)
showStatMsg(i18n("Executed the \"Launcher\"."));
else
showStatMsg(i18n("ERROR: Couldn't execute the \"Launcher\"!"));
}
void PwM::goToURL_slot()
{
PWM_ASSERT(curDoc());
if (curDoc()->isDeepLocked())
return;
unsigned int curEntryIndex;
if (!view->getCurEntryIndex(&curEntryIndex))
return;
bool ret = curDoc()->goToURL(view->getCurrentCategory(),
curEntryIndex);
if (ret)
showStatMsg(i18n("started browser with current URL."));
else
showStatMsg(i18n("ERROR: Couldn't start browser! Maybe invalid URL?"));
}
void PwM::copyToClipboard(const QString &s)
{
QClipboard *cb = QApplication::clipboard();
#ifndef PWM_EMBEDDED
if (cb->supportsSelection())
cb->setText(s, QClipboard::Selection);
cb->setText(s, QClipboard::Clipboard);
#else
cb->setText(s);
#endif
}
void PwM::showStatMsg(const QString &msg)
{
#ifdef DESKTOP_VERSION
statusBar()->message(msg, STATUSBAR_MSG_TIMEOUT * 1000);
#else
qDebug("Statusbar : %s",msg.latin1());
Global::statusMessage(msg);
#endif
}
void PwM::focusInEvent(QFocusEvent *e)
{
if (e->gotFocus()) {
emit gotFocus(this);
} else if (e->lostFocus()) {
emit lostFocus(this);
}
}
#ifdef PWM_EMBEDDED
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)
{
PWM_ASSERT(curDoc());
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();
//US curDoc()->sync sets the dirtyFlag in case the sync was successfull.
save();
}
return ret;
}
+
+void PwM::removeSyncInfo( QString syncProfile)
+{
+ qDebug("PWM::not implemented: removeSyncInfo for profile %s ", syncProfile.latin1());
+}
+
#endif
#ifndef PWM_EMBEDDED
#include "pwm.moc"
#endif
diff --git a/pwmanager/pwmanager/pwm.h b/pwmanager/pwmanager/pwm.h
index 5822d59..fb34bca 100644
--- a/pwmanager/pwmanager/pwm.h
+++ b/pwmanager/pwmanager/pwm.h
@@ -1,297 +1,298 @@
/***************************************************************************
* *
* 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.0.1 of pwmanager
* and was modified to run on embedded devices that run microkde
*
* $Id$
**************************************************************************/
#ifndef __PWM_H
#define __PWM_H
#include <kpopupmenu.h>
#include <klistview.h>
#include <kmainwindow.h>
#ifndef PWM_EMBEDDED
#include <kwin.h>
#include <kapp.h>
#include <kdeversion.h>
#else
#include <ksyncmanager.h>
#endif
#include <kaction.h>
#include <qglobal.h>
#include "pwmview.h"
#include "pwmexception.h"
/** timeout for displaying a message on the status-bar (in seconds) */
#define STATUSBAR_MSG_TIMEOUT 5
class PwMInit;
class KSyncManager;
/** PwM is the base class of the project */
#ifndef PWM_EMBEDDED
//MOC_SKIP_BEGIN
class PwM : public KMainWindow
//MOC_SKIP_END
#else
class PwM : public KMainWindow, public KSyncInterface
#endif
{
Q_OBJECT
public:
friend class PwMView;
/** construtor */
PwM(PwMInit *_init, PwMDoc *doc,
bool virginity = true,
QWidget* parent = 0, const char *name = 0);
/** destructor */
~PwM();
/** copy some text to the global clipboard */
static void copyToClipboard(const QString &s);
/** returns pointer to the view */
PwMView * curView()
{ return view; }
/** returns pointer to the currently using document. */
PwMDoc * curDoc()
{ return curView()->document(); }
/** open a new doc with the given filename */
PwMDoc * openDoc(QString filename, bool openDeepLocked = false);
/** show a message on the global status bar.
* The message times out after some seconds.
*/
void showStatMsg(const QString &msg);
/** ask the user where to save the doc (if it has not been saved, yet)
* and write the data to disk.
*/
bool save();
/** 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/export/csv triggered */
void exportToCsv();
/** file/import/text triggered */
bool importFromText();
/** file/import/gpasman triggered */
bool importFromGpasman();
/** file/import/kwallet triggered */
bool importKWallet();
/** file/import/csv triggered */
bool importCsv();
/** file/print triggered */
void print_slot();
/** manage/add triggered */
//US ENH : changed code to run with older MOC
void addPwd_slot();
void addPwd_slot1(QString *pw, PwMDoc *_doc);
/** manage/edit triggered */
//US ENH : changed code to run with older MOC
void editPwd_slot();
void editPwd_slot1(const QString *category);
void editPwd_slot3(const QString *category, const int *index ,PwMDoc *_doc );
/** 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 */
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 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 cf8690f..fd17ce5 100644
--- a/pwmanager/pwmanager/pwmdoc.cpp
+++ b/pwmanager/pwmanager/pwmdoc.cpp
@@ -2923,576 +2923,579 @@ void PwMDoc::ensureLvp()
//Now start with the sorted and reset listviewpos.
sortedBegin = sorted.begin();
sortedEnd = sorted.end();
sortedI = sortedBegin;
while (sortedI != sortedEnd) {
// qDebug("reset defined: %s, from pos=%i to pos=%i", (*sortedI)->desc.c_str(), (*sortedI)->listViewPos, lvpTop+1);
(*sortedI)->listViewPos = ++lvpTop;
++sortedI;
}
/*/debug
entrBegin = catI->d.begin();
entrEnd = catI->d.end();
entrI = entrBegin;
while (entrI != entrEnd) {
qDebug("check: %s, pos=%i", (*entrI).desc.c_str(), (*entrI).listViewPos);
++entrI;
}
*/
++catI;
}
}
QString PwMDoc::getTitle()
{
/* NOTE: We have to ensure, that the returned title
* is unique and not reused somewhere else while
* 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();
PWM_ASSERT(unnamedNum != 0);
}
title = DEFAULT_TITLE;
title += " ";
title += tostr(unnamedNum).c_str();
}
return title;
}
bool PwMDoc::tryDelete()
{
if (deleted)
return true;
int ret;
if (isDirty()) {
ret = dirtyAskSave(getTitle());
if (ret == 0) { // save to disk
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.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.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()) {
if (manager->isProgressBarCanceled())
return e_syncError;
if ( incCounter % modulo == 0 )
manager->showProgressBar(incCounter);
uid = er[ incCounter ];
qDebug("sync uid %s from remote file", uid.latin1());
qApp->processEvents();
inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal );
inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote );
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, inLocal->desc.c_str());
if ( take == 3 )
return e_syncError;
if ( take == 1 ) {// take local
int oldlistpos = inRemote->listViewPos;
(*inRemote) = (*inLocal);
inRemote->listViewPos = oldlistpos;
++changedRemote;
} else { // take == 2 take remote
int oldlistpos = inLocal->listViewPos;
(*inLocal) = (*inRemote);
inLocal->listViewPos = oldlistpos;
++changedLocal;
}
}
} else { // no conflict
if ( inRemote->meta.update > mLastSync || mode == 5 ) {
inRemote->meta.update = modifiedSync;
//first check if we have a matching category in the local file
const string* remotecat = syncRemote->getCategory(catRemote);
syncLocal->addEntry(remotecat->c_str(), inRemote, true, false);
++addedPasswordsLocal;
} else {
// pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
syncRemote->delEntry(catRemote, indexRemote, true);
++deletedPasswordsRemote;
}
}
++incCounter;
}
er.clear();
QStringList el = syncLocal->getIDEntryList();
modulo = (el.count()/10)+1;
manager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
incCounter = 0;
while ( incCounter < el.count()) {
qApp->processEvents();
if (manager->isProgressBarCanceled())
return e_syncError;
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 );
PWM_ASSERT(inLocal);
if ( inRemote == 0 ) {
if ( inLocal->meta.update < mLastSync && mode != 4 ) {
// pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
syncLocal->delEntry(catLocal, indexLocal, true);
++deletedPasswordsLocal;
} else {
if ( ! manager->mWriteBackExistingOnly ) {
++addedPasswordsRemote;
inLocal->meta.update = modifiedSync;
//first check if we have a matching category in the remote file
const string* localcat = syncLocal->getCategory(catLocal);
PwMDataItem newEntry;
newEntry = *inLocal;
inRemote = &newEntry;
//USsyncRemote->insertAddressee( inRemote, false );
syncRemote->addEntry(localcat->c_str(), inRemote, true, false);
}
}
}
++incCounter;
}
el.clear();
manager->hideProgressBar();
// Now write the info back into the sync data space of the files
mLastSync = QDateTime::currentDateTime().addSecs( 1 );
// get rid of micro seconds
QTime t = mLastSync.time();
mLastSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
syncItemLocal->lastSyncDate = mLastSync;
syncItemRemote->lastSyncDate = mLastSync;
QString mes;
mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedPasswordsLocal, addedPasswordsRemote, changedLocal, changedRemote, deletedPasswordsLocal, deletedPasswordsRemote );
if ( manager->mShowSyncSummary ) {
KMessageBox::information(0, mes, i18n("PWM/Pi Synchronization") );
}
qDebug( mes );
return e_success;
}
int PwMDoc::takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full )
{
// 0 equal
// 1 take local
// 2 take remote
// 3 cancel
QDateTime localMod = local->meta.update;
QDateTime remoteMod = remote->meta.update;
if ( localMod == remoteMod )
return 0;
qDebug(" %d %d conflict on %s %s ", mode, full, local->desc.c_str(), remote->desc.c_str() );
//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
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)
+{
+ qDebug("PwMDoc::not implemented: removeSyncInfo for profile %s ", syncProfile.latin1());
+}
//this are the overwritten callbackmethods from the syncinterface
bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode)
{
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();
bool exists = findSyncData(d->syncName.c_str(), &index);
if (exists == true) {
// DOH! We found this entry.
return e_entryExists;
}
dti.syncDta.push_back(*d);
if (!dontFlagDirty)
flagDirty();
return e_success;
}
/** delete syncdata entry */
bool PwMDoc::delSyncDataEntry(unsigned int index, bool dontFlagDirty)
{
if (isDeepLocked())
return false;
if (index > dti.syncDta.size() - 1)
return false;
// delete entry
dti.syncDta.erase(dti.syncDta.begin() + index);
if (!dontFlagDirty)
flagDirty();
return true;
}
PwMDataItem* PwMDoc::findEntryByID(const QString &uid, unsigned int *category, unsigned int *index)
{
vector<PwMCategoryItem>::iterator catcounter = dti.dta.begin(),
catend = dti.dta.end();
vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI;
while (catcounter != catend) {
entrBegin = catcounter->d.begin();
entrEnd = catcounter->d.end();
entrI = entrBegin;
while (entrI != entrEnd) {
if ((*entrI).meta.uniqueid == uid.latin1()) {
if (category)
*category = catcounter - dti.dta.begin();
if (index)
*index = entrI - entrBegin;
return &(*entrI);
}
++entrI;
}
++catcounter;
}
return 0;
}
QStringList PwMDoc::getIDEntryList()
{
QStringList results;
vector<PwMCategoryItem>::iterator catcounter = dti.dta.begin(),
catend = dti.dta.end();
vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI;
while (catcounter != catend) {
entrBegin = catcounter->d.begin();
entrEnd = catcounter->d.end();
entrI = entrBegin;
while (entrI != entrEnd) {
results.append( (*entrI).meta.uniqueid.c_str() );
++entrI;
}
++catcounter;
}
return results;
}
#ifndef PWM_EMBEDDED
#include "pwmdoc.moc"
#endif
diff --git a/pwmanager/pwmanager/pwmdoc.h b/pwmanager/pwmanager/pwmdoc.h
index 55e3231..e419c24 100644
--- a/pwmanager/pwmanager/pwmdoc.h
+++ b/pwmanager/pwmanager/pwmdoc.h
@@ -381,408 +381,409 @@ protected:
/** 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" */
bool isLocked(const QString &category, unsigned int index);
bool isLocked(unsigned int category, unsigned int index)
{ return dti.dta[category].d[index].lockStat; }
/** returns the deeplock status */
bool isDeepLocked()
{ return getDocStatFlag(DOC_STAT_DEEPLOCKED); }
/** (un)lock all entries */
bool lockAll(bool lock);
/** unlocks all entries tempoarly.
* 1st NOTE: Be very careful with this function! :)
* 2nd NOTE: After you have called unlockAll_Tempoary(); ,
* please DON'T forget to call unlockAll_Tempoary(true);
* _before_ the user (or someone else) is able to change
* the document!
* 3rd NOTE: Please DON'T change "dta" while the data is tempoary
* unlocked! This will cause corruption.
*/
bool unlockAll_tempoary(bool revert = false);
/** deep-(un)locks the document.
* deep-locking writes all data to the file, deletes all data
* in memory, but doesn't close the document.
* deep-locking is only available, if the user previously saved
* the doc to a file (with a password).
* If "saveToFile" is false, it does NOT write the data to the file!
*/
PwMerror deepLock(bool lock = true, bool saveToFile = true);
/** is unlockable without pw? */
bool unlockWoPw()
{ return getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); }
/** get the "currentPassword" */
const QString& getCurrentPw()
{ return currentPw; }
/** open a window and request the user to change the mpw */
void changeCurrentPw();
/** set the "listViewPos" variable of "dta" */
void setListViewPos(const QString &category, unsigned int index,
int pos);
/** set the "listViewPos" variable of "dta" */
void setListViewPos(unsigned int category, unsigned int index,
int pos);
/** get the "listViewPos" variable of "dta" */
int getListViewPos(const QString &category, unsigned int index);
/** set the maximum number of entries allowed */
void setMaxNumEntries(unsigned int num = DEFAULT_MAX_ENTRIES)
{ maxEntries = num; }
/** get the maximum number of entries allowed */
unsigned int getMaxNumEntries()
{ return maxEntries; }
/** ensure all listViewPos of all dta items are set. (are ! -1).
* If there are some undefined entries, add them to the end of
* the listViewPos(itions). */
void ensureLvp();
/** execute the "launcher" of this entry */
bool execLauncher(const QString &category, unsigned int entryIndex);
/** see above */
bool execLauncher(unsigned int category, unsigned int entryIndex);
/** open a browser with the URL-section of the given entry */
bool goToURL(const QString &category, unsigned int entryIndex);
/** see above */
bool goToURL(unsigned int category, unsigned int entryIndex);
/** returns true if there is no entry present in the document.
* Note: The "default" Category is present everytime, so
* it's checked for it's entries.
*/
bool isDocEmpty()
{
if (numCategories() > 1)
return false;
if (numEntries(0))
return false;
return true;
}
/** returns the filename of this doc */
const QString& getFilename()
{ return filename; }
/** returns the title of the doc */
QString getTitle();
/** sets the list-view-pointer hold in the doc */
void setListViewPointer(PwMView *_listView)
{ listView = _listView; }
/** returns the list-view-pointer */
PwMView * getListViewPointer()
{ return listView; }
/** try to delete the doc. The user may be asked to save
* the data. The user may cancel the whole operation.
* false is returned, then.
*/
bool tryDelete();
/** is the doc deleted? (with tryDelete() ) */
bool isDeleted()
{ return deleted; }
/** returns the document timer object */
DocTimer * timer()
{ return _timer; }
/** get a lock on the dataChanged signal.
* If someone is holding a lock, the signal is not emitted.
*/
void getDataChangedLock()
{ ++dataChangedLock; }
/** put the dataChanged lock */
void putDataChangedLock()
{ --dataChangedLock; }
/** returns the revision count of the item at cat/index */
unsigned int getEntryRevCnt(unsigned int category, unsigned int index)
{ return dti.dta[category].d[index].rev; }
/** returns a const pointer to the entries meta */
const PwMMetaData * getEntryMeta(unsigned int category, unsigned int index)
{ return &(dti.dta[category].d[index].meta); }
/** is the entry at "category" "index" a binary entry? */
bool isBinEntry(unsigned int category, unsigned int index)
{ return dti.dta[category].d[index].binary; }
public slots:
/** wrapper for PwMTray */
void _deepUnlock();
signals:
/** the data of the document has changed and must be updated
* in all views.
* NOTE: use emitDataChanged(PwMDoc *document) to emit this signal!
*/
void dataChanged(PwMDoc *document);
/** the document class is going to close. This signal may be
* used to nofify all views, that the user closed the document,
* so the views can go down, too.
*/
void docClosed(PwMDoc *document);
/** somebody just opened the document */
void docOpened(PwMDoc *document);
/** this document object just got created */
void docCreated(PwMDoc *document);
public:
/** emit the dataChanged signal after checking for a lock */
void emitDataChanged(PwMDoc *document)
{
if (!dataChangedLock)
emit dataChanged(document);
}
protected:
/** current file for this doc */
QString filename;
//US ENH: we need a place where we keep the syncentries. So I invented
// struct PwMItem, that has a vector of PwMCategoryItem and vector of PwMSyncItem
/** holds all data */
PwMItem dti;
/** maximum number of entries */
unsigned int maxEntries;
/** currently used password to encrypt data */
QString currentPw;
/** current global document status flags */
unsigned int curDocStat;
/** browser process for goToURL() */
KProcess browserProc;
/** 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);
/** read data from file beginning at "pos", decrypt and return it */
PwMerror decrypt(string *d, unsigned int pos, const QString *pw, char algo, 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 void removeSyncInfo( QString syncProfile);
#endif
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);
PwMDataItem* findEntryByID(const QString &uid, unsigned int *category, unsigned int *index);
QStringList getIDEntryList();
};
#endif