summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp33
-rw-r--r--libkdepim/ksyncmanager.cpp186
-rw-r--r--libkdepim/ksyncmanager.h14
-rw-r--r--pwmanager/pwmanager/pwm.cpp22
-rw-r--r--pwmanager/pwmanager/pwm.h1
-rw-r--r--pwmanager/pwmanager/pwmdoc.cpp92
-rw-r--r--pwmanager/pwmanager/pwmdoc.h25
7 files changed, 318 insertions, 55 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index f222234..f8359de 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -825,515 +825,516 @@ void KABCore::setCategories()
825{ 825{
826 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 826 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
827 if ( !dlg.exec() ) 827 if ( !dlg.exec() )
828 return; 828 return;
829 829
830 bool merge = false; 830 bool merge = false;
831 QString msg = i18n( "Merge with existing categories?" ); 831 QString msg = i18n( "Merge with existing categories?" );
832 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 832 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
833 merge = true; 833 merge = true;
834 834
835 QStringList categories = dlg.selectedCategories(); 835 QStringList categories = dlg.selectedCategories();
836 836
837 QStringList uids = mViewManager->selectedUids(); 837 QStringList uids = mViewManager->selectedUids();
838 QStringList::Iterator it; 838 QStringList::Iterator it;
839 for ( it = uids.begin(); it != uids.end(); ++it ) { 839 for ( it = uids.begin(); it != uids.end(); ++it ) {
840 KABC::Addressee addr = mAddressBook->findByUid( *it ); 840 KABC::Addressee addr = mAddressBook->findByUid( *it );
841 if ( !addr.isEmpty() ) { 841 if ( !addr.isEmpty() ) {
842 if ( !merge ) 842 if ( !merge )
843 addr.setCategories( categories ); 843 addr.setCategories( categories );
844 else { 844 else {
845 QStringList addrCategories = addr.categories(); 845 QStringList addrCategories = addr.categories();
846 QStringList::Iterator catIt; 846 QStringList::Iterator catIt;
847 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 847 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
848 if ( !addrCategories.contains( *catIt ) ) 848 if ( !addrCategories.contains( *catIt ) )
849 addrCategories.append( *catIt ); 849 addrCategories.append( *catIt );
850 } 850 }
851 addr.setCategories( addrCategories ); 851 addr.setCategories( addrCategories );
852 } 852 }
853 853
854 mAddressBook->insertAddressee( addr ); 854 mAddressBook->insertAddressee( addr );
855 } 855 }
856 } 856 }
857 857
858 if ( uids.count() > 0 ) 858 if ( uids.count() > 0 )
859 setModified( true ); 859 setModified( true );
860} 860}
861 861
862void KABCore::setSearchFields( const KABC::Field::List &fields ) 862void KABCore::setSearchFields( const KABC::Field::List &fields )
863{ 863{
864 mIncSearchWidget->setFields( fields ); 864 mIncSearchWidget->setFields( fields );
865} 865}
866 866
867void KABCore::incrementalSearch( const QString& text ) 867void KABCore::incrementalSearch( const QString& text )
868{ 868{
869 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 869 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
870} 870}
871 871
872void KABCore::setModified() 872void KABCore::setModified()
873{ 873{
874 setModified( true ); 874 setModified( true );
875} 875}
876 876
877void KABCore::setModifiedWOrefresh() 877void KABCore::setModifiedWOrefresh()
878{ 878{
879 // qDebug("KABCore::setModifiedWOrefresh() "); 879 // qDebug("KABCore::setModifiedWOrefresh() ");
880 mModified = true; 880 mModified = true;
881 mActionSave->setEnabled( mModified ); 881 mActionSave->setEnabled( mModified );
882#ifdef DESKTOP_VERSION 882#ifdef DESKTOP_VERSION
883 mDetails->refreshView(); 883 mDetails->refreshView();
884#endif 884#endif
885 885
886} 886}
887void KABCore::setModified( bool modified ) 887void KABCore::setModified( bool modified )
888{ 888{
889 mModified = modified; 889 mModified = modified;
890 mActionSave->setEnabled( mModified ); 890 mActionSave->setEnabled( mModified );
891 891
892 if ( modified ) 892 if ( modified )
893 mJumpButtonBar->recreateButtons(); 893 mJumpButtonBar->recreateButtons();
894 894
895 mViewManager->refreshView(); 895 mViewManager->refreshView();
896 mDetails->refreshView(); 896 mDetails->refreshView();
897 897
898} 898}
899 899
900bool KABCore::modified() const 900bool KABCore::modified() const
901{ 901{
902 return mModified; 902 return mModified;
903} 903}
904 904
905void KABCore::contactModified( const KABC::Addressee &addr ) 905void KABCore::contactModified( const KABC::Addressee &addr )
906{ 906{
907 907
908 Command *command = 0; 908 Command *command = 0;
909 QString uid; 909 QString uid;
910 910
911 // check if it exists already 911 // check if it exists already
912 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 912 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
913 if ( origAddr.isEmpty() ) 913 if ( origAddr.isEmpty() )
914 command = new PwNewCommand( mAddressBook, addr ); 914 command = new PwNewCommand( mAddressBook, addr );
915 else { 915 else {
916 command = new PwEditCommand( mAddressBook, origAddr, addr ); 916 command = new PwEditCommand( mAddressBook, origAddr, addr );
917 uid = addr.uid(); 917 uid = addr.uid();
918 } 918 }
919 919
920 UndoStack::instance()->push( command ); 920 UndoStack::instance()->push( command );
921 RedoStack::instance()->clear(); 921 RedoStack::instance()->clear();
922 922
923 setModified( true ); 923 setModified( true );
924} 924}
925 925
926void KABCore::newContact() 926void KABCore::newContact()
927{ 927{
928 928
929 929
930 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 930 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
931 931
932 QPtrList<KRES::Resource> kresResources; 932 QPtrList<KRES::Resource> kresResources;
933 QPtrListIterator<KABC::Resource> it( kabcResources ); 933 QPtrListIterator<KABC::Resource> it( kabcResources );
934 KABC::Resource *resource; 934 KABC::Resource *resource;
935 while ( ( resource = it.current() ) != 0 ) { 935 while ( ( resource = it.current() ) != 0 ) {
936 ++it; 936 ++it;
937 if ( !resource->readOnly() ) { 937 if ( !resource->readOnly() ) {
938 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 938 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
939 if ( res ) 939 if ( res )
940 kresResources.append( res ); 940 kresResources.append( res );
941 } 941 }
942 } 942 }
943 943
944 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 944 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
945 resource = static_cast<KABC::Resource*>( res ); 945 resource = static_cast<KABC::Resource*>( res );
946 946
947 if ( resource ) { 947 if ( resource ) {
948 KABC::Addressee addr; 948 KABC::Addressee addr;
949 addr.setResource( resource ); 949 addr.setResource( resource );
950 mEditorDialog->setAddressee( addr ); 950 mEditorDialog->setAddressee( addr );
951 KApplication::execDialog ( mEditorDialog ); 951 KApplication::execDialog ( mEditorDialog );
952 952
953 } else 953 } else
954 return; 954 return;
955 955
956 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 956 // mEditorDict.insert( dialog->addressee().uid(), dialog );
957 957
958 958
959} 959}
960 960
961void KABCore::addEmail( QString aStr ) 961void KABCore::addEmail( QString aStr )
962{ 962{
963#ifndef KAB_EMBEDDED 963#ifndef KAB_EMBEDDED
964 QString fullName, email; 964 QString fullName, email;
965 965
966 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 966 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
967 967
968 // Try to lookup the addressee matching the email address 968 // Try to lookup the addressee matching the email address
969 bool found = false; 969 bool found = false;
970 QStringList emailList; 970 QStringList emailList;
971 KABC::AddressBook::Iterator it; 971 KABC::AddressBook::Iterator it;
972 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 972 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
973 emailList = (*it).emails(); 973 emailList = (*it).emails();
974 if ( emailList.contains( email ) > 0 ) { 974 if ( emailList.contains( email ) > 0 ) {
975 found = true; 975 found = true;
976 (*it).setNameFromString( fullName ); 976 (*it).setNameFromString( fullName );
977 editContact( (*it).uid() ); 977 editContact( (*it).uid() );
978 } 978 }
979 } 979 }
980 980
981 if ( !found ) { 981 if ( !found ) {
982 KABC::Addressee addr; 982 KABC::Addressee addr;
983 addr.setNameFromString( fullName ); 983 addr.setNameFromString( fullName );
984 addr.insertEmail( email, true ); 984 addr.insertEmail( email, true );
985 985
986 mAddressBook->insertAddressee( addr ); 986 mAddressBook->insertAddressee( addr );
987 mViewManager->refreshView( addr.uid() ); 987 mViewManager->refreshView( addr.uid() );
988 editContact( addr.uid() ); 988 editContact( addr.uid() );
989 } 989 }
990#else //KAB_EMBEDDED 990#else //KAB_EMBEDDED
991 qDebug("KABCore::addEmail finsih method"); 991 qDebug("KABCore::addEmail finsih method");
992#endif //KAB_EMBEDDED 992#endif //KAB_EMBEDDED
993} 993}
994 994
995void KABCore::importVCard( const KURL &url, bool showPreview ) 995void KABCore::importVCard( const KURL &url, bool showPreview )
996{ 996{
997 mXXPortManager->importVCard( url, showPreview ); 997 mXXPortManager->importVCard( url, showPreview );
998} 998}
999void KABCore::importFromOL() 999void KABCore::importFromOL()
1000{ 1000{
1001#ifdef _WIN32_ 1001#ifdef _WIN32_
1002 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1002 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1003 idgl->exec(); 1003 idgl->exec();
1004 KABC::Addressee::List list = idgl->getAddressList(); 1004 KABC::Addressee::List list = idgl->getAddressList();
1005 if ( list.count() > 0 ) { 1005 if ( list.count() > 0 ) {
1006 KABC::Addressee::List listNew; 1006 KABC::Addressee::List listNew;
1007 KABC::Addressee::List listExisting; 1007 KABC::Addressee::List listExisting;
1008 KABC::Addressee::List::Iterator it; 1008 KABC::Addressee::List::Iterator it;
1009 KABC::AddressBook::Iterator iter; 1009 KABC::AddressBook::Iterator iter;
1010 for ( it = list.begin(); it != list.end(); ++it ) { 1010 for ( it = list.begin(); it != list.end(); ++it ) {
1011 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1011 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1012 listNew.append( (*it) ); 1012 listNew.append( (*it) );
1013 else 1013 else
1014 listExisting.append( (*it) ); 1014 listExisting.append( (*it) );
1015 } 1015 }
1016 if ( listExisting.count() > 0 ) 1016 if ( listExisting.count() > 0 )
1017 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1017 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1018 if ( listNew.count() > 0 ) { 1018 if ( listNew.count() > 0 ) {
1019 pasteWithNewUid = false; 1019 pasteWithNewUid = false;
1020 pasteContacts( listNew ); 1020 pasteContacts( listNew );
1021 pasteWithNewUid = true; 1021 pasteWithNewUid = true;
1022 } 1022 }
1023 } 1023 }
1024 delete idgl; 1024 delete idgl;
1025#endif 1025#endif
1026} 1026}
1027 1027
1028void KABCore::importVCard( const QString &vCard, bool showPreview ) 1028void KABCore::importVCard( const QString &vCard, bool showPreview )
1029{ 1029{
1030 mXXPortManager->importVCard( vCard, showPreview ); 1030 mXXPortManager->importVCard( vCard, showPreview );
1031} 1031}
1032 1032
1033//US added a second method without defaultparameter 1033//US added a second method without defaultparameter
1034void KABCore::editContact2() { 1034void KABCore::editContact2() {
1035 editContact( QString::null ); 1035 editContact( QString::null );
1036} 1036}
1037 1037
1038void KABCore::editContact( const QString &uid ) 1038void KABCore::editContact( const QString &uid )
1039{ 1039{
1040 1040
1041 if ( mExtensionManager->isQuickEditVisible() ) 1041 if ( mExtensionManager->isQuickEditVisible() )
1042 return; 1042 return;
1043 1043
1044 // First, locate the contact entry 1044 // First, locate the contact entry
1045 QString localUID = uid; 1045 QString localUID = uid;
1046 if ( localUID.isNull() ) { 1046 if ( localUID.isNull() ) {
1047 QStringList uidList = mViewManager->selectedUids(); 1047 QStringList uidList = mViewManager->selectedUids();
1048 if ( uidList.count() > 0 ) 1048 if ( uidList.count() > 0 )
1049 localUID = *( uidList.at( 0 ) ); 1049 localUID = *( uidList.at( 0 ) );
1050 } 1050 }
1051 1051
1052 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1052 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1053 if ( !addr.isEmpty() ) { 1053 if ( !addr.isEmpty() ) {
1054 mEditorDialog->setAddressee( addr ); 1054 mEditorDialog->setAddressee( addr );
1055 KApplication::execDialog ( mEditorDialog ); 1055 KApplication::execDialog ( mEditorDialog );
1056 } 1056 }
1057} 1057}
1058 1058
1059/** 1059/**
1060 Shows or edits the detail view for the given uid. If the uid is QString::null, 1060 Shows or edits the detail view for the given uid. If the uid is QString::null,
1061 the method will try to find a selected addressee in the view. 1061 the method will try to find a selected addressee in the view.
1062 */ 1062 */
1063void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1063void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1064{ 1064{
1065 if ( mMultipleViewsAtOnce ) 1065 if ( mMultipleViewsAtOnce )
1066 { 1066 {
1067 editContact( uid ); 1067 editContact( uid );
1068 } 1068 }
1069 else 1069 else
1070 { 1070 {
1071 setDetailsVisible( true ); 1071 setDetailsVisible( true );
1072 mActionDetails->setChecked(true); 1072 mActionDetails->setChecked(true);
1073 } 1073 }
1074 1074
1075} 1075}
1076 1076
1077void KABCore::save() 1077void KABCore::save()
1078{ 1078{
1079 if (syncManager->blockSave()) 1079 if (syncManager->blockSave())
1080 return; 1080 return;
1081 syncManager->setBlockSave(true);
1082 if ( !mModified ) 1081 if ( !mModified )
1083 return; 1082 return;
1083
1084 syncManager->setBlockSave(true);
1084 QString text = i18n( "There was an error while attempting to save\n the " 1085 QString text = i18n( "There was an error while attempting to save\n the "
1085 "address book. Please check that some \nother application is " 1086 "address book. Please check that some \nother application is "
1086 "not using it. " ); 1087 "not using it. " );
1087 statusMessage(i18n("Saving addressbook ... ")); 1088 statusMessage(i18n("Saving addressbook ... "));
1088#ifndef KAB_EMBEDDED 1089#ifndef KAB_EMBEDDED
1089 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1090 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1090 if ( !b || !b->save() ) { 1091 if ( !b || !b->save() ) {
1091 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1092 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1092 } 1093 }
1093#else //KAB_EMBEDDED 1094#else //KAB_EMBEDDED
1094 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1095 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1095 if ( !b || !b->save() ) { 1096 if ( !b || !b->save() ) {
1096 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1097 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1097 } 1098 }
1098#endif //KAB_EMBEDDED 1099#endif //KAB_EMBEDDED
1099 1100
1100 statusMessage(i18n("Addressbook saved!")); 1101 statusMessage(i18n("Addressbook saved!"));
1101 setModified( false ); 1102 setModified( false );
1102 syncManager->setBlockSave(false); 1103 syncManager->setBlockSave(false);
1103} 1104}
1104 1105
1105void KABCore::statusMessage(QString mess , int time ) 1106void KABCore::statusMessage(QString mess , int time )
1106{ 1107{
1107 //topLevelWidget()->setCaption( mess ); 1108 //topLevelWidget()->setCaption( mess );
1108 // pending setting timer to revome message 1109 // pending setting timer to revome message
1109} 1110}
1110void KABCore::undo() 1111void KABCore::undo()
1111{ 1112{
1112 UndoStack::instance()->undo(); 1113 UndoStack::instance()->undo();
1113 1114
1114 // Refresh the view 1115 // Refresh the view
1115 mViewManager->refreshView(); 1116 mViewManager->refreshView();
1116} 1117}
1117 1118
1118void KABCore::redo() 1119void KABCore::redo()
1119{ 1120{
1120 RedoStack::instance()->redo(); 1121 RedoStack::instance()->redo();
1121 1122
1122 // Refresh the view 1123 // Refresh the view
1123 mViewManager->refreshView(); 1124 mViewManager->refreshView();
1124} 1125}
1125 1126
1126void KABCore::setJumpButtonBarVisible( bool visible ) 1127void KABCore::setJumpButtonBarVisible( bool visible )
1127{ 1128{
1128 if (mMultipleViewsAtOnce) 1129 if (mMultipleViewsAtOnce)
1129 { 1130 {
1130 if ( visible ) 1131 if ( visible )
1131 mJumpButtonBar->show(); 1132 mJumpButtonBar->show();
1132 else 1133 else
1133 mJumpButtonBar->hide(); 1134 mJumpButtonBar->hide();
1134 } 1135 }
1135 else 1136 else
1136 { 1137 {
1137 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1138 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1138 if (mViewManager->isVisible()) 1139 if (mViewManager->isVisible())
1139 { 1140 {
1140 if ( visible ) 1141 if ( visible )
1141 mJumpButtonBar->show(); 1142 mJumpButtonBar->show();
1142 else 1143 else
1143 mJumpButtonBar->hide(); 1144 mJumpButtonBar->hide();
1144 } 1145 }
1145 else 1146 else
1146 { 1147 {
1147 mJumpButtonBar->hide(); 1148 mJumpButtonBar->hide();
1148 } 1149 }
1149 } 1150 }
1150} 1151}
1151 1152
1152 1153
1153void KABCore::setDetailsToState() 1154void KABCore::setDetailsToState()
1154{ 1155{
1155 setDetailsVisible( mActionDetails->isChecked() ); 1156 setDetailsVisible( mActionDetails->isChecked() );
1156} 1157}
1157 1158
1158 1159
1159 1160
1160void KABCore::setDetailsVisible( bool visible ) 1161void KABCore::setDetailsVisible( bool visible )
1161{ 1162{
1162 if (visible && mDetails->isHidden()) 1163 if (visible && mDetails->isHidden())
1163 { 1164 {
1164 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1165 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1165 if ( addrList.count() > 0 ) 1166 if ( addrList.count() > 0 )
1166 mDetails->setAddressee( addrList[ 0 ] ); 1167 mDetails->setAddressee( addrList[ 0 ] );
1167 } 1168 }
1168 1169
1169 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1170 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1170 // the listview and the detailview. We do that by changing the splitbar size. 1171 // the listview and the detailview. We do that by changing the splitbar size.
1171 if (mMultipleViewsAtOnce) 1172 if (mMultipleViewsAtOnce)
1172 { 1173 {
1173 if ( visible ) 1174 if ( visible )
1174 mDetails->show(); 1175 mDetails->show();
1175 else 1176 else
1176 mDetails->hide(); 1177 mDetails->hide();
1177 } 1178 }
1178 else 1179 else
1179 { 1180 {
1180 if ( visible ) { 1181 if ( visible ) {
1181 mViewManager->hide(); 1182 mViewManager->hide();
1182 mDetails->show(); 1183 mDetails->show();
1183 } 1184 }
1184 else { 1185 else {
1185 mViewManager->show(); 1186 mViewManager->show();
1186 mDetails->hide(); 1187 mDetails->hide();
1187 } 1188 }
1188 setJumpButtonBarVisible( !visible ); 1189 setJumpButtonBarVisible( !visible );
1189 } 1190 }
1190 1191
1191} 1192}
1192 1193
1193void KABCore::extensionChanged( int id ) 1194void KABCore::extensionChanged( int id )
1194{ 1195{
1195 //change the details view only for non desktop systems 1196 //change the details view only for non desktop systems
1196#ifndef DESKTOP_VERSION 1197#ifndef DESKTOP_VERSION
1197 1198
1198 if (id == 0) 1199 if (id == 0)
1199 { 1200 {
1200 //the user disabled the extension. 1201 //the user disabled the extension.
1201 1202
1202 if (mMultipleViewsAtOnce) 1203 if (mMultipleViewsAtOnce)
1203 { // enable detailsview again 1204 { // enable detailsview again
1204 setDetailsVisible( true ); 1205 setDetailsVisible( true );
1205 mActionDetails->setChecked( true ); 1206 mActionDetails->setChecked( true );
1206 } 1207 }
1207 else 1208 else
1208 { //go back to the listview 1209 { //go back to the listview
1209 setDetailsVisible( false ); 1210 setDetailsVisible( false );
1210 mActionDetails->setChecked( false ); 1211 mActionDetails->setChecked( false );
1211 mActionDetails->setEnabled(true); 1212 mActionDetails->setEnabled(true);
1212 } 1213 }
1213 1214
1214 } 1215 }
1215 else 1216 else
1216 { 1217 {
1217 //the user enabled the extension. 1218 //the user enabled the extension.
1218 setDetailsVisible( false ); 1219 setDetailsVisible( false );
1219 mActionDetails->setChecked( false ); 1220 mActionDetails->setChecked( false );
1220 1221
1221 if (!mMultipleViewsAtOnce) 1222 if (!mMultipleViewsAtOnce)
1222 { 1223 {
1223 mActionDetails->setEnabled(false); 1224 mActionDetails->setEnabled(false);
1224 } 1225 }
1225 1226
1226 mExtensionManager->setSelectionChanged(); 1227 mExtensionManager->setSelectionChanged();
1227 1228
1228 } 1229 }
1229 1230
1230#endif// DESKTOP_VERSION 1231#endif// DESKTOP_VERSION
1231 1232
1232} 1233}
1233 1234
1234 1235
1235void KABCore::extensionModified( const KABC::Addressee::List &list ) 1236void KABCore::extensionModified( const KABC::Addressee::List &list )
1236{ 1237{
1237 1238
1238 if ( list.count() != 0 ) { 1239 if ( list.count() != 0 ) {
1239 KABC::Addressee::List::ConstIterator it; 1240 KABC::Addressee::List::ConstIterator it;
1240 for ( it = list.begin(); it != list.end(); ++it ) 1241 for ( it = list.begin(); it != list.end(); ++it )
1241 mAddressBook->insertAddressee( *it ); 1242 mAddressBook->insertAddressee( *it );
1242 if ( list.count() > 1 ) 1243 if ( list.count() > 1 )
1243 setModified(); 1244 setModified();
1244 else 1245 else
1245 setModifiedWOrefresh(); 1246 setModifiedWOrefresh();
1246 } 1247 }
1247 if ( list.count() == 0 ) 1248 if ( list.count() == 0 )
1248 mViewManager->refreshView(); 1249 mViewManager->refreshView();
1249 else 1250 else
1250 mViewManager->refreshView( list[ 0 ].uid() ); 1251 mViewManager->refreshView( list[ 0 ].uid() );
1251 1252
1252 1253
1253 1254
1254} 1255}
1255 1256
1256QString KABCore::getNameByPhone( const QString &phone ) 1257QString KABCore::getNameByPhone( const QString &phone )
1257{ 1258{
1258#ifndef KAB_EMBEDDED 1259#ifndef KAB_EMBEDDED
1259 QRegExp r( "[/*/-/ ]" ); 1260 QRegExp r( "[/*/-/ ]" );
1260 QString localPhone( phone ); 1261 QString localPhone( phone );
1261 1262
1262 bool found = false; 1263 bool found = false;
1263 QString ownerName = ""; 1264 QString ownerName = "";
1264 KABC::AddressBook::Iterator iter; 1265 KABC::AddressBook::Iterator iter;
1265 KABC::PhoneNumber::List::Iterator phoneIter; 1266 KABC::PhoneNumber::List::Iterator phoneIter;
1266 KABC::PhoneNumber::List phoneList; 1267 KABC::PhoneNumber::List phoneList;
1267 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1268 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1268 phoneList = (*iter).phoneNumbers(); 1269 phoneList = (*iter).phoneNumbers();
1269 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1270 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1270 ++phoneIter) { 1271 ++phoneIter) {
1271 // Get rid of separator chars so just the numbers are compared. 1272 // Get rid of separator chars so just the numbers are compared.
1272 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1273 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1273 ownerName = (*iter).formattedName(); 1274 ownerName = (*iter).formattedName();
1274 found = true; 1275 found = true;
1275 } 1276 }
1276 } 1277 }
1277 } 1278 }
1278 1279
1279 return ownerName; 1280 return ownerName;
1280#else //KAB_EMBEDDED 1281#else //KAB_EMBEDDED
1281 qDebug("KABCore::getNameByPhone finsih method"); 1282 qDebug("KABCore::getNameByPhone finsih method");
1282 return ""; 1283 return "";
1283#endif //KAB_EMBEDDED 1284#endif //KAB_EMBEDDED
1284 1285
1285} 1286}
1286 1287
1287void KABCore::openConfigDialog() 1288void KABCore::openConfigDialog()
1288{ 1289{
1289 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1290 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1290 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1291 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1291 ConfigureDialog->addModule(kabcfg ); 1292 ConfigureDialog->addModule(kabcfg );
1292 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1293 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1293 ConfigureDialog->addModule(kdelibcfg ); 1294 ConfigureDialog->addModule(kdelibcfg );
1294 1295
1295 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1296 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1296 this, SLOT( configurationChanged() ) ); 1297 this, SLOT( configurationChanged() ) );
1297 connect( ConfigureDialog, SIGNAL( okClicked() ), 1298 connect( ConfigureDialog, SIGNAL( okClicked() ),
1298 this, SLOT( configurationChanged() ) ); 1299 this, SLOT( configurationChanged() ) );
1299 saveSettings(); 1300 saveSettings();
1300#ifndef DESKTOP_VERSION 1301#ifndef DESKTOP_VERSION
1301 ConfigureDialog->showMaximized(); 1302 ConfigureDialog->showMaximized();
1302#endif 1303#endif
1303 if ( ConfigureDialog->exec() ) 1304 if ( ConfigureDialog->exec() )
1304 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1305 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1305 delete ConfigureDialog; 1306 delete ConfigureDialog;
1306} 1307}
1307 1308
1308void KABCore::openLDAPDialog() 1309void KABCore::openLDAPDialog()
1309{ 1310{
1310#ifndef KAB_EMBEDDED 1311#ifndef KAB_EMBEDDED
1311 if ( !mLdapSearchDialog ) { 1312 if ( !mLdapSearchDialog ) {
1312 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1313 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1313 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1314 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1314 SLOT( refreshView() ) ); 1315 SLOT( refreshView() ) );
1315 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1316 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1316 SLOT( setModified() ) ); 1317 SLOT( setModified() ) );
1317 } else 1318 } else
1318 mLdapSearchDialog->restoreSettings(); 1319 mLdapSearchDialog->restoreSettings();
1319 1320
1320 if ( mLdapSearchDialog->isOK() ) 1321 if ( mLdapSearchDialog->isOK() )
1321 mLdapSearchDialog->exec(); 1322 mLdapSearchDialog->exec();
1322#else //KAB_EMBEDDED 1323#else //KAB_EMBEDDED
1323 qDebug("KABCore::openLDAPDialog() finsih method"); 1324 qDebug("KABCore::openLDAPDialog() finsih method");
1324#endif //KAB_EMBEDDED 1325#endif //KAB_EMBEDDED
1325} 1326}
1326 1327
1327void KABCore::print() 1328void KABCore::print()
1328{ 1329{
1329#ifndef KAB_EMBEDDED 1330#ifndef KAB_EMBEDDED
1330 KPrinter printer; 1331 KPrinter printer;
1331 if ( !printer.setup( this ) ) 1332 if ( !printer.setup( this ) )
1332 return; 1333 return;
1333 1334
1334 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1335 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1335 mViewManager->selectedUids(), this ); 1336 mViewManager->selectedUids(), this );
1336 1337
1337 wizard.exec(); 1338 wizard.exec();
1338#else //KAB_EMBEDDED 1339#else //KAB_EMBEDDED
1339 qDebug("KABCore::print() finsih method"); 1340 qDebug("KABCore::print() finsih method");
@@ -2081,589 +2082,581 @@ void KABCore::requestForDetails(const QString& sourceChannel, const QString& ses
2081#ifndef DESKTOP_VERSION 2082#ifndef DESKTOP_VERSION
2082#ifndef KORG_NODCOP 2083#ifndef KORG_NODCOP
2083 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2084 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2084#endif 2085#endif
2085#endif 2086#endif
2086 2087
2087 mMainWindow->showMaximized(); 2088 mMainWindow->showMaximized();
2088 mMainWindow-> raise(); 2089 mMainWindow-> raise();
2089 2090
2090 mViewManager->setSelected( "", false); 2091 mViewManager->setSelected( "", false);
2091 mViewManager->refreshView( "" ); 2092 mViewManager->refreshView( "" );
2092 mViewManager->setSelected( foundUid, true ); 2093 mViewManager->setSelected( foundUid, true );
2093 mViewManager->refreshView( foundUid ); 2094 mViewManager->refreshView( foundUid );
2094 2095
2095 if ( !mMultipleViewsAtOnce ) 2096 if ( !mMultipleViewsAtOnce )
2096 { 2097 {
2097 setDetailsVisible( true ); 2098 setDetailsVisible( true );
2098 mActionDetails->setChecked(true); 2099 mActionDetails->setChecked(true);
2099 } 2100 }
2100 } 2101 }
2101} 2102}
2102 2103
2103 2104
2104void KABCore::faq() 2105void KABCore::faq()
2105{ 2106{
2106 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2107 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2107} 2108}
2108 2109
2109#include <libkcal/syncdefines.h> 2110#include <libkcal/syncdefines.h>
2110 2111
2111KABC::Addressee KABCore::getLastSyncAddressee() 2112KABC::Addressee KABCore::getLastSyncAddressee()
2112{ 2113{
2113 Addressee lse; 2114 Addressee lse;
2114 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2115 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2115 2116
2116 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2117 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2117 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2118 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2118 if (lse.isEmpty()) { 2119 if (lse.isEmpty()) {
2119 qDebug("Creating new last-syncAddressee "); 2120 qDebug("Creating new last-syncAddressee ");
2120 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2121 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2121 QString sum = ""; 2122 QString sum = "";
2122 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2123 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2123 sum = "E: "; 2124 sum = "E: ";
2124 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2125 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2125 lse.setRevision( mLastAddressbookSync ); 2126 lse.setRevision( mLastAddressbookSync );
2126 lse.setCategories( i18n("SyncEvent") ); 2127 lse.setCategories( i18n("SyncEvent") );
2127 mAddressBook->insertAddressee( lse ); 2128 mAddressBook->insertAddressee( lse );
2128 } 2129 }
2129 return lse; 2130 return lse;
2130} 2131}
2131int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2132int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2132{ 2133{
2133 2134
2134 //void setZaurusId(int id); 2135 //void setZaurusId(int id);
2135 // int zaurusId() const; 2136 // int zaurusId() const;
2136 // void setZaurusUid(int id); 2137 // void setZaurusUid(int id);
2137 // int zaurusUid() const; 2138 // int zaurusUid() const;
2138 // void setZaurusStat(int id); 2139 // void setZaurusStat(int id);
2139 // int zaurusStat() const; 2140 // int zaurusStat() const;
2140 // 0 equal 2141 // 0 equal
2141 // 1 take local 2142 // 1 take local
2142 // 2 take remote 2143 // 2 take remote
2143 // 3 cancel 2144 // 3 cancel
2144 QDateTime lastSync = mLastAddressbookSync; 2145 QDateTime lastSync = mLastAddressbookSync;
2145 QDateTime localMod = local->revision(); 2146 QDateTime localMod = local->revision();
2146 QDateTime remoteMod = remote->revision(); 2147 QDateTime remoteMod = remote->revision();
2147 2148
2148 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2149 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2149 2150
2150 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2151 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2151 bool remCh, locCh; 2152 bool remCh, locCh;
2152 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2153 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2153 2154
2154 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2155 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2155 locCh = ( localMod > mLastAddressbookSync ); 2156 locCh = ( localMod > mLastAddressbookSync );
2156 if ( !remCh && ! locCh ) { 2157 if ( !remCh && ! locCh ) {
2157 //qDebug("both not changed "); 2158 //qDebug("both not changed ");
2158 lastSync = localMod.addDays(1); 2159 lastSync = localMod.addDays(1);
2159 if ( mode <= SYNC_PREF_ASK ) 2160 if ( mode <= SYNC_PREF_ASK )
2160 return 0; 2161 return 0;
2161 } else { 2162 } else {
2162 if ( locCh ) { 2163 if ( locCh ) {
2163 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2164 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2164 lastSync = localMod.addDays( -1 ); 2165 lastSync = localMod.addDays( -1 );
2165 if ( !remCh ) 2166 if ( !remCh )
2166 remoteMod =( lastSync.addDays( -1 ) ); 2167 remoteMod =( lastSync.addDays( -1 ) );
2167 } else { 2168 } else {
2168 //qDebug(" not loc changed "); 2169 //qDebug(" not loc changed ");
2169 lastSync = localMod.addDays( 1 ); 2170 lastSync = localMod.addDays( 1 );
2170 if ( remCh ) 2171 if ( remCh )
2171 remoteMod =( lastSync.addDays( 1 ) ); 2172 remoteMod =( lastSync.addDays( 1 ) );
2172 2173
2173 } 2174 }
2174 } 2175 }
2175 full = true; 2176 full = true;
2176 if ( mode < SYNC_PREF_ASK ) 2177 if ( mode < SYNC_PREF_ASK )
2177 mode = SYNC_PREF_ASK; 2178 mode = SYNC_PREF_ASK;
2178 } else { 2179 } else {
2179 if ( localMod == remoteMod ) 2180 if ( localMod == remoteMod )
2180 return 0; 2181 return 0;
2181 2182
2182 } 2183 }
2183 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 2184 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
2184 2185
2185 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); 2186 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod);
2186 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 2187 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
2187 //full = true; //debug only 2188 //full = true; //debug only
2188 if ( full ) { 2189 if ( full ) {
2189 bool equ = ( (*local) == (*remote) ); 2190 bool equ = ( (*local) == (*remote) );
2190 if ( equ ) { 2191 if ( equ ) {
2191 //qDebug("equal "); 2192 //qDebug("equal ");
2192 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2193 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2193 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2194 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2194 } 2195 }
2195 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2196 if ( mode < SYNC_PREF_FORCE_LOCAL )
2196 return 0; 2197 return 0;
2197 2198
2198 }//else //debug only 2199 }//else //debug only
2199 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2200 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2200 } 2201 }
2201 int result; 2202 int result;
2202 bool localIsNew; 2203 bool localIsNew;
2203 //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() ); 2204 //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() );
2204 2205
2205 if ( full && mode < SYNC_PREF_NEWEST ) 2206 if ( full && mode < SYNC_PREF_NEWEST )
2206 mode = SYNC_PREF_ASK; 2207 mode = SYNC_PREF_ASK;
2207 2208
2208 switch( mode ) { 2209 switch( mode ) {
2209 case SYNC_PREF_LOCAL: 2210 case SYNC_PREF_LOCAL:
2210 if ( lastSync > remoteMod ) 2211 if ( lastSync > remoteMod )
2211 return 1; 2212 return 1;
2212 if ( lastSync > localMod ) 2213 if ( lastSync > localMod )
2213 return 2; 2214 return 2;
2214 return 1; 2215 return 1;
2215 break; 2216 break;
2216 case SYNC_PREF_REMOTE: 2217 case SYNC_PREF_REMOTE:
2217 if ( lastSync > remoteMod ) 2218 if ( lastSync > remoteMod )
2218 return 1; 2219 return 1;
2219 if ( lastSync > localMod ) 2220 if ( lastSync > localMod )
2220 return 2; 2221 return 2;
2221 return 2; 2222 return 2;
2222 break; 2223 break;
2223 case SYNC_PREF_NEWEST: 2224 case SYNC_PREF_NEWEST:
2224 if ( localMod > remoteMod ) 2225 if ( localMod > remoteMod )
2225 return 1; 2226 return 1;
2226 else 2227 else
2227 return 2; 2228 return 2;
2228 break; 2229 break;
2229 case SYNC_PREF_ASK: 2230 case SYNC_PREF_ASK:
2230 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2231 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2231 if ( lastSync > remoteMod ) 2232 if ( lastSync > remoteMod )
2232 return 1; 2233 return 1;
2233 if ( lastSync > localMod ) 2234 if ( lastSync > localMod )
2234 return 2; 2235 return 2;
2235 localIsNew = localMod >= remoteMod; 2236 localIsNew = localMod >= remoteMod;
2236 //qDebug("conflict! ************************************** "); 2237 //qDebug("conflict! ************************************** ");
2237 { 2238 {
2238 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2239 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2239 result = acd.executeD(localIsNew); 2240 result = acd.executeD(localIsNew);
2240 return result; 2241 return result;
2241 } 2242 }
2242 break; 2243 break;
2243 case SYNC_PREF_FORCE_LOCAL: 2244 case SYNC_PREF_FORCE_LOCAL:
2244 return 1; 2245 return 1;
2245 break; 2246 break;
2246 case SYNC_PREF_FORCE_REMOTE: 2247 case SYNC_PREF_FORCE_REMOTE:
2247 return 2; 2248 return 2;
2248 break; 2249 break;
2249 2250
2250 default: 2251 default:
2251 // SYNC_PREF_TAKE_BOTH not implemented 2252 // SYNC_PREF_TAKE_BOTH not implemented
2252 break; 2253 break;
2253 } 2254 }
2254 return 0; 2255 return 0;
2255} 2256}
2256 2257
2257 2258
2258bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2259bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2259{ 2260{
2260 bool syncOK = true; 2261 bool syncOK = true;
2261 int addedAddressee = 0; 2262 int addedAddressee = 0;
2262 int addedAddresseeR = 0; 2263 int addedAddresseeR = 0;
2263 int deletedAddresseeR = 0; 2264 int deletedAddresseeR = 0;
2264 int deletedAddresseeL = 0; 2265 int deletedAddresseeL = 0;
2265 int changedLocal = 0; 2266 int changedLocal = 0;
2266 int changedRemote = 0; 2267 int changedRemote = 0;
2267 2268
2268 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2269 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2269 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2270 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2270 2271
2271 //QPtrList<Addressee> el = local->rawAddressees(); 2272 //QPtrList<Addressee> el = local->rawAddressees();
2272 Addressee addresseeR; 2273 Addressee addresseeR;
2273 QString uid; 2274 QString uid;
2274 int take; 2275 int take;
2275 Addressee addresseeL; 2276 Addressee addresseeL;
2276 Addressee addresseeRSync; 2277 Addressee addresseeRSync;
2277 Addressee addresseeLSync; 2278 Addressee addresseeLSync;
2278 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2279 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2279 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2280 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2280 bool fullDateRange = false; 2281 bool fullDateRange = false;
2281 local->resetTempSyncStat(); 2282 local->resetTempSyncStat();
2282 mLastAddressbookSync = QDateTime::currentDateTime(); 2283 mLastAddressbookSync = QDateTime::currentDateTime();
2283 QDateTime modifiedCalendar = mLastAddressbookSync;; 2284 QDateTime modifiedCalendar = mLastAddressbookSync;;
2284 addresseeLSync = getLastSyncAddressee(); 2285 addresseeLSync = getLastSyncAddressee();
2285 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2286 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2286 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2287 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2287 if ( !addresseeR.isEmpty() ) { 2288 if ( !addresseeR.isEmpty() ) {
2288 addresseeRSync = addresseeR; 2289 addresseeRSync = addresseeR;
2289 remote->removeAddressee(addresseeR ); 2290 remote->removeAddressee(addresseeR );
2290 2291
2291 } else { 2292 } else {
2292 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2293 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2293 addresseeRSync = addresseeLSync ; 2294 addresseeRSync = addresseeLSync ;
2294 } else { 2295 } else {
2295 qDebug("FULLDATE 1"); 2296 qDebug("FULLDATE 1");
2296 fullDateRange = true; 2297 fullDateRange = true;
2297 Addressee newAdd; 2298 Addressee newAdd;
2298 addresseeRSync = newAdd; 2299 addresseeRSync = newAdd;
2299 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2300 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2300 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2301 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2301 addresseeRSync.setRevision( mLastAddressbookSync ); 2302 addresseeRSync.setRevision( mLastAddressbookSync );
2302 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2303 addresseeRSync.setCategories( i18n("SyncAddressee") );
2303 } 2304 }
2304 } 2305 }
2305 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2306 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2306 qDebug("FULLDATE 2"); 2307 qDebug("FULLDATE 2");
2307 fullDateRange = true; 2308 fullDateRange = true;
2308 } 2309 }
2309 if ( ! fullDateRange ) { 2310 if ( ! fullDateRange ) {
2310 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2311 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2311 2312
2312 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2313 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2313 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2314 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2314 fullDateRange = true; 2315 fullDateRange = true;
2315 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2316 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2316 } 2317 }
2317 } 2318 }
2318 // fullDateRange = true; // debug only! 2319 // fullDateRange = true; // debug only!
2319 if ( fullDateRange ) 2320 if ( fullDateRange )
2320 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2321 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2321 else 2322 else
2322 mLastAddressbookSync = addresseeLSync.revision(); 2323 mLastAddressbookSync = addresseeLSync.revision();
2323 // for resyncing if own file has changed 2324 // for resyncing if own file has changed
2324 // PENDING fixme later when implemented 2325 // PENDING fixme later when implemented
2325#if 0 2326#if 0
2326 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2327 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2327 mLastAddressbookSync = loadedFileVersion; 2328 mLastAddressbookSync = loadedFileVersion;
2328 qDebug("setting mLastAddressbookSync "); 2329 qDebug("setting mLastAddressbookSync ");
2329 } 2330 }
2330#endif 2331#endif
2331 2332
2332 //qDebug("*************************** "); 2333 //qDebug("*************************** ");
2333 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2334 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2334 QStringList er = remote->uidList(); 2335 QStringList er = remote->uidList();
2335 Addressee inR ;//= er.first(); 2336 Addressee inR ;//= er.first();
2336 Addressee inL; 2337 Addressee inL;
2337 QProgressBar bar( er.count(),0 ); 2338
2338 bar.setCaption (i18n("Syncing - close to abort!") ); 2339 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2339 2340
2340 int w = 300;
2341 if ( QApplication::desktop()->width() < 320 )
2342 w = 220;
2343 int h = bar.sizeHint().height() ;
2344 int dw = QApplication::desktop()->width();
2345 int dh = QApplication::desktop()->height();
2346 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2347 bar.show();
2348 int modulo = (er.count()/10)+1; 2341 int modulo = (er.count()/10)+1;
2349 int incCounter = 0; 2342 int incCounter = 0;
2350 while ( incCounter < er.count()) { 2343 while ( incCounter < er.count()) {
2351 if ( ! bar.isVisible() ) 2344 if (syncManager->isProgressBarCanceled())
2352 return false; 2345 return false;
2353 if ( incCounter % modulo == 0 ) 2346 if ( incCounter % modulo == 0 )
2354 bar.setProgress( incCounter ); 2347 syncManager->showProgressBar(incCounter);
2348
2355 uid = er[ incCounter ]; 2349 uid = er[ incCounter ];
2356 bool skipIncidence = false; 2350 bool skipIncidence = false;
2357 if ( uid.left(19) == QString("last-syncAddressee-") ) 2351 if ( uid.left(19) == QString("last-syncAddressee-") )
2358 skipIncidence = true; 2352 skipIncidence = true;
2359 QString idS,OidS; 2353 QString idS,OidS;
2360 qApp->processEvents(); 2354 qApp->processEvents();
2361 if ( !skipIncidence ) { 2355 if ( !skipIncidence ) {
2362 inL = local->findByUid( uid ); 2356 inL = local->findByUid( uid );
2363 inR = remote->findByUid( uid ); 2357 inR = remote->findByUid( uid );
2364 //inL.setResource( 0 ); 2358 //inL.setResource( 0 );
2365 //inR.setResource( 0 ); 2359 //inR.setResource( 0 );
2366 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2360 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2367 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { 2361 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) {
2368 //qDebug("take %d %s ", take, inL.summary().latin1()); 2362 //qDebug("take %d %s ", take, inL.summary().latin1());
2369 if ( take == 3 ) 2363 if ( take == 3 )
2370 return false; 2364 return false;
2371 if ( take == 1 ) {// take local 2365 if ( take == 1 ) {// take local
2372 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2366 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2373 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2367 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2374 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2368 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2375 local->insertAddressee( inL, false ); 2369 local->insertAddressee( inL, false );
2376 idS = inR.externalUID(); 2370 idS = inR.externalUID();
2377 OidS = inR.originalExternalUID(); 2371 OidS = inR.originalExternalUID();
2378 } 2372 }
2379 else 2373 else
2380 idS = inR.IDStr(); 2374 idS = inR.IDStr();
2381 remote->removeAddressee( inR ); 2375 remote->removeAddressee( inR );
2382 inR = inL; 2376 inR = inL;
2383 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2377 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2384 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2378 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2385 inR.setOriginalExternalUID( OidS ); 2379 inR.setOriginalExternalUID( OidS );
2386 inR.setExternalUID( idS ); 2380 inR.setExternalUID( idS );
2387 } else { 2381 } else {
2388 inR.setIDStr( idS ); 2382 inR.setIDStr( idS );
2389 } 2383 }
2390 inR.setResource( 0 ); 2384 inR.setResource( 0 );
2391 remote->insertAddressee( inR , false); 2385 remote->insertAddressee( inR , false);
2392 ++changedRemote; 2386 ++changedRemote;
2393 } else { // take == 2 take remote 2387 } else { // take == 2 take remote
2394 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2388 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2395 if ( inR.revision().date().year() < 2004 ) 2389 if ( inR.revision().date().year() < 2004 )
2396 inR.setRevision( modifiedCalendar ); 2390 inR.setRevision( modifiedCalendar );
2397 } 2391 }
2398 idS = inL.IDStr(); 2392 idS = inL.IDStr();
2399 local->removeAddressee( inL ); 2393 local->removeAddressee( inL );
2400 inL = inR; 2394 inL = inR;
2401 inL.setIDStr( idS ); 2395 inL.setIDStr( idS );
2402 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2396 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2403 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2397 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2404 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2398 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2405 } 2399 }
2406 inL.setResource( 0 ); 2400 inL.setResource( 0 );
2407 local->insertAddressee( inL , false ); 2401 local->insertAddressee( inL , false );
2408 ++changedLocal; 2402 ++changedLocal;
2409 } 2403 }
2410 } 2404 }
2411 } else { // no conflict 2405 } else { // no conflict
2412 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2406 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2413 QString des = addresseeLSync.note(); 2407 QString des = addresseeLSync.note();
2414 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2408 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2415 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2409 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2416 remote->insertAddressee( inR, false ); 2410 remote->insertAddressee( inR, false );
2417 ++deletedAddresseeR; 2411 ++deletedAddresseeR;
2418 } else { 2412 } else {
2419 inR.setRevision( modifiedCalendar ); 2413 inR.setRevision( modifiedCalendar );
2420 remote->insertAddressee( inR, false ); 2414 remote->insertAddressee( inR, false );
2421 inL = inR; 2415 inL = inR;
2422 inL.setResource( 0 ); 2416 inL.setResource( 0 );
2423 local->insertAddressee( inL , false); 2417 local->insertAddressee( inL , false);
2424 ++addedAddressee; 2418 ++addedAddressee;
2425 } 2419 }
2426 } else { 2420 } else {
2427 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2421 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2428 inR.setRevision( modifiedCalendar ); 2422 inR.setRevision( modifiedCalendar );
2429 remote->insertAddressee( inR, false ); 2423 remote->insertAddressee( inR, false );
2430 inR.setResource( 0 ); 2424 inR.setResource( 0 );
2431 local->insertAddressee( inR, false ); 2425 local->insertAddressee( inR, false );
2432 ++addedAddressee; 2426 ++addedAddressee;
2433 } else { 2427 } else {
2434 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2428 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2435 remote->removeAddressee( inR ); 2429 remote->removeAddressee( inR );
2436 ++deletedAddresseeR; 2430 ++deletedAddresseeR;
2437 } 2431 }
2438 } 2432 }
2439 } 2433 }
2440 } 2434 }
2441 ++incCounter; 2435 ++incCounter;
2442 } 2436 }
2443 er.clear(); 2437 er.clear();
2444 QStringList el = local->uidList(); 2438 QStringList el = local->uidList();
2445 modulo = (el.count()/10)+1; 2439 modulo = (el.count()/10)+1;
2446 bar.setCaption (i18n("Add / remove addressees") ); 2440
2447 bar.setTotalSteps ( el.count() ) ; 2441 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
2448 bar.show();
2449 incCounter = 0; 2442 incCounter = 0;
2450 while ( incCounter < el.count()) { 2443 while ( incCounter < el.count()) {
2451 qApp->processEvents(); 2444 qApp->processEvents();
2452 if ( ! bar.isVisible() ) 2445 if (syncManager->isProgressBarCanceled())
2453 return false; 2446 return false;
2454 if ( incCounter % modulo == 0 ) 2447 if ( incCounter % modulo == 0 )
2455 bar.setProgress( incCounter ); 2448 syncManager->showProgressBar(incCounter);
2456 uid = el[ incCounter ]; 2449 uid = el[ incCounter ];
2457 bool skipIncidence = false; 2450 bool skipIncidence = false;
2458 if ( uid.left(19) == QString("last-syncAddressee-") ) 2451 if ( uid.left(19) == QString("last-syncAddressee-") )
2459 skipIncidence = true; 2452 skipIncidence = true;
2460 if ( !skipIncidence ) { 2453 if ( !skipIncidence ) {
2461 inL = local->findByUid( uid ); 2454 inL = local->findByUid( uid );
2462 inR = remote->findByUid( uid ); 2455 inR = remote->findByUid( uid );
2463 if ( inR.isEmpty() ) { 2456 if ( inR.isEmpty() ) {
2464 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2457 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2465 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2458 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2466 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2459 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2467 local->removeAddressee( inL ); 2460 local->removeAddressee( inL );
2468 ++deletedAddresseeL; 2461 ++deletedAddresseeL;
2469 } else { 2462 } else {
2470 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { 2463 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) {
2471 inL.removeID(mCurrentSyncDevice ); 2464 inL.removeID(mCurrentSyncDevice );
2472 ++addedAddresseeR; 2465 ++addedAddresseeR;
2473 inL.setRevision( modifiedCalendar ); 2466 inL.setRevision( modifiedCalendar );
2474 local->insertAddressee( inL, false ); 2467 local->insertAddressee( inL, false );
2475 inR = inL; 2468 inR = inL;
2476 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 2469 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2477 inR.setResource( 0 ); 2470 inR.setResource( 0 );
2478 remote->insertAddressee( inR, false ); 2471 remote->insertAddressee( inR, false );
2479 } 2472 }
2480 } 2473 }
2481 } else { 2474 } else {
2482 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2475 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2483 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2476 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2484 local->removeAddressee( inL ); 2477 local->removeAddressee( inL );
2485 ++deletedAddresseeL; 2478 ++deletedAddresseeL;
2486 } else { 2479 } else {
2487 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { 2480 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) {
2488 ++addedAddresseeR; 2481 ++addedAddresseeR;
2489 inL.setRevision( modifiedCalendar ); 2482 inL.setRevision( modifiedCalendar );
2490 local->insertAddressee( inL, false ); 2483 local->insertAddressee( inL, false );
2491 inR = inL; 2484 inR = inL;
2492 inR.setResource( 0 ); 2485 inR.setResource( 0 );
2493 remote->insertAddressee( inR, false ); 2486 remote->insertAddressee( inR, false );
2494 } 2487 }
2495 } 2488 }
2496 } 2489 }
2497 } 2490 }
2498 } 2491 }
2499 ++incCounter; 2492 ++incCounter;
2500 } 2493 }
2501 el.clear(); 2494 el.clear();
2502 bar.hide(); 2495 syncManager->hideProgressBar();
2503 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2496 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2504 // get rid of micro seconds 2497 // get rid of micro seconds
2505 QTime t = mLastAddressbookSync.time(); 2498 QTime t = mLastAddressbookSync.time();
2506 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2499 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2507 addresseeLSync.setRevision( mLastAddressbookSync ); 2500 addresseeLSync.setRevision( mLastAddressbookSync );
2508 addresseeRSync.setRevision( mLastAddressbookSync ); 2501 addresseeRSync.setRevision( mLastAddressbookSync );
2509 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2502 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2510 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2503 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2511 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2504 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2512 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2505 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2513 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2506 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2514 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2507 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2515 addresseeRSync.setNote( "" ) ; 2508 addresseeRSync.setNote( "" ) ;
2516 addresseeLSync.setNote( "" ); 2509 addresseeLSync.setNote( "" );
2517 2510
2518 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2511 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2519 remote->insertAddressee( addresseeRSync, false ); 2512 remote->insertAddressee( addresseeRSync, false );
2520 local->insertAddressee( addresseeLSync, false ); 2513 local->insertAddressee( addresseeLSync, false );
2521 QString mes; 2514 QString mes;
2522 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 ); 2515 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 );
2523 if ( KABPrefs::instance()->mShowSyncSummary ) { 2516 if ( KABPrefs::instance()->mShowSyncSummary ) {
2524 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); 2517 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") );
2525 } 2518 }
2526 qDebug( mes ); 2519 qDebug( mes );
2527 return syncOK; 2520 return syncOK;
2528} 2521}
2529 2522
2530 2523
2531//this is a overwritten callbackmethods from the syncinterface 2524//this is a overwritten callbackmethods from the syncinterface
2532bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 2525bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
2533{ 2526{
2534 2527
2535 //pending prepare addresseeview for output 2528 //pending prepare addresseeview for output
2536 //pending detect, if remote file has REV field. if not switch to external sync 2529 //pending detect, if remote file has REV field. if not switch to external sync
2537 mGlobalSyncMode = SYNC_MODE_NORMAL; 2530 mGlobalSyncMode = SYNC_MODE_NORMAL;
2538 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2531 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2539 2532
2540 AddressBook abLocal(filename,"syncContact"); 2533 AddressBook abLocal(filename,"syncContact");
2541 bool syncOK = false; 2534 bool syncOK = false;
2542 if ( abLocal.load() ) { 2535 if ( abLocal.load() ) {
2543 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2536 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2544 bool external = false; 2537 bool external = false;
2545 bool isXML = false; 2538 bool isXML = false;
2546 if ( filename.right(4) == ".xml") { 2539 if ( filename.right(4) == ".xml") {
2547 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2540 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2548 isXML = true; 2541 isXML = true;
2549 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2542 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2550 } else { 2543 } else {
2551 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2544 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2552 if ( ! lse.isEmpty() ) { 2545 if ( ! lse.isEmpty() ) {
2553 if ( lse.familyName().left(4) == "!E: " ) 2546 if ( lse.familyName().left(4) == "!E: " )
2554 external = true; 2547 external = true;
2555 } else { 2548 } else {
2556 bool found = false; 2549 bool found = false;
2557 AddressBook::Iterator it; 2550 AddressBook::Iterator it;
2558 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2551 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2559 if ( (*it).revision().date().year() > 2003 ) { 2552 if ( (*it).revision().date().year() > 2003 ) {
2560 found = true; 2553 found = true;
2561 break; 2554 break;
2562 } 2555 }
2563 } 2556 }
2564 external = ! found; 2557 external = ! found;
2565 } 2558 }
2566 2559
2567 if ( external ) { 2560 if ( external ) {
2568 qDebug("Setting vcf mode to external "); 2561 qDebug("Setting vcf mode to external ");
2569 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2562 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2570 AddressBook::Iterator it; 2563 AddressBook::Iterator it;
2571 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2564 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2572 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2565 (*it).setID( mCurrentSyncDevice, (*it).uid() );
2573 (*it).computeCsum( mCurrentSyncDevice ); 2566 (*it).computeCsum( mCurrentSyncDevice );
2574 } 2567 }
2575 } 2568 }
2576 } 2569 }
2577 //AddressBook::Iterator it; 2570 //AddressBook::Iterator it;
2578 //QStringList vcards; 2571 //QStringList vcards;
2579 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2572 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2580 // qDebug("Name %s ", (*it).familyName().latin1()); 2573 // qDebug("Name %s ", (*it).familyName().latin1());
2581 //} 2574 //}
2582 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2575 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2583 if ( syncOK ) { 2576 if ( syncOK ) {
2584 if ( KABPrefs::instance()->mWriteBackFile ) 2577 if ( KABPrefs::instance()->mWriteBackFile )
2585 { 2578 {
2586 if ( external ) 2579 if ( external )
2587 abLocal.removeSyncAddressees( !isXML); 2580 abLocal.removeSyncAddressees( !isXML);
2588 qDebug("Saving remote AB "); 2581 qDebug("Saving remote AB ");
2589 abLocal.saveAB(); 2582 abLocal.saveAB();
2590 if ( isXML ) { 2583 if ( isXML ) {
2591 // afterwrite processing 2584 // afterwrite processing
2592 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2585 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2593 } 2586 }
2594 } 2587 }
2595 } 2588 }
2596 setModified(); 2589 setModified();
2597 2590
2598 } 2591 }
2599 if ( syncOK ) 2592 if ( syncOK )
2600 mViewManager->refreshView(); 2593 mViewManager->refreshView();
2601 return syncOK; 2594 return syncOK;
2602#if 0 2595#if 0
2603 2596
2604 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 2597 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
2605 getEventViewerDialog()->setSyncMode( true ); 2598 getEventViewerDialog()->setSyncMode( true );
2606 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 2599 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
2607 getEventViewerDialog()->setSyncMode( false ); 2600 getEventViewerDialog()->setSyncMode( false );
2608 if ( syncOK ) { 2601 if ( syncOK ) {
2609 if ( KOPrefs::instance()->mWriteBackFile ) 2602 if ( KOPrefs::instance()->mWriteBackFile )
2610 { 2603 {
2611 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 2604 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2612 storage->save(); 2605 storage->save();
2613 } 2606 }
2614 } 2607 }
2615 setModified(); 2608 setModified();
2616 } 2609 }
2617 2610
2618#endif 2611#endif
2619} 2612}
2620 2613
2621 2614
2622//this is a overwritten callbackmethods from the syncinterface 2615//this is a overwritten callbackmethods from the syncinterface
2623bool KABCore::syncExternal(KSyncManager* manager, QString resource) 2616bool KABCore::syncExternal(KSyncManager* manager, QString resource)
2624{ 2617{
2625 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2618 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2626 2619
2627 AddressBook abLocal( resource,"syncContact"); 2620 AddressBook abLocal( resource,"syncContact");
2628 bool syncOK = false; 2621 bool syncOK = false;
2629 if ( abLocal.load() ) { 2622 if ( abLocal.load() ) {
2630 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2623 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
2631 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2624 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2632 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2625 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2633 qDebug("KABCore::syncExternal: why do we acces here KABPrefs and not somehow KSyncProfile? "); 2626 qDebug("KABCore::syncExternal: why do we acces here KABPrefs and not somehow KSyncProfile? ");
2634 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, KABPrefs::instance()->mSyncAlgoPrefs ); 2627 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, KABPrefs::instance()->mSyncAlgoPrefs );
2635 if ( syncOK ) { 2628 if ( syncOK ) {
2636 if ( KABPrefs::instance()->mWriteBackFile ) { 2629 if ( KABPrefs::instance()->mWriteBackFile ) {
2637 abLocal.saveAB(); 2630 abLocal.saveAB();
2638 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2631 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2639 } 2632 }
2640 } 2633 }
2641 setModified(); 2634 setModified();
2642 } 2635 }
2643 if ( syncOK ) 2636 if ( syncOK )
2644 mViewManager->refreshView(); 2637 mViewManager->refreshView();
2645 return syncOK; 2638 return syncOK;
2646 2639
2647} 2640}
2648 2641
2649//called by the syncmanager to indicate that the work has to marked as dirty. 2642//called by the syncmanager to indicate that the work has to marked as dirty.
2650void KABCore::sync_setModified() 2643void KABCore::sync_setModified()
2651{ 2644{
2652 setModified(); 2645 setModified();
2653} 2646}
2654 2647
2655//called by the syncmanager to ask if the dirty flag is set. 2648//called by the syncmanager to ask if the dirty flag is set.
2656bool KABCore::sync_isModified() 2649bool KABCore::sync_isModified()
2657{ 2650{
2658 return mModified; 2651 return mModified;
2659} 2652}
2660 2653
2661 2654
2662//called by the syncmanager to indicate that the work has to be saved. 2655//called by the syncmanager to indicate that the work has to be saved.
2663void KABCore::sync_save() 2656void KABCore::sync_save()
2664{ 2657{
2665 save(); 2658 save();
2666} 2659}
2667 2660
2668 2661
2669 2662
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 87f200a..07e6761 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1,529 +1,665 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21// $Id$ 21// $Id$
22 22
23#include "ksyncmanager.h" 23#include "ksyncmanager.h"
24 24
25#include <stdlib.h> 25#include <stdlib.h>
26 26
27#ifndef _WIN32_ 27#ifndef _WIN32_
28#include <unistd.h> 28#include <unistd.h>
29#endif 29#endif
30 30
31 31
32#include "ksyncprofile.h" 32#include "ksyncprofile.h"
33#include "ksyncprefsdialog.h" 33#include "ksyncprefsdialog.h"
34#include "kpimprefs.h" 34#include "kpimprefs.h"
35 35
36#include <qdir.h> 36#include <qdir.h>
37#include <qprogressbar.h>
37#include <qpopupmenu.h> 38#include <qpopupmenu.h>
38#include <qpushbutton.h> 39#include <qpushbutton.h>
39#include <qradiobutton.h> 40#include <qradiobutton.h>
40#include <qbuttongroup.h> 41#include <qbuttongroup.h>
41#include <qtimer.h> 42#include <qtimer.h>
42#include <qmessagebox.h> 43#include <qmessagebox.h>
43#include <qapplication.h> 44#include <qapplication.h>
44#include <qlineedit.h> 45#include <qlineedit.h>
45#include <qdialog.h> 46#include <qdialog.h>
46#include <qlayout.h> 47#include <qlayout.h>
47 48
48#include <klocale.h> 49#include <klocale.h>
49#include <kglobal.h> 50#include <kglobal.h>
50#include <kconfig.h> 51#include <kconfig.h>
51#include <kfiledialog.h> 52#include <kfiledialog.h>
52 53
53KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) 54KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu)
54 : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs), mSyncMenu(syncmenu) 55 : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs), mSyncMenu(syncmenu)
55{ 56{
57 bar = new QProgressBar ( 1, 0 );
58 bar->setCaption ("");
59
60 int w = 300;
61 if ( QApplication::desktop()->width() < 320 )
62 w = 220;
63 int h = bar->sizeHint().height() ;
64 int dw = QApplication::desktop()->width();
65 int dh = QApplication::desktop()->height();
66 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
56 67
57} 68}
58 69
59KSyncManager::~KSyncManager() 70KSyncManager::~KSyncManager()
60{ 71{
61 72 delete bar;
62} 73}
63 74
64 75
65void KSyncManager::fillSyncMenu() 76void KSyncManager::fillSyncMenu()
66{ 77{
67 if ( mSyncMenu->count() ) 78 if ( mSyncMenu->count() )
68 mSyncMenu->clear(); 79 mSyncMenu->clear();
69 80
70 mSyncMenu->insertItem( i18n("Configure..."), 0 ); 81 mSyncMenu->insertItem( i18n("Configure..."), 0 );
71 mSyncMenu->insertSeparator(); 82 mSyncMenu->insertSeparator();
72 mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); 83 mSyncMenu->insertItem( i18n("Multiple sync"), 1 );
73 mSyncMenu->insertSeparator(); 84 mSyncMenu->insertSeparator();
74 85
75 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 86 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
76 config.setGroup("General"); 87 config.setGroup("General");
77 QStringList prof = config.readListEntry("SyncProfileNames"); 88 QStringList prof = config.readListEntry("SyncProfileNames");
78 mPrefs->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 89 mPrefs->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
79 if ( prof.count() < 3 ) { 90 if ( prof.count() < 3 ) {
80 prof.clear(); 91 prof.clear();
81 prof << i18n("Sharp_DTM"); 92 prof << i18n("Sharp_DTM");
82 prof << i18n("Local_file"); 93 prof << i18n("Local_file");
83 prof << i18n("Last_file"); 94 prof << i18n("Last_file");
84 KSyncProfile* temp = new KSyncProfile (); 95 KSyncProfile* temp = new KSyncProfile ();
85 temp->setName( prof[0] ); 96 temp->setName( prof[0] );
86 temp->writeConfig(&config); 97 temp->writeConfig(&config);
87 temp->setName( prof[1] ); 98 temp->setName( prof[1] );
88 temp->writeConfig(&config); 99 temp->writeConfig(&config);
89 temp->setName( prof[2] ); 100 temp->setName( prof[2] );
90 temp->writeConfig(&config); 101 temp->writeConfig(&config);
91 config.setGroup("General"); 102 config.setGroup("General");
92 config.writeEntry("SyncProfileNames",prof); 103 config.writeEntry("SyncProfileNames",prof);
93 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 104 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
94 config.sync(); 105 config.sync();
95 delete temp; 106 delete temp;
96 } 107 }
97 mPrefs->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 108 mPrefs->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
98 mPrefs->mSyncProfileNames = prof; 109 mPrefs->mSyncProfileNames = prof;
99 unsigned int i; 110 unsigned int i;
100 for ( i = 0; i < prof.count(); ++i ) { 111 for ( i = 0; i < prof.count(); ++i ) {
101
102 mSyncMenu->insertItem( prof[i], 1000+i ); 112 mSyncMenu->insertItem( prof[i], 1000+i );
103 if ( i == 2 ) 113 if ( i == 2 )
104 mSyncMenu->insertSeparator(); 114 mSyncMenu->insertSeparator();
105 } 115 }
106 QDir app_dir; 116 QDir app_dir;
107 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 117 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available
108 mSyncMenu->setItemEnabled( false , 1000 ); 118 if ( mTargetApp == PWMPI) {
119 mSyncMenu->removeItem( 1000 );
120 }
121 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
122 mSyncMenu->setItemEnabled( 1000, false );
109 } 123 }
110 //probaly useless 124 //probaly useless
111 //mView->setupExternSyncProfiles(); 125 //mView->setupExternSyncProfiles();
112} 126}
113 127
114void KSyncManager::slotSyncMenu( int action ) 128void KSyncManager::slotSyncMenu( int action )
115{ 129{
116 //qDebug("syncaction %d ", action); 130 //qDebug("syncaction %d ", action);
117 if ( action == 0 ) { 131 if ( action == 0 ) {
118 132
119 // seems to be a Qt2 event handling bug 133 // seems to be a Qt2 event handling bug
120 // syncmenu.clear causes a segfault at first time 134 // syncmenu.clear causes a segfault at first time
121 // when we call it after the main event loop, it is ok 135 // when we call it after the main event loop, it is ok
122 // same behaviour when calling OM/Pi via QCOP for the first time 136 // same behaviour when calling OM/Pi via QCOP for the first time
123 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 137 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
124 //confSync(); 138 //confSync();
125 139
126 return; 140 return;
127 } 141 }
128 if ( action == 1 ) { 142 if ( action == 1 ) {
129 multiSync( true ); 143 multiSync( true );
130 return; 144 return;
131 } 145 }
132 146
133 if (blockSave()) 147 if (blockSave())
134 return; 148 return;
135 149
136 setBlockSave(true); 150 setBlockSave(true);
137 151
138 mCurrentSyncProfile = action - 1000 ; 152 mCurrentSyncProfile = action - 1000 ;
139 mCurrentSyncDevice = mPrefs->mSyncProfileNames[mCurrentSyncProfile] ; 153 mCurrentSyncDevice = mPrefs->mSyncProfileNames[mCurrentSyncProfile] ;
140 mCurrentSyncName = mPrefs->mLocalMachineName ; 154 mCurrentSyncName = mPrefs->mLocalMachineName ;
141 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 155 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
142 KSyncProfile* temp = new KSyncProfile (); 156 KSyncProfile* temp = new KSyncProfile ();
143 temp->setName(mPrefs->mSyncProfileNames[mCurrentSyncProfile]); 157 temp->setName(mPrefs->mSyncProfileNames[mCurrentSyncProfile]);
144 temp->readConfig(&config); 158 temp->readConfig(&config);
145 mPrefs->mAskForPreferences = temp->getAskForPreferences(); 159 mPrefs->mAskForPreferences = temp->getAskForPreferences();
146 mPrefs->mSyncAlgoPrefs = temp->getSyncPrefs(); 160 mPrefs->mSyncAlgoPrefs = temp->getSyncPrefs();
147 mPrefs->mWriteBackFile = temp->getWriteBackFile(); 161 mPrefs->mWriteBackFile = temp->getWriteBackFile();
148 mPrefs->mWriteBackExistingOnly = temp->getWriteBackExisting(); 162 mPrefs->mWriteBackExistingOnly = temp->getWriteBackExisting();
149 mPrefs->mWriteBackInFuture = 0; 163 mPrefs->mWriteBackInFuture = 0;
150 if ( temp->getWriteBackFuture() ) 164 if ( temp->getWriteBackFuture() )
151 mPrefs->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 165 mPrefs->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
152 mPrefs->mShowSyncSummary = temp->getShowSummaryAfterSync(); 166 mPrefs->mShowSyncSummary = temp->getShowSummaryAfterSync();
153 if ( action == 1000 ) { 167 if ( action == 1000 ) {
154 syncSharp(); 168 syncSharp();
155 169
156 } else if ( action == 1001 ) { 170 } else if ( action == 1001 ) {
157 syncLocalFile(); 171 syncLocalFile();
158 172
159 } else if ( action == 1002 ) { 173 } else if ( action == 1002 ) {
160 quickSyncLocalFile(); 174 quickSyncLocalFile();
161 175
162 } else if ( action >= 1003 ) { 176 } else if ( action >= 1003 ) {
163 if ( temp->getIsLocalFileSync() ) { 177 if ( temp->getIsLocalFileSync() ) {
164 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 178 switch(mTargetApp)
179 {
180 case (KAPI):
181 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
165 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 182 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
166 183 break;
184 case (KOPI):
185 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
186 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
187 break;
188 case (PWMPI):
189 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
190 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
191 break;
192 default:
193 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
194 break;
195
196 }
167 } else { 197 } else {
168 if ( temp->getIsPhoneSync() ) { 198 if ( temp->getIsPhoneSync() ) {
169 mPrefs->mPhoneDevice = temp->getPhoneDevice( ) ; 199 mPrefs->mPhoneDevice = temp->getPhoneDevice( ) ;
170 mPrefs->mPhoneConnection = temp->getPhoneConnection( ); 200 mPrefs->mPhoneConnection = temp->getPhoneConnection( );
171 mPrefs->mPhoneModel = temp->getPhoneModel( ); 201 mPrefs->mPhoneModel = temp->getPhoneModel( );
172 syncPhone(); 202 syncPhone();
173 } else 203 } else
174 syncRemote( temp ); 204 syncRemote( temp );
175 205
176 } 206 }
177 } 207 }
178 delete temp; 208 delete temp;
179 setBlockSave(false); 209 setBlockSave(false);
180} 210}
181 211
182void KSyncManager::syncLocalFile() 212void KSyncManager::syncLocalFile()
183{ 213{
184 214
185 QString fn =mPrefs->mLastSyncedLocalFile; 215 QString fn =mPrefs->mLastSyncedLocalFile;
186 216 QString ext;
187 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), mParent ); 217
218 switch(mTargetApp)
219 {
220 case (KAPI):
221 ext = "(*.vcf)";
222 break;
223 case (KOPI):
224 ext = "(*.ics/*.vcs)";
225 break;
226 case (PWMPI):
227 ext = "(*.pwm)";
228 break;
229 default:
230 qDebug("KSyncManager::syncLocalFile: invalid apptype selected");
231 break;
232
233 }
234
235 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
188 if ( fn == "" ) 236 if ( fn == "" )
189 return; 237 return;
190 if ( syncWithFile( fn, false ) ) { 238 if ( syncWithFile( fn, false ) ) {
191 qDebug("syncLocalFile() successful "); 239 qDebug("syncLocalFile() successful ");
192 } 240 }
193 241
194} 242}
195bool KSyncManager::syncWithFile( QString fn , bool quick ) 243bool KSyncManager::syncWithFile( QString fn , bool quick )
196{ 244{
197 bool ret = false; 245 bool ret = false;
198 QFileInfo info; 246 QFileInfo info;
199 info.setFile( fn ); 247 info.setFile( fn );
200 QString mess; 248 QString mess;
201 bool loadbup = true; 249 bool loadbup = true;
202 if ( !info. exists() ) { 250 if ( !info. exists() ) {
203 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 251 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
204 int result = QMessageBox::warning( mParent, i18n("Warning!"), 252 int result = QMessageBox::warning( mParent, i18n("Warning!"),
205 mess ); 253 mess );
206 return ret; 254 return ret;
207 } 255 }
208 int result = 0; 256 int result = 0;
209 if ( !quick ) { 257 if ( !quick ) {
210 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 258 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
211 result = QMessageBox::warning( mParent, i18n("Warning!"), 259 result = QMessageBox::warning( mParent, i18n("Warning!"),
212 mess, 260 mess,
213 i18n("Sync"), i18n("Cancel"), 0, 261 i18n("Sync"), i18n("Cancel"), 0,
214 0, 1 ); 262 0, 1 );
215 if ( result ) 263 if ( result )
216 return false; 264 return false;
217 } 265 }
218 if ( mPrefs->mAskForPreferences ) 266 if ( mPrefs->mAskForPreferences )
219 edit_sync_options(); 267 edit_sync_options();
220 if ( result == 0 ) { 268 if ( result == 0 ) {
221 //qDebug("Now sycing ... "); 269 //qDebug("Now sycing ... ");
222 if ( ret = mImplementation->sync( this, fn, mPrefs->mSyncAlgoPrefs ) ) 270 if ( ret = mImplementation->sync( this, fn, mPrefs->mSyncAlgoPrefs ) )
223 mParent->setCaption( i18n("Synchronization successful") ); 271 mParent->setCaption( i18n("Synchronization successful") );
224 else 272 else
225 mParent->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 273 mParent->setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
226 if ( ! quick ) 274 if ( ! quick )
227 mPrefs->mLastSyncedLocalFile = fn; 275 mPrefs->mLastSyncedLocalFile = fn;
228 mImplementation->sync_setModified(); 276 mImplementation->sync_setModified();
229 } 277 }
230 return ret; 278 return ret;
231} 279}
232void KSyncManager::quickSyncLocalFile() 280void KSyncManager::quickSyncLocalFile()
233{ 281{
234 282
235 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, false ) ) { 283 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, false ) ) {
236 qDebug("quick syncLocalFile() successful "); 284 qDebug("quick syncLocalFile() successful ");
237 285
238 } 286 }
239} 287}
240void KSyncManager::multiSync( bool askforPrefs ) 288void KSyncManager::multiSync( bool askforPrefs )
241{ 289{
242 if (blockSave()) 290 if (blockSave())
243 return; 291 return;
244 setBlockSave(true); 292 setBlockSave(true);
245 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 293 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
246 if ( QMessageBox::information( mParent, i18n("Sync"), 294 if ( QMessageBox::information( mParent, i18n("Sync"),
247 question, 295 question,
248 i18n("Yes"), i18n("No"), 296 i18n("Yes"), i18n("No"),
249 0, 0 ) != 0 ) { 297 0, 0 ) != 0 ) {
250 setBlockSave(false); 298 setBlockSave(false);
251 mParent->setCaption(i18n("Aborted! Nothing synced!")); 299 mParent->setCaption(i18n("Aborted! Nothing synced!"));
252 return; 300 return;
253 } 301 }
254 mCurrentSyncDevice = i18n("Multiple profiles") ; 302 mCurrentSyncDevice = i18n("Multiple profiles") ;
255 mPrefs->mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; 303 mPrefs->mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
256 if ( askforPrefs ) { 304 if ( askforPrefs ) {
257 edit_sync_options(); 305 edit_sync_options();
258 mPrefs->mRingSyncAlgoPrefs = mPrefs->mSyncAlgoPrefs; 306 mPrefs->mRingSyncAlgoPrefs = mPrefs->mSyncAlgoPrefs;
259 } 307 }
260 mParent->setCaption(i18n("Multiple sync started.") ); 308 mParent->setCaption(i18n("Multiple sync started.") );
261 qApp->processEvents(); 309 qApp->processEvents();
262 int num = ringSync() ; 310 int num = ringSync() ;
263 if ( num > 1 ) 311 if ( num > 1 )
264 ringSync(); 312 ringSync();
265 setBlockSave(false); 313 setBlockSave(false);
266 if ( num ) 314 if ( num )
267 mImplementation->sync_save(); 315 mImplementation->sync_save();
268 if ( num ) 316 if ( num )
269 mParent->setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 317 mParent->setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
270 else 318 else
271 mParent->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 319 mParent->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
272 return; 320 return;
273} 321}
274int KSyncManager::ringSync() 322int KSyncManager::ringSync()
275{ 323{
276 int syncedProfiles = 0; 324 int syncedProfiles = 0;
277 unsigned int i; 325 unsigned int i;
278 QTime timer; 326 QTime timer;
279 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 327 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
280 QStringList syncProfileNames = mPrefs->mSyncProfileNames; 328 QStringList syncProfileNames = mPrefs->mSyncProfileNames;
281 KSyncProfile* temp = new KSyncProfile (); 329 KSyncProfile* temp = new KSyncProfile ();
282 mPrefs->mAskForPreferences = false; 330 mPrefs->mAskForPreferences = false;
283 for ( i = 0; i < syncProfileNames.count(); ++i ) { 331 for ( i = 0; i < syncProfileNames.count(); ++i ) {
284 mCurrentSyncProfile = i; 332 mCurrentSyncProfile = i;
285 temp->setName(syncProfileNames[mCurrentSyncProfile]); 333 temp->setName(syncProfileNames[mCurrentSyncProfile]);
286 temp->readConfig(&config); 334 temp->readConfig(&config);
287 if ( temp->getIncludeInRingSyncAB() && ( i < 1 || i > 2 )) { 335
336 QString includeInRingSync;
337 switch(mTargetApp)
338 {
339 case (KAPI):
340 includeInRingSync = temp->getIncludeInRingSyncAB();
341 break;
342 case (KOPI):
343 includeInRingSync = temp->getIncludeInRingSync();
344 break;
345 case (PWMPI):
346 includeInRingSync = temp->getIncludeInRingSyncPWM();
347 break;
348 default:
349 qDebug("KSyncManager::ringSync: invalid apptype selected");
350 break;
351
352 }
353
354
355 if ( includeInRingSync && ( i < 1 || i > 2 )) {
288 mParent->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 356 mParent->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
289 ++syncedProfiles; 357 ++syncedProfiles;
290 // mPrefs->mAskForPreferences = temp->getAskForPreferences(); 358 // mPrefs->mAskForPreferences = temp->getAskForPreferences();
291 mPrefs->mWriteBackFile = temp->getWriteBackFile(); 359 mPrefs->mWriteBackFile = temp->getWriteBackFile();
292 mPrefs->mWriteBackExistingOnly = temp->getWriteBackExisting(); 360 mPrefs->mWriteBackExistingOnly = temp->getWriteBackExisting();
293 mPrefs->mWriteBackInFuture = 0; 361 mPrefs->mWriteBackInFuture = 0;
294 if ( temp->getWriteBackFuture() ) 362 if ( temp->getWriteBackFuture() )
295 mPrefs->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 363 mPrefs->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
296 mPrefs->mShowSyncSummary = false; 364 mPrefs->mShowSyncSummary = false;
297 mCurrentSyncDevice = syncProfileNames[i] ; 365 mCurrentSyncDevice = syncProfileNames[i] ;
298 mCurrentSyncName = mPrefs->mLocalMachineName; 366 mCurrentSyncName = mPrefs->mLocalMachineName;
299 if ( i == 0 ) { 367 if ( i == 0 ) {
300 syncSharp(); 368 syncSharp();
301 } else { 369 } else {
302 if ( temp->getIsLocalFileSync() ) { 370 if ( temp->getIsLocalFileSync() ) {
303 if ( syncWithFile( temp->getRemoteFileNameAB( ), true ) ) 371 switch(mTargetApp)
304 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 372 {
373 case (KAPI):
374 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
375 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
376 break;
377 case (KOPI):
378 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
379 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
380 break;
381 case (PWMPI):
382 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
383 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
384 break;
385 default:
386 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
387 break;
388 }
305 } else { 389 } else {
306 if ( temp->getIsPhoneSync() ) { 390 if ( temp->getIsPhoneSync() ) {
307 mPrefs->mPhoneDevice = temp->getPhoneDevice( ) ; 391 mPrefs->mPhoneDevice = temp->getPhoneDevice( ) ;
308 mPrefs->mPhoneConnection = temp->getPhoneConnection( ); 392 mPrefs->mPhoneConnection = temp->getPhoneConnection( );
309 mPrefs->mPhoneModel = temp->getPhoneModel( ); 393 mPrefs->mPhoneModel = temp->getPhoneModel( );
310 syncPhone(); 394 syncPhone();
311 } else 395 } else
312 syncRemote( temp, false ); 396 syncRemote( temp, false );
313 397
314 } 398 }
315 } 399 }
316 timer.start(); 400 timer.start();
317 mParent->setCaption(i18n("Multiple sync in progress ... please wait!") ); 401 mParent->setCaption(i18n("Multiple sync in progress ... please wait!") );
318 while ( timer.elapsed () < 2000 ) { 402 while ( timer.elapsed () < 2000 ) {
319 qApp->processEvents(); 403 qApp->processEvents();
320#ifndef _WIN32_ 404#ifndef _WIN32_
321 sleep (1); 405 sleep (1);
322#endif 406#endif
323 } 407 }
324 408
325 } 409 }
326 410
327 } 411 }
328 delete temp; 412 delete temp;
329 return syncedProfiles; 413 return syncedProfiles;
330} 414}
331 415
332void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) 416void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
333{ 417{
334 QString question; 418 QString question;
335 if ( ask ) { 419 if ( ask ) {
336 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 420 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
337 if ( QMessageBox::information( mParent, i18n("Sync"), 421 if ( QMessageBox::information( mParent, i18n("Sync"),
338 question, 422 question,
339 i18n("Yes"), i18n("No"), 423 i18n("Yes"), i18n("No"),
340 0, 0 ) != 0 ) 424 0, 0 ) != 0 )
341 return; 425 return;
342 } 426 }
343 QString command = prof->getPreSyncCommandAB(); 427
428 QString preCommand;
429 QString localTempFile;
430 QString postCommand;
431
432 switch(mTargetApp)
433 {
434 case (KAPI):
435 preCommand = prof->getPreSyncCommandAB();
436 postCommand = prof->getPostSyncCommandAB();
437 localTempFile = prof->getLocalTempFileAB();
438 break;
439 case (KOPI):
440 preCommand = prof->getPreSyncCommand();
441 postCommand = prof->getPostSyncCommand();
442 localTempFile = prof->getLocalTempFile();
443 break;
444 case (PWMPI):
445 preCommand = prof->getPreSyncCommandPWM();
446 postCommand = prof->getPostSyncCommandPWM();
447 localTempFile = prof->getLocalTempFilePWM();
448 break;
449 default:
450 qDebug("KSyncManager::syncRemote: invalid apptype selected");
451 break;
452 }
453
454
344 int fi; 455 int fi;
345 if ( (fi = command.find("$PWD$")) > 0 ) { 456 if ( (fi = preCommand.find("$PWD$")) > 0 ) {
346 QString pwd = getPassword(); 457 QString pwd = getPassword();
347 command = command.left( fi )+ pwd + command.mid( fi+5 ); 458 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
348 459
349 } 460 }
350 int maxlen = 30; 461 int maxlen = 30;
351 if ( QApplication::desktop()->width() > 320 ) 462 if ( QApplication::desktop()->width() > 320 )
352 maxlen += 25; 463 maxlen += 25;
353 mParent->setCaption ( i18n( "Copy remote file to local machine..." ) ); 464 mParent->setCaption ( i18n( "Copy remote file to local machine..." ) );
354 int fileSize = 0; 465 int fileSize = 0;
355 int result = system ( command ); 466 int result = system ( preCommand );
356 // 0 : okay 467 // 0 : okay
357 // 256: no such file or dir 468 // 256: no such file or dir
358 // 469 //
359 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 470 qDebug("KO: Remote copy result(0 = okay): %d ",result );
360 if ( result != 0 ) { 471 if ( result != 0 ) {
361 unsigned int len = maxlen; 472 unsigned int len = maxlen;
362 while ( len < command.length() ) { 473 while ( len < preCommand.length() ) {
363 command.insert( len , "\n" ); 474 preCommand.insert( len , "\n" );
364 len += maxlen +2; 475 len += maxlen +2;
365 } 476 }
366 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; 477 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ;
367 QMessageBox::information( mParent, i18n("Sync - ERROR"), 478 QMessageBox::information( mParent, i18n("Sync - ERROR"),
368 question, 479 question,
369 i18n("Okay!")) ; 480 i18n("Okay!")) ;
370 mParent->setCaption (""); 481 mParent->setCaption ("");
371 return; 482 return;
372 } 483 }
373 mParent->setCaption ( i18n( "Copying succeed." ) ); 484 mParent->setCaption ( i18n( "Copying succeed." ) );
374 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 485 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
375 if ( syncWithFile( prof->getLocalTempFileAB(), true ) ) { 486
487
488
489 if ( syncWithFile( localTempFile, true ) ) {
376// Event* e = mView->getLastSyncEvent(); 490// Event* e = mView->getLastSyncEvent();
377// e->setReadOnly( false ); 491// e->setReadOnly( false );
378// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 492// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
379// e->setReadOnly( true ); 493// e->setReadOnly( true );
380 if ( mPrefs->mWriteBackFile ) { 494 if ( mPrefs->mWriteBackFile ) {
381 command = prof->getPostSyncCommandAB();
382 int fi; 495 int fi;
383 if ( (fi = command.find("$PWD$")) > 0 ) { 496 if ( (fi = postCommand.find("$PWD$")) > 0 ) {
384 QString pwd = getPassword(); 497 QString pwd = getPassword();
385 command = command.left( fi )+ pwd + command.mid( fi+5 ); 498 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
386 499
387 } 500 }
388 mParent->setCaption ( i18n( "Writing back file ..." ) ); 501 mParent->setCaption ( i18n( "Writing back file ..." ) );
389 result = system ( command ); 502 result = system ( postCommand );
390 qDebug("Writing back file result: %d ", result); 503 qDebug("Writing back file result: %d ", result);
391 if ( result != 0 ) { 504 if ( result != 0 ) {
392 mParent->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 505 mParent->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
393 return; 506 return;
394 } else { 507 } else {
395 mParent->setCaption ( i18n( "Syncronization sucessfully completed" ) ); 508 mParent->setCaption ( i18n( "Syncronization sucessfully completed" ) );
396 } 509 }
397 } 510 }
398 } 511 }
399 return; 512 return;
400} 513}
401 514
402void KSyncManager::edit_sync_options() 515void KSyncManager::edit_sync_options()
403{ 516{
404 //mDialogManager->showSyncOptions(); 517 //mDialogManager->showSyncOptions();
405 //mPrefs->mSyncAlgoPrefs 518 //mPrefs->mSyncAlgoPrefs
406 QDialog dia( mParent, "dia", true ); 519 QDialog dia( mParent, "dia", true );
407 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 520 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
408 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 521 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
409 QVBoxLayout lay ( &dia ); 522 QVBoxLayout lay ( &dia );
410 lay.setSpacing( 2 ); 523 lay.setSpacing( 2 );
411 lay.setMargin( 3 ); 524 lay.setMargin( 3 );
412 lay.addWidget(&gr); 525 lay.addWidget(&gr);
413 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 526 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
414 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 527 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
415 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 528 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
416 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 529 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
417 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 530 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
418 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 531 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
419 //QRadioButton both( i18n("Take both on conflict"), &gr ); 532 //QRadioButton both( i18n("Take both on conflict"), &gr );
420 QPushButton pb ( "OK", &dia); 533 QPushButton pb ( "OK", &dia);
421 lay.addWidget( &pb ); 534 lay.addWidget( &pb );
422 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 535 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
423 switch ( mPrefs->mSyncAlgoPrefs ) { 536 switch ( mPrefs->mSyncAlgoPrefs ) {
424 case 0: 537 case 0:
425 loc.setChecked( true); 538 loc.setChecked( true);
426 break; 539 break;
427 case 1: 540 case 1:
428 rem.setChecked( true ); 541 rem.setChecked( true );
429 break; 542 break;
430 case 2: 543 case 2:
431 newest.setChecked( true); 544 newest.setChecked( true);
432 break; 545 break;
433 case 3: 546 case 3:
434 ask.setChecked( true); 547 ask.setChecked( true);
435 break; 548 break;
436 case 4: 549 case 4:
437 f_loc.setChecked( true); 550 f_loc.setChecked( true);
438 break; 551 break;
439 case 5: 552 case 5:
440 f_rem.setChecked( true); 553 f_rem.setChecked( true);
441 break; 554 break;
442 case 6: 555 case 6:
443 // both.setChecked( true); 556 // both.setChecked( true);
444 break; 557 break;
445 default: 558 default:
446 break; 559 break;
447 } 560 }
448 if ( dia.exec() ) { 561 if ( dia.exec() ) {
449 mPrefs->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 562 mPrefs->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
450 } 563 }
451 564
452 565
453} 566}
454QString KSyncManager::getPassword( ) 567QString KSyncManager::getPassword( )
455{ 568{
456 QString retfile = ""; 569 QString retfile = "";
457 QDialog dia ( mParent, "input-dialog", true ); 570 QDialog dia ( mParent, "input-dialog", true );
458 QLineEdit lab ( &dia ); 571 QLineEdit lab ( &dia );
459 lab.setEchoMode( QLineEdit::Password ); 572 lab.setEchoMode( QLineEdit::Password );
460 QVBoxLayout lay( &dia ); 573 QVBoxLayout lay( &dia );
461 lay.setMargin(7); 574 lay.setMargin(7);
462 lay.setSpacing(7); 575 lay.setSpacing(7);
463 lay.addWidget( &lab); 576 lay.addWidget( &lab);
464 dia.setFixedSize( 230,50 ); 577 dia.setFixedSize( 230,50 );
465 dia.setCaption( i18n("Enter password") ); 578 dia.setCaption( i18n("Enter password") );
466 QPushButton pb ( "OK", &dia); 579 QPushButton pb ( "OK", &dia);
467 lay.addWidget( &pb ); 580 lay.addWidget( &pb );
468 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 581 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
469 dia.show(); 582 dia.show();
470 int res = dia.exec(); 583 int res = dia.exec();
471 if ( res ) 584 if ( res )
472 retfile = lab.text(); 585 retfile = lab.text();
473 dia.hide(); 586 dia.hide();
474 qApp->processEvents(); 587 qApp->processEvents();
475 return retfile; 588 return retfile;
476 589
477} 590}
478 591
479 592
480void KSyncManager::confSync() 593void KSyncManager::confSync()
481{ 594{
482 static KSyncPrefsDialog* sp = 0; 595 static KSyncPrefsDialog* sp = 0;
483 if ( ! sp ) { 596 if ( ! sp ) {
484 sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); 597 sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
485 } 598 }
486 sp->usrReadConfig(); 599 sp->usrReadConfig();
487#ifndef DESKTOP_VERSION 600#ifndef DESKTOP_VERSION
488 sp->showMaximized(); 601 sp->showMaximized();
489#else 602#else
490 sp->show(); 603 sp->show();
491#endif 604#endif
492 sp->exec(); 605 sp->exec();
493 mPrefs->mSyncProfileNames = sp->getSyncProfileNames(); 606 mPrefs->mSyncProfileNames = sp->getSyncProfileNames();
494 mPrefs->mLocalMachineName = sp->getLocalMachineName (); 607 mPrefs->mLocalMachineName = sp->getLocalMachineName ();
495 fillSyncMenu(); 608 fillSyncMenu();
496} 609}
497 610
498void KSyncManager::syncSharp() 611void KSyncManager::syncSharp()
499{ 612{
500 if ( ! syncExternalApplication("sharp") ) 613 if ( ! syncExternalApplication("sharp") )
501 qDebug("ERROR sync sharp ");; 614 qDebug("ERROR sync sharp ");;
502} 615}
503 616
504bool KSyncManager::syncExternalApplication(QString resource) 617bool KSyncManager::syncExternalApplication(QString resource)
505{ 618{
506 if ( mImplementation->sync_isModified() ) 619 if ( mImplementation->sync_isModified() )
507 mImplementation->sync_save(); 620 mImplementation->sync_save();
508 621
509 if ( mPrefs->mAskForPreferences ) 622 if ( mPrefs->mAskForPreferences )
510 edit_sync_options(); 623 edit_sync_options();
511 624
512 qDebug("sync %s", resource.latin1()); 625 qDebug("sync %s", resource.latin1());
513 626
514 bool syncOK = mImplementation->syncExternal(this, resource); 627 bool syncOK = mImplementation->syncExternal(this, resource);
515 628
516 return syncOK; 629 return syncOK;
517 630
518} 631}
519 632
520void KSyncManager::syncPhone() 633void KSyncManager::syncPhone()
521{ 634{
522 if ( mImplementation->sync_isModified() ) 635 if ( mImplementation->sync_isModified() )
523 mImplementation->sync_save(); 636 mImplementation->sync_save();
524 637
525 qDebug("pending syncPhone(); "); 638 qDebug("pending syncPhone(); ");
526 //mView->syncPhone(); 639 //mView->syncPhone();
527 mImplementation->sync_setModified(); 640 mImplementation->sync_setModified();
528 641
529} 642}
643
644void KSyncManager::showProgressBar(int percentage, QString caption, int total)
645{
646 if (!bar->isVisible())
647 {
648 bar->setCaption (caption);
649 bar->setTotalSteps ( total ) ;
650
651 bar->show();
652 }
653
654 bar->setProgress( percentage );
655}
656
657void KSyncManager::hideProgressBar()
658{
659 bar->hide();
660}
661
662bool KSyncManager::isProgressBarCanceled()
663{
664 return !bar->isVisible();
665}
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 389a005..9761107 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -1,119 +1,129 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19 19
20$Id$ 20$Id$
21*/ 21*/
22#ifndef _KSYNCMANAGER_H 22#ifndef _KSYNCMANAGER_H
23#define _KSYNCMANAGER_H 23#define _KSYNCMANAGER_H
24 24
25#include <qobject.h> 25#include <qobject.h>
26#include <qstring.h> 26#include <qstring.h>
27 27
28class QPopupMenu; 28class QPopupMenu;
29class KSyncProfile; 29class KSyncProfile;
30class KPimPrefs; 30class KPimPrefs;
31class QWidget; 31class QWidget;
32class KSyncManager; 32class KSyncManager;
33class KSyncInterface; 33class KSyncInterface;
34class QProgressBar;
34 35
35class KSyncManager : public QObject 36class KSyncManager : public QObject
36{ 37{
37 Q_OBJECT 38 Q_OBJECT
38 39
39 public: 40 public:
40 enum TargetApp { 41 enum TargetApp {
41 KOPI = 0, 42 KOPI = 0,
42 KAPI = 1, 43 KAPI = 1,
43 PWMPI = 2 }; 44 PWMPI = 2 };
44 45
45 46
46 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); 47 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu);
47 ~KSyncManager() ; 48 ~KSyncManager() ;
48 49
49 bool blockSave() { return mBlockSaveFlag; } 50 bool blockSave() { return mBlockSaveFlag; }
50 void setBlockSave(bool sa) { mBlockSaveFlag = sa; } 51 void setBlockSave(bool sa) { mBlockSaveFlag = sa; }
51 52
52 void fillSyncMenu(); 53 void fillSyncMenu();
53 54
54 QString getCurrentSyncDevice() { return mCurrentSyncDevice; } 55 QString getCurrentSyncDevice() { return mCurrentSyncDevice; }
55 QString getCurrentSyncName() { return mCurrentSyncName; } 56 QString getCurrentSyncName() { return mCurrentSyncName; }
56 57
58 void showProgressBar(int percentage, QString caption = QString::null, int total=100);
59 void hideProgressBar();
60 bool isProgressBarCanceled();
61
62
57 public slots: 63 public slots:
58 void slotSyncMenu( int ); 64 void slotSyncMenu( int );
59 65
60 private: 66 private:
61 // LR ******************************* 67 // LR *******************************
62 // sync stuff! 68 // sync stuff!
63 QString mCurrentSyncDevice; 69 QString mCurrentSyncDevice;
64 QString mCurrentSyncName; 70 QString mCurrentSyncName;
65 void quickSyncLocalFile(); 71 void quickSyncLocalFile();
66 bool syncWithFile( QString fn , bool quick ); 72 bool syncWithFile( QString fn , bool quick );
67 void syncLocalFile(); 73 void syncLocalFile();
68 void syncPhone(); 74 void syncPhone();
69 void syncSharp(); 75 void syncSharp();
70 bool syncExternalApplication(QString); 76 bool syncExternalApplication(QString);
71 void multiSync( bool askforPrefs ); 77 void multiSync( bool askforPrefs );
72 int mCurrentSyncProfile ; 78 int mCurrentSyncProfile ;
73 void syncRemote( KSyncProfile* prof, bool ask = true); 79 void syncRemote( KSyncProfile* prof, bool ask = true);
74 void edit_sync_options(); 80 void edit_sync_options();
75 int ringSync(); 81 int ringSync();
76 QString getPassword( ); 82 QString getPassword( );
77 83
78 private slots: 84 private slots:
79 void confSync(); 85 void confSync();
80 // ********************* 86 // *********************
81 87
82 private: 88 private:
83 bool mBlockSaveFlag; 89 bool mBlockSaveFlag;
84 90
85 91
86 QWidget* mParent; 92 QWidget* mParent;
87 KSyncInterface* mImplementation; 93 KSyncInterface* mImplementation;
88 TargetApp mTargetApp; 94 TargetApp mTargetApp;
89 KPimPrefs* mPrefs; 95 KPimPrefs* mPrefs;
90 QPopupMenu* mSyncMenu; 96 QPopupMenu* mSyncMenu;
91 97
92 98 QProgressBar* bar;
93 99
94 100
95 101
96 102
97 103
98}; 104};
99 105
100 106
101class KSyncInterface 107class KSyncInterface
102{ 108{
103 public: 109 public:
104 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; 110 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0;
105 virtual bool syncExternal(KSyncManager* manager, QString resource) = 0;
106 111
112 virtual bool syncExternal(KSyncManager* manager, QString resource)
113 {
114 // empty implementation, because some syncable applications do not have an external(sharpdtm) syncmode, like pwmanager.
115 return false;
116 }
107 117
108 //called by the syncmanager to indicate that the work has to be marked as dirty. 118 //called by the syncmanager to indicate that the work has to be marked as dirty.
109 virtual void sync_setModified() = 0; 119 virtual void sync_setModified() = 0;
110 120
111 //called by the syncmanager to ask if the dirty flag is set. 121 //called by the syncmanager to ask if the dirty flag is set.
112 virtual bool sync_isModified() = 0; 122 virtual bool sync_isModified() = 0;
113 123
114 //called by the syncmanager to indicate that the work has to be saved. 124 //called by the syncmanager to indicate that the work has to be saved.
115 virtual void sync_save() = 0; 125 virtual void sync_save() = 0;
116}; 126};
117 127
118 128
119#endif 129#endif
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp
index ac2e66e..014e809 100644
--- a/pwmanager/pwmanager/pwm.cpp
+++ b/pwmanager/pwmanager/pwm.cpp
@@ -1069,287 +1069,297 @@ bool PwM::importFromGpasman()
1069 "Do you want to continue nevertheless?"), 1069 "Do you want to continue nevertheless?"),
1070 i18n("password error")) 1070 i18n("password error"))
1071 == KMessageBox::No) { 1071 == KMessageBox::No) {
1072 goto cancelImport; 1072 goto cancelImport;
1073 } 1073 }
1074 } else if (ret != e_success) { 1074 } else if (ret != e_success) {
1075 KMessageBox::error(this, 1075 KMessageBox::error(this,
1076 i18n("Could not import file!\n" 1076 i18n("Could not import file!\n"
1077 "Do you have permission to read this file?"), 1077 "Do you have permission to read this file?"),
1078 i18n("import failed")); 1078 i18n("import failed"));
1079 goto cancelImport; 1079 goto cancelImport;
1080 } 1080 }
1081 setVirgin(false); 1081 setVirgin(false);
1082 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1082 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1083 return true; 1083 return true;
1084 1084
1085cancelImport: 1085cancelImport:
1086 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1086 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1087 return false; 1087 return false;
1088} 1088}
1089 1089
1090#ifdef CONFIG_KWALLETIF 1090#ifdef CONFIG_KWALLETIF
1091bool PwM::checkAndAskForKWalletEmu() 1091bool PwM::checkAndAskForKWalletEmu()
1092{ 1092{
1093 if (init->kwalletEmu()) { 1093 if (init->kwalletEmu()) {
1094 /* KWallet emulation is enabled. We can't import/export 1094 /* KWallet emulation is enabled. We can't import/export
1095 * data from/to it, while emulation is active. 1095 * data from/to it, while emulation is active.
1096 */ 1096 */
1097 if (KMessageBox::questionYesNo(this, 1097 if (KMessageBox::questionYesNo(this,
1098 i18n("KWallet emulation is enabled.\n" 1098 i18n("KWallet emulation is enabled.\n"
1099 "You can't import or export data from/to " 1099 "You can't import or export data from/to "
1100 "the original KWallet, while the emulation " 1100 "the original KWallet, while the emulation "
1101 "is active.\n" 1101 "is active.\n"
1102 "Do you want to tempoarly disable the KWallet emulation?"), 1102 "Do you want to tempoarly disable the KWallet emulation?"),
1103 i18n("Tempoarly disable KWallet emulation?")) 1103 i18n("Tempoarly disable KWallet emulation?"))
1104 == KMessageBox::Yes) { 1104 == KMessageBox::Yes) {
1105 init->initKWalletEmu(true); 1105 init->initKWalletEmu(true);
1106 PWM_ASSERT(!init->kwalletEmu()); 1106 PWM_ASSERT(!init->kwalletEmu());
1107 return true; 1107 return true;
1108 } 1108 }
1109 return false; 1109 return false;
1110 } 1110 }
1111 return true; 1111 return true;
1112} 1112}
1113#endif // CONFIG_KWALLETIF 1113#endif // CONFIG_KWALLETIF
1114 1114
1115bool PwM::importKWallet() 1115bool PwM::importKWallet()
1116{ 1116{
1117#ifdef CONFIG_KWALLETIF 1117#ifdef CONFIG_KWALLETIF
1118 if (!checkAndAskForKWalletEmu()) 1118 if (!checkAndAskForKWalletEmu())
1119 return false; 1119 return false;
1120 KWalletIf walletIf(this); 1120 KWalletIf walletIf(this);
1121 if (!isVirgin()) { 1121 if (!isVirgin()) {
1122 if (KMessageBox::questionYesNo(this, 1122 if (KMessageBox::questionYesNo(this,
1123 i18n("Do you want to import the data " 1123 i18n("Do you want to import the data "
1124 "into the current document? (If you " 1124 "into the current document? (If you "
1125 "select \"no\", a new document will be " 1125 "select \"no\", a new document will be "
1126 "opened.)"), 1126 "opened.)"),
1127 i18n("import into this document?")) 1127 i18n("import into this document?"))
1128 == KMessageBox::No) { 1128 == KMessageBox::No) {
1129 // import the data to a new window. 1129 // import the data to a new window.
1130 PwM *newInstance = init->createMainWnd(); 1130 PwM *newInstance = init->createMainWnd();
1131 bool ok = newInstance->importKWallet(); 1131 bool ok = newInstance->importKWallet();
1132 if (!ok) { 1132 if (!ok) {
1133 newInstance->setForceQuit(true); 1133 newInstance->setForceQuit(true);
1134 delete_and_null(newInstance); 1134 delete_and_null(newInstance);
1135 goto exit_fail; 1135 goto exit_fail;
1136 } else { 1136 } else {
1137 goto exit_ok; 1137 goto exit_ok;
1138 } 1138 }
1139 } 1139 }
1140 } 1140 }
1141 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1141 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1142 if (!walletIf.kwalletImport(curDoc())) { 1142 if (!walletIf.kwalletImport(curDoc())) {
1143 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1143 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1144 showStatMsg(i18n("KWallet import failed")); 1144 showStatMsg(i18n("KWallet import failed"));
1145 goto exit_fail; 1145 goto exit_fail;
1146 } 1146 }
1147 KMessageBox::information(this, 1147 KMessageBox::information(this,
1148 i18n("Successfully imported the KWallet data " 1148 i18n("Successfully imported the KWallet data "
1149 "into the current document."), 1149 "into the current document."),
1150 i18n("successfully imported")); 1150 i18n("successfully imported"));
1151 showStatMsg(i18n("successfully imported")); 1151 showStatMsg(i18n("successfully imported"));
1152 setVirgin(false); 1152 setVirgin(false);
1153 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1153 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1154 1154
1155exit_ok: 1155exit_ok:
1156 init->initKWalletEmu(); 1156 init->initKWalletEmu();
1157 return true; 1157 return true;
1158 1158
1159exit_fail: 1159exit_fail:
1160 init->initKWalletEmu(); 1160 init->initKWalletEmu();
1161#endif // CONFIG_KWALLETIF 1161#endif // CONFIG_KWALLETIF
1162 return false; 1162 return false;
1163} 1163}
1164 1164
1165void PwM::print_slot() 1165void PwM::print_slot()
1166{ 1166{
1167 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1167 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1168#ifndef PWM_EMBEDDED 1168#ifndef PWM_EMBEDDED
1169 PwMPrint p(curDoc(), this); 1169 PwMPrint p(curDoc(), this);
1170 p.printNow(); 1170 p.printNow();
1171#else 1171#else
1172 qDebug("PwM::print_slot , PRINTING IS NOT IMPLEMENTED"); 1172 qDebug("PwM::print_slot , PRINTING IS NOT IMPLEMENTED");
1173#endif 1173#endif
1174 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1174 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1175} 1175}
1176 1176
1177void PwM::genNewCard_slot() 1177void PwM::genNewCard_slot()
1178{ 1178{
1179#ifdef CONFIG_KEYCARD 1179#ifdef CONFIG_KEYCARD
1180 init->keycard()->genNewCard(); 1180 init->keycard()->genNewCard();
1181#endif 1181#endif
1182} 1182}
1183 1183
1184void PwM::eraseCard_slot() 1184void PwM::eraseCard_slot()
1185{ 1185{
1186#ifdef CONFIG_KEYCARD 1186#ifdef CONFIG_KEYCARD
1187 init->keycard()->eraseCard(); 1187 init->keycard()->eraseCard();
1188#endif 1188#endif
1189} 1189}
1190 1190
1191void PwM::readCardId_slot() 1191void PwM::readCardId_slot()
1192{ 1192{
1193#ifdef CONFIG_KEYCARD 1193#ifdef CONFIG_KEYCARD
1194 init->keycard()->displayKey(); 1194 init->keycard()->displayKey();
1195#endif 1195#endif
1196} 1196}
1197 1197
1198void PwM::makeCardBackup_slot() 1198void PwM::makeCardBackup_slot()
1199{ 1199{
1200#ifdef CONFIG_KEYCARD 1200#ifdef CONFIG_KEYCARD
1201 init->keycard()->makeBackupImage(); 1201 init->keycard()->makeBackupImage();
1202#endif 1202#endif
1203} 1203}
1204 1204
1205void PwM::replayCardBackup_slot() 1205void PwM::replayCardBackup_slot()
1206{ 1206{
1207#ifdef CONFIG_KEYCARD 1207#ifdef CONFIG_KEYCARD
1208 init->keycard()->replayBackupImage(); 1208 init->keycard()->replayBackupImage();
1209#endif 1209#endif
1210} 1210}
1211 1211
1212void PwM::execLauncher_slot() 1212void PwM::execLauncher_slot()
1213{ 1213{
1214 PWM_ASSERT(curDoc()); 1214 PWM_ASSERT(curDoc());
1215 if (curDoc()->isDeepLocked()) 1215 if (curDoc()->isDeepLocked())
1216 return; 1216 return;
1217 unsigned int curEntryIndex; 1217 unsigned int curEntryIndex;
1218 if (!view->getCurEntryIndex(&curEntryIndex)) 1218 if (!view->getCurEntryIndex(&curEntryIndex))
1219 return; 1219 return;
1220 bool ret = curDoc()->execLauncher(view->getCurrentCategory(), 1220 bool ret = curDoc()->execLauncher(view->getCurrentCategory(),
1221 curEntryIndex); 1221 curEntryIndex);
1222 if (ret) 1222 if (ret)
1223 showStatMsg(i18n("Executed the \"Launcher\".")); 1223 showStatMsg(i18n("Executed the \"Launcher\"."));
1224 else 1224 else
1225 showStatMsg(i18n("ERROR: Couldn't execute the \"Launcher\"!")); 1225 showStatMsg(i18n("ERROR: Couldn't execute the \"Launcher\"!"));
1226} 1226}
1227 1227
1228void PwM::goToURL_slot() 1228void PwM::goToURL_slot()
1229{ 1229{
1230 PWM_ASSERT(curDoc()); 1230 PWM_ASSERT(curDoc());
1231 if (curDoc()->isDeepLocked()) 1231 if (curDoc()->isDeepLocked())
1232 return; 1232 return;
1233 unsigned int curEntryIndex; 1233 unsigned int curEntryIndex;
1234 if (!view->getCurEntryIndex(&curEntryIndex)) 1234 if (!view->getCurEntryIndex(&curEntryIndex))
1235 return; 1235 return;
1236 bool ret = curDoc()->goToURL(view->getCurrentCategory(), 1236 bool ret = curDoc()->goToURL(view->getCurrentCategory(),
1237 curEntryIndex); 1237 curEntryIndex);
1238 if (ret) 1238 if (ret)
1239 showStatMsg(i18n("started browser with current URL.")); 1239 showStatMsg(i18n("started browser with current URL."));
1240 else 1240 else
1241 showStatMsg(i18n("ERROR: Couldn't start browser! Maybe invalid URL?")); 1241 showStatMsg(i18n("ERROR: Couldn't start browser! Maybe invalid URL?"));
1242} 1242}
1243 1243
1244void PwM::copyToClipboard(const QString &s) 1244void PwM::copyToClipboard(const QString &s)
1245{ 1245{
1246 QClipboard *cb = QApplication::clipboard(); 1246 QClipboard *cb = QApplication::clipboard();
1247#ifndef PWM_EMBEDDED 1247#ifndef PWM_EMBEDDED
1248 if (cb->supportsSelection()) 1248 if (cb->supportsSelection())
1249 cb->setText(s, QClipboard::Selection); 1249 cb->setText(s, QClipboard::Selection);
1250 cb->setText(s, QClipboard::Clipboard); 1250 cb->setText(s, QClipboard::Clipboard);
1251#else 1251#else
1252 cb->setText(s); 1252 cb->setText(s);
1253 1253
1254#endif 1254#endif
1255 1255
1256} 1256}
1257 1257
1258void PwM::showStatMsg(const QString &msg) 1258void PwM::showStatMsg(const QString &msg)
1259{ 1259{
1260#ifndef PWM_EMBEDDED 1260#ifndef PWM_EMBEDDED
1261 KStatusBar *statBar = statusBar(); 1261 KStatusBar *statBar = statusBar();
1262 statBar->message(msg, STATUSBAR_MSG_TIMEOUT * 1000); 1262 statBar->message(msg, STATUSBAR_MSG_TIMEOUT * 1000);
1263#else 1263#else
1264 qDebug("Statusbar : %s",msg.latin1()); 1264 qDebug("Statusbar : %s",msg.latin1());
1265#endif 1265#endif
1266} 1266}
1267 1267
1268void PwM::focusInEvent(QFocusEvent *e) 1268void PwM::focusInEvent(QFocusEvent *e)
1269{ 1269{
1270 if (e->gotFocus()) { 1270 if (e->gotFocus()) {
1271 emit gotFocus(this); 1271 emit gotFocus(this);
1272 } else if (e->lostFocus()) { 1272 } else if (e->lostFocus()) {
1273 emit lostFocus(this); 1273 emit lostFocus(this);
1274 } 1274 }
1275} 1275}
1276 1276
1277 1277
1278#ifdef PWM_EMBEDDED 1278#ifdef PWM_EMBEDDED
1279 1279
1280void PwM::showLicense_slot() 1280void PwM::showLicense_slot()
1281{ 1281{
1282 KApplication::showLicence(); 1282 KApplication::showLicence();
1283} 1283}
1284 1284
1285void PwM::faq_slot() 1285void PwM::faq_slot()
1286{ 1286{
1287 KApplication::showFile( "PWM/Pi FAQ", "kdepim/pwmanager/pwmanagerFAQ.txt" ); 1287 KApplication::showFile( "PWM/Pi FAQ", "kdepim/pwmanager/pwmanagerFAQ.txt" );
1288} 1288}
1289 1289
1290void PwM::createAboutData_slot() 1290void PwM::createAboutData_slot()
1291{ 1291{
1292 QString version; 1292 QString version;
1293#include <../version> 1293#include <../version>
1294 QMessageBox::about( this, "About PwManager/Pi", 1294 QMessageBox::about( this, "About PwManager/Pi",
1295 "PwManager/Platform-independent\n" 1295 "PwManager/Platform-independent\n"
1296 "(PWM/Pi) " +version + " - " + 1296 "(PWM/Pi) " +version + " - " +
1297#ifdef DESKTOP_VERSION 1297#ifdef DESKTOP_VERSION
1298 "Desktop Edition\n" 1298 "Desktop Edition\n"
1299#else 1299#else
1300 "PDA-Edition\n" 1300 "PDA-Edition\n"
1301 "for: Zaurus 5500 / 7x0 / 8x0\n" 1301 "for: Zaurus 5500 / 7x0 / 8x0\n"
1302#endif 1302#endif
1303 1303
1304 "(c) 2004 Ulf Schenk\n" 1304 "(c) 2004 Ulf Schenk\n"
1305 "(c) 2004 Lutz Rogowski\n" 1305 "(c) 2004 Lutz Rogowski\n"
1306 "(c) 1997-2004, The KDE PIM Team\n" 1306 "(c) 1997-2004, The KDE PIM Team\n"
1307 1307
1308 "(c) Michael Buesch - main programming\nand current maintainer\nmbuesch@freenet.de\n" 1308 "(c) Michael Buesch - main programming\nand current maintainer\nmbuesch@freenet.de\n"
1309 "Matt Scifo - mscifo@o1.com\n" 1309 "Matt Scifo - mscifo@o1.com\n"
1310 "Elias Probst - elias.probst@gmx.de\n" 1310 "Elias Probst - elias.probst@gmx.de\n"
1311 "George Staikos - staikos@kde.org\n" 1311 "George Staikos - staikos@kde.org\n"
1312 "Matthew Palmer - mjp16@uow.edu.au\n" 1312 "Matthew Palmer - mjp16@uow.edu.au\n"
1313 "Olivier Sessink - gpasman@nl.linux.org\n" 1313 "Olivier Sessink - gpasman@nl.linux.org\n"
1314 "The libgcrypt developers -\nBlowfish and SHA1 algorithms\nftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/\n" 1314 "The libgcrypt developers -\nBlowfish and SHA1 algorithms\nftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/\n"
1315 "Troy Engel - tengel@sonic.net\n" 1315 "Troy Engel - tengel@sonic.net\n"
1316 "Wickey - wickey@gmx.at\n" 1316 "Wickey - wickey@gmx.at\n"
1317 "Ian MacGregor - original documentation author.\n" 1317 "Ian MacGregor - original documentation author.\n"
1318 ); 1318 );
1319} 1319}
1320 1320
1321 1321
1322//this are the overwritten callbackmethods from the syncinterface 1322//this are the overwritten callbackmethods from the syncinterface
1323bool PwM::sync(KSyncManager* manager, QString filename, int mode) 1323bool PwM::sync(KSyncManager* manager, QString filename, int mode)
1324{ 1324{
1325 return true; 1325 PWM_ASSERT(curDoc());
1326}
1327 1326
1328bool PwM::syncExternal(KSyncManager* manager, QString resource) 1327 bool ret = curDoc()->sync(manager, filename, mode);
1329{ 1328
1330 return true; 1329 if (ret == true) {
1330 //US BUG: what can we call here to update the view of the current doc?
1331 //mViewManager->refreshView();
1332 }
1333
1334 return ret;
1331} 1335}
1332 1336
1333//called by the syncmanager to indicate that the work has to marked as dirty. 1337//called by the syncmanager to indicate that the work has to be marked as dirty.
1334void PwM::sync_setModified() 1338void PwM::sync_setModified()
1335{ 1339{
1340 PWM_ASSERT(curDoc());
1341 curDoc()->sync_setModified();
1336} 1342}
1337 1343
1338//called by the syncmanager to ask if the dirty flag is set. 1344//called by the syncmanager to ask if the dirty flag is set.
1339bool PwM::sync_isModified() 1345bool PwM::sync_isModified()
1340{ 1346{
1347 PWM_ASSERT(curDoc());
1348 return curDoc()->sync_isModified();
1341} 1349}
1342 1350
1343//called by the syncmanager to indicate that the work has to be saved. 1351//called by the syncmanager to indicate that the work has to be saved.
1344void PwM::sync_save() 1352void PwM::sync_save()
1345{ 1353{
1354 PWM_ASSERT(curDoc());
1355 return curDoc()->sync_save();
1346} 1356}
1347 1357
1348 1358
1349 1359
1350#endif 1360#endif
1351 1361
1352 1362
1353#ifndef PWM_EMBEDDED 1363#ifndef PWM_EMBEDDED
1354#include "pwm.moc" 1364#include "pwm.moc"
1355#endif 1365#endif
diff --git a/pwmanager/pwmanager/pwm.h b/pwmanager/pwmanager/pwm.h
index 2fe7352..7c6bf0d 100644
--- a/pwmanager/pwmanager/pwm.h
+++ b/pwmanager/pwmanager/pwm.h
@@ -18,281 +18,280 @@
18 **************************************************************************/ 18 **************************************************************************/
19 19
20#ifndef __PWM_H 20#ifndef __PWM_H
21#define __PWM_H 21#define __PWM_H
22 22
23 23
24#include <kpopupmenu.h> 24#include <kpopupmenu.h>
25#include <klistview.h> 25#include <klistview.h>
26#include <kmainwindow.h> 26#include <kmainwindow.h>
27 27
28#ifndef PWM_EMBEDDED 28#ifndef PWM_EMBEDDED
29#include <kwin.h> 29#include <kwin.h>
30#include <kapp.h> 30#include <kapp.h>
31#include <kdeversion.h> 31#include <kdeversion.h>
32#else 32#else
33#include <ksyncmanager.h> 33#include <ksyncmanager.h>
34#endif 34#endif
35 35
36#include <kaction.h> 36#include <kaction.h>
37 37
38#include <qglobal.h> 38#include <qglobal.h>
39 39
40#include "pwmview.h" 40#include "pwmview.h"
41#include "pwmexception.h" 41#include "pwmexception.h"
42 42
43 43
44/** timeout for displaying a message on the status-bar (in seconds) */ 44/** timeout for displaying a message on the status-bar (in seconds) */
45 #define STATUSBAR_MSG_TIMEOUT5 45 #define STATUSBAR_MSG_TIMEOUT5
46 46
47 47
48class PwMInit; 48class PwMInit;
49class KSyncManager; 49class KSyncManager;
50 50
51/** PwM is the base class of the project */ 51/** PwM is the base class of the project */
52#ifndef PWM_EMBEDDED 52#ifndef PWM_EMBEDDED
53//MOC_SKIP_BEGIN 53//MOC_SKIP_BEGIN
54class PwM : public KMainWindow 54class PwM : public KMainWindow
55//MOC_SKIP_END 55//MOC_SKIP_END
56#else 56#else
57class PwM : public KMainWindow, public KSyncInterface 57class PwM : public KMainWindow, public KSyncInterface
58#endif 58#endif
59{ 59{
60 Q_OBJECT 60 Q_OBJECT
61public: 61public:
62 friend class PwMView; 62 friend class PwMView;
63 /** construtor */ 63 /** construtor */
64 PwM(PwMInit *_init, PwMDoc *doc, 64 PwM(PwMInit *_init, PwMDoc *doc,
65 bool virginity = true, 65 bool virginity = true,
66 QWidget* parent = 0, const char *name = 0); 66 QWidget* parent = 0, const char *name = 0);
67 /** destructor */ 67 /** destructor */
68 ~PwM(); 68 ~PwM();
69 69
70 /** copy some text to the global clipboard */ 70 /** copy some text to the global clipboard */
71 static void copyToClipboard(const QString &s); 71 static void copyToClipboard(const QString &s);
72 72
73 /** returns pointer to the view */ 73 /** returns pointer to the view */
74 PwMView * curView() 74 PwMView * curView()
75 { return view; } 75 { return view; }
76 /** returns pointer to the currently using document. */ 76 /** returns pointer to the currently using document. */
77 PwMDoc * curDoc() 77 PwMDoc * curDoc()
78 { return curView()->document(); } 78 { return curView()->document(); }
79 /** open a new doc with the given filename */ 79 /** open a new doc with the given filename */
80 PwMDoc * openDoc(QString filename, bool openDeepLocked = false); 80 PwMDoc * openDoc(QString filename, bool openDeepLocked = false);
81 /** show a message on the global status bar. 81 /** show a message on the global status bar.
82 * The message times out after some seconds. 82 * The message times out after some seconds.
83 */ 83 */
84 void showStatMsg(const QString &msg); 84 void showStatMsg(const QString &msg);
85 /** ask the user where to save the doc (if it has not been saved, yet) 85 /** ask the user where to save the doc (if it has not been saved, yet)
86 * and write the data to disk. 86 * and write the data to disk.
87 */ 87 */
88 bool save(); 88 bool save();
89 /** ask the user where to save the doc 89 /** ask the user where to save the doc
90 * and write the data to disk. 90 * and write the data to disk.
91 */ 91 */
92 bool saveAs(); 92 bool saveAs();
93 /** force quit. Quit this window, always! Don't minimize it */ 93 /** force quit. Quit this window, always! Don't minimize it */
94 bool isForceQuit() 94 bool isForceQuit()
95 { return forceQuit; } 95 { return forceQuit; }
96 /** set forceQuit */ 96 /** set forceQuit */
97 void setForceQuit(bool force) 97 void setForceQuit(bool force)
98 { forceQuit = force; } 98 { forceQuit = force; }
99 /** force minimize this window */ 99 /** force minimize this window */
100 bool isForceMinimizeToTray() 100 bool isForceMinimizeToTray()
101 { return forceMinimizeToTray; } 101 { return forceMinimizeToTray; }
102 /** set forceMinimizeToTray */ 102 /** set forceMinimizeToTray */
103 void setForceMinimizeToTray(bool force) 103 void setForceMinimizeToTray(bool force)
104 { forceMinimizeToTray = force; } 104 { forceMinimizeToTray = force; }
105 105
106public slots: 106public slots:
107 /** file/new triggered */ 107 /** file/new triggered */
108 void new_slot(); 108 void new_slot();
109 /** file/open triggered */ 109 /** file/open triggered */
110//US ENH 110//US ENH
111 void open_slot(); 111 void open_slot();
112 void open_slot(QString fn); 112 void open_slot(QString fn);
113 /** file/close triggered */ 113 /** file/close triggered */
114 void close_slot(); 114 void close_slot();
115 /** file/quit triggered */ 115 /** file/quit triggered */
116 void quitButton_slot(); 116 void quitButton_slot();
117 /** file/save triggered */ 117 /** file/save triggered */
118 void save_slot(); 118 void save_slot();
119 /** file/saveAs triggered */ 119 /** file/saveAs triggered */
120 void saveAs_slot(); 120 void saveAs_slot();
121 /** file/export/text triggered */ 121 /** file/export/text triggered */
122 void exportToText(); 122 void exportToText();
123 /** file/export/gpasman triggered */ 123 /** file/export/gpasman triggered */
124 void exportToGpasman(); 124 void exportToGpasman();
125 /** file/export/kwallet triggered */ 125 /** file/export/kwallet triggered */
126 void exportToKWallet(); 126 void exportToKWallet();
127 /** file/import/text triggered */ 127 /** file/import/text triggered */
128 bool importFromText(); 128 bool importFromText();
129 /** file/import/gpasman triggered */ 129 /** file/import/gpasman triggered */
130 bool importFromGpasman(); 130 bool importFromGpasman();
131 /** file/import/kwallet triggered */ 131 /** file/import/kwallet triggered */
132 bool importKWallet(); 132 bool importKWallet();
133 /** file/print triggered */ 133 /** file/print triggered */
134 void print_slot(); 134 void print_slot();
135 /** manage/add triggered */ 135 /** manage/add triggered */
136 //US ENH : changed code to run with older MOC 136 //US ENH : changed code to run with older MOC
137 void addPwd_slot(); 137 void addPwd_slot();
138 void addPwd_slot(QString *pw, PwMDoc *_doc); 138 void addPwd_slot(QString *pw, PwMDoc *_doc);
139 /** manage/edit triggered */ 139 /** manage/edit triggered */
140 //US ENH : changed code to run with older MOC 140 //US ENH : changed code to run with older MOC
141 void editPwd_slot(); 141 void editPwd_slot();
142 void editPwd_slot(const QString *category); 142 void editPwd_slot(const QString *category);
143 void editPwd_slot(const QString *category = 0, const int *index = 0, 143 void editPwd_slot(const QString *category = 0, const int *index = 0,
144 PwMDoc *_doc = 0); 144 PwMDoc *_doc = 0);
145 /** manage/delete triggered */ 145 /** manage/delete triggered */
146 void deletePwd_slot(); 146 void deletePwd_slot();
147 /** execute the "Launcher" entry */ 147 /** execute the "Launcher" entry */
148 void execLauncher_slot(); 148 void execLauncher_slot();
149 /** open browser with URL entry */ 149 /** open browser with URL entry */
150 void goToURL_slot(); 150 void goToURL_slot();
151 /** manage/changeMasterPwd triggered */ 151 /** manage/changeMasterPwd triggered */
152 void changeMasterPwd_slot(); 152 void changeMasterPwd_slot();
153 /** lock current document */ 153 /** lock current document */
154 void lockWnd_slot(); 154 void lockWnd_slot();
155 /** deeplock current document */ 155 /** deeplock current document */
156 void deepLockWnd_slot(); 156 void deepLockWnd_slot();
157 /** window/unlock triggered */ 157 /** window/unlock triggered */
158 void unlockWnd_slot(); 158 void unlockWnd_slot();
159 /** find item */ 159 /** find item */
160 void find_slot(); 160 void find_slot();
161 /** configure clicked */ 161 /** configure clicked */
162 void config_slot(); 162 void config_slot();
163 /** (de)activate the "change master pw" button in the menu-bar */ 163 /** (de)activate the "change master pw" button in the menu-bar */
164 void activateMpButton(bool activate = true); 164 void activateMpButton(bool activate = true);
165 /** generate a new chipcard */ 165 /** generate a new chipcard */
166 void genNewCard_slot(); 166 void genNewCard_slot();
167 /** completely erase the current card */ 167 /** completely erase the current card */
168 void eraseCard_slot(); 168 void eraseCard_slot();
169 /** returns the ID number of the current card */ 169 /** returns the ID number of the current card */
170 void readCardId_slot(); 170 void readCardId_slot();
171 /** make backup image of the current card */ 171 /** make backup image of the current card */
172 void makeCardBackup_slot(); 172 void makeCardBackup_slot();
173 /** write backup image to current card */ 173 /** write backup image to current card */
174 void replayCardBackup_slot(); 174 void replayCardBackup_slot();
175 175
176#ifdef PWM_EMBEDDED 176#ifdef PWM_EMBEDDED
177 void showLicense_slot(); 177 void showLicense_slot();
178 void faq_slot(); 178 void faq_slot();
179 void createAboutData_slot(); 179 void createAboutData_slot();
180#endif 180#endif
181 181
182protected: 182protected:
183 /** is this window virgin? */ 183 /** is this window virgin? */
184 bool isVirgin() 184 bool isVirgin()
185 { return virgin; } 185 { return virgin; }
186 /** add/remove virginity */ 186 /** add/remove virginity */
187 void setVirgin(bool v); 187 void setVirgin(bool v);
188 /** initialize the menubar */ 188 /** initialize the menubar */
189 void initMenubar(); 189 void initMenubar();
190 /** initialize the toolbar */ 190 /** initialize the toolbar */
191 void initToolbar(); 191 void initToolbar();
192 /** initialize the window-metrics */ 192 /** initialize the window-metrics */
193 void initMetrics(); 193 void initMetrics();
194 /** close-event */ 194 /** close-event */
195 void closeEvent(QCloseEvent *e); 195 void closeEvent(QCloseEvent *e);
196 /** creates a new PwM-ListView and returns it */ 196 /** creates a new PwM-ListView and returns it */
197 PwMView * makeNewListView(PwMDoc *doc); 197 PwMView * makeNewListView(PwMDoc *doc);
198 /** Window hide-event */ 198 /** Window hide-event */
199 void hideEvent(QHideEvent *); 199 void hideEvent(QHideEvent *);
200 /** is this window minimized? */ 200 /** is this window minimized? */
201 bool isMinimized() 201 bool isMinimized()
202 { 202 {
203#ifndef PWM_EMBEDDED 203#ifndef PWM_EMBEDDED
204 #if KDE_VERSION >= KDE_MAKE_VERSION(3, 2, 0) 204 #if KDE_VERSION >= KDE_MAKE_VERSION(3, 2, 0)
205 return KWin::windowInfo(winId()).isMinimized(); 205 return KWin::windowInfo(winId()).isMinimized();
206 #else // KDE_VERSION 206 #else // KDE_VERSION
207 return KWin::info(winId()).isIconified(); 207 return KWin::info(winId()).isIconified();
208 #endif // KDE_VERSION 208 #endif // KDE_VERSION
209#else 209#else
210 return false; 210 return false;
211#endif 211#endif
212 } 212 }
213 /** window got the focus */ 213 /** window got the focus */
214 void focusInEvent(QFocusEvent *e); 214 void focusInEvent(QFocusEvent *e);
215 /** update the caption string */ 215 /** update the caption string */
216 void updateCaption(); 216 void updateCaption();
217#ifdef CONFIG_KWALLETIF 217#ifdef CONFIG_KWALLETIF
218 /** check if kwalletemu is enabled and ask the user what to do */ 218 /** check if kwalletemu is enabled and ask the user what to do */
219 bool checkAndAskForKWalletEmu(); 219 bool checkAndAskForKWalletEmu();
220#endif // CONFIG_KWALLETIF 220#endif // CONFIG_KWALLETIF
221 221
222protected slots: 222protected slots:
223 /** doc got closed */ 223 /** doc got closed */
224 void docClosed(PwMDoc *doc); 224 void docClosed(PwMDoc *doc);
225 225
226signals: 226signals:
227 /** window got closed (by user or someone else) */ 227 /** window got closed (by user or someone else) */
228 void closed(PwM *wnd); 228 void closed(PwM *wnd);
229 /** window got the focus (was brought to foreground) */ 229 /** window got the focus (was brought to foreground) */
230 void gotFocus(PwM *wnd); 230 void gotFocus(PwM *wnd);
231 /** window lost the focus */ 231 /** window lost the focus */
232 void lostFocus(PwM *wnd); 232 void lostFocus(PwM *wnd);
233 233
234protected: 234protected:
235 /** pointer to the view active in this KMainWindow */ 235 /** pointer to the view active in this KMainWindow */
236 PwMView *view; 236 PwMView *view;
237 /** pointer to the init class */ 237 /** pointer to the init class */
238 PwMInit *init; 238 PwMInit *init;
239 /** has this window already lost its virginity? 239 /** has this window already lost its virginity?
240 * Means is there an open working document 240 * Means is there an open working document
241 */ 241 */
242 bool virgin; 242 bool virgin;
243 /** "file" popup-menu */ 243 /** "file" popup-menu */
244 KPopupMenu *filePopup; 244 KPopupMenu *filePopup;
245 245
246 /** "manage" popup-menu */ 246 /** "manage" popup-menu */
247 KPopupMenu *managePopup; 247 KPopupMenu *managePopup;
248#ifdef CONFIG_KEYCARD 248#ifdef CONFIG_KEYCARD
249 /** "chipcard" popup-menu */ 249 /** "chipcard" popup-menu */
250 KPopupMenu *chipcardPopup; 250 KPopupMenu *chipcardPopup;
251#endif // CONFIG_KEYCARD 251#endif // CONFIG_KEYCARD
252 /** "view" popup-menu */ 252 /** "view" popup-menu */
253 KPopupMenu *viewPopup; 253 KPopupMenu *viewPopup;
254 /** "options" popup-menu */ 254 /** "options" popup-menu */
255 KPopupMenu *optionsPopup; 255 KPopupMenu *optionsPopup;
256 /** "help" popup-menu */ 256 /** "help" popup-menu */
257 KPopupMenu *helpPopup; 257 KPopupMenu *helpPopup;
258 /** "export" popup-menu */ 258 /** "export" popup-menu */
259 KPopupMenu *exportPopup; 259 KPopupMenu *exportPopup;
260 /** "import" popup-menu */ 260 /** "import" popup-menu */
261 KPopupMenu *importPopup; 261 KPopupMenu *importPopup;
262 /** force quit this window? */ 262 /** force quit this window? */
263 bool forceQuit; 263 bool forceQuit;
264 /** force minimize this window to the tray */ 264 /** force minimize this window to the tray */
265 bool forceMinimizeToTray; 265 bool forceMinimizeToTray;
266 266
267 267
268 268
269 269
270 private: 270 private:
271#ifdef PWM_EMBEDDED 271#ifdef PWM_EMBEDDED
272 //this are the overwritten callbackmethods from the syncinterface 272 //this are the overwritten callbackmethods from the syncinterface
273 virtual bool sync(KSyncManager* manager, QString filename, int mode); 273 virtual bool sync(KSyncManager* manager, QString filename, int mode);
274 virtual bool syncExternal(KSyncManager* manager, QString resource);
275 274
276 //called by the syncmanager to indicate that the work has to marked as dirty. 275 //called by the syncmanager to indicate that the work has to marked as dirty.
277 virtual void sync_setModified(); 276 virtual void sync_setModified();
278 //called by the syncmanager to ask if the dirty flag is set. 277 //called by the syncmanager to ask if the dirty flag is set.
279 virtual bool sync_isModified(); 278 virtual bool sync_isModified();
280 //called by the syncmanager to indicate that the work has to be saved. 279 //called by the syncmanager to indicate that the work has to be saved.
281 virtual void sync_save(); 280 virtual void sync_save();
282 281
283 // LR ******************************* 282 // LR *******************************
284 // sync stuff! 283 // sync stuff!
285 QPopupMenu *syncPopup; 284 QPopupMenu *syncPopup;
286 KSyncManager* syncManager; 285 KSyncManager* syncManager;
287#endif 286#endif
288 287
289 288
290 289
291 290
292 291
293 292
294 293
295 294
296}; 295};
297 296
298#endif 297#endif
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp
index 1b6d36f..82fc746 100644
--- a/pwmanager/pwmanager/pwmdoc.cpp
+++ b/pwmanager/pwmanager/pwmdoc.cpp
@@ -2528,259 +2528,351 @@ PwMerror PwMDoc::importText_PwM(const QString *file)
2528 // read comment-line 2528 // read comment-line
2529 if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) 2529 if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1)
2530 goto formatError; 2530 goto formatError;
2531 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.comment)) 2531 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.comment))
2532 goto formatError; 2532 goto formatError;
2533 2533
2534 // read URL-line 2534 // read URL-line
2535 if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) 2535 if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1)
2536 goto formatError; 2536 goto formatError;
2537 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.url)) 2537 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.url))
2538 goto formatError; 2538 goto formatError;
2539 2539
2540 // read launcher-line 2540 // read launcher-line
2541 if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) 2541 if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1)
2542 goto formatError; 2542 goto formatError;
2543 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.launcher)) 2543 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.launcher))
2544 goto formatError; 2544 goto formatError;
2545 2545
2546 currItem.lockStat = true; 2546 currItem.lockStat = true;
2547 currItem.listViewPos = -1; 2547 currItem.listViewPos = -1;
2548 addEntry(curCat.c_str(), &currItem, true); 2548 addEntry(curCat.c_str(), &currItem, true);
2549 ++entriesRead; 2549 ++entriesRead;
2550 } while (1); 2550 } while (1);
2551 } while (1); 2551 } while (1);
2552 if (!entriesRead) 2552 if (!entriesRead)
2553 goto formatError; 2553 goto formatError;
2554 2554
2555 free(ch_tmp); 2555 free(ch_tmp);
2556 fclose(f); 2556 fclose(f);
2557 flagDirty(); 2557 flagDirty();
2558 return e_success; 2558 return e_success;
2559 2559
2560 formatError: 2560 formatError:
2561 free(ch_tmp); 2561 free(ch_tmp);
2562 fclose(f); 2562 fclose(f);
2563 return e_fileFormat; 2563 return e_fileFormat;
2564} 2564}
2565 2565
2566bool PwMDoc::textExtractEntry_PwM(const char *in, ssize_t in_size, string *out) 2566bool PwMDoc::textExtractEntry_PwM(const char *in, ssize_t in_size, string *out)
2567{ 2567{
2568 PWM_ASSERT(in && out); 2568 PWM_ASSERT(in && out);
2569 ssize_t i = 0, len = in_size - 1; 2569 ssize_t i = 0, len = in_size - 1;
2570 while (i < len) { 2570 while (i < len) {
2571 if (in[i] == ':') 2571 if (in[i] == ':')
2572 break; 2572 break;
2573 ++i; 2573 ++i;
2574 } 2574 }
2575 i += 2; 2575 i += 2;
2576 *out = ""; 2576 *out = "";
2577 out->append(in + i, in_size - i - 1); 2577 out->append(in + i, in_size - i - 1);
2578 return true; 2578 return true;
2579} 2579}
2580 2580
2581PwMerror PwMDoc::exportToGpasman(const QString *file) 2581PwMerror PwMDoc::exportToGpasman(const QString *file)
2582{ 2582{
2583 PWM_ASSERT(file); 2583 PWM_ASSERT(file);
2584 GpasmanFile gp; 2584 GpasmanFile gp;
2585 int ret; 2585 int ret;
2586 2586
2587 if (!unlockAll_tempoary()) 2587 if (!unlockAll_tempoary())
2588 return e_lock; 2588 return e_lock;
2589 2589
2590 QString gpmPassword; 2590 QString gpmPassword;
2591 while (1) { 2591 while (1) {
2592 gpmPassword = requestNewMpw(0); 2592 gpmPassword = requestNewMpw(0);
2593 if (gpmPassword == "") { 2593 if (gpmPassword == "") {
2594 unlockAll_tempoary(true); 2594 unlockAll_tempoary(true);
2595 return e_noPw; 2595 return e_noPw;
2596 } 2596 }
2597 if (gpmPassword.length() < 4) { 2597 if (gpmPassword.length() < 4) {
2598 gpmPwLenErrMsgBox(); 2598 gpmPwLenErrMsgBox();
2599 } else { 2599 } else {
2600 break; 2600 break;
2601 } 2601 }
2602 } 2602 }
2603 2603
2604 ret = gp.save_init(file->latin1(), gpmPassword.latin1()); 2604 ret = gp.save_init(file->latin1(), gpmPassword.latin1());
2605 if (ret != 1) { 2605 if (ret != 1) {
2606 unlockAll_tempoary(true); 2606 unlockAll_tempoary(true);
2607 return e_accessFile; 2607 return e_accessFile;
2608 } 2608 }
2609 2609
2610 char *entry[4]; 2610 char *entry[4];
2611 unsigned int numCat = numCategories(), i; 2611 unsigned int numCat = numCategories(), i;
2612 unsigned int numEntr, j; 2612 unsigned int numEntr, j;
2613 int descLen, nameLen, pwLen, commentLen; 2613 int descLen, nameLen, pwLen, commentLen;
2614 for (i = 0; i < numCat; ++i) { 2614 for (i = 0; i < numCat; ++i) {
2615 numEntr = numEntries(i); 2615 numEntr = numEntries(i);
2616 for (j = 0; j < numEntr; ++j) { 2616 for (j = 0; j < numEntr; ++j) {
2617 descLen = dta[i].d[j].desc.length(); 2617 descLen = dta[i].d[j].desc.length();
2618 nameLen = dta[i].d[j].name.length(); 2618 nameLen = dta[i].d[j].name.length();
2619 pwLen = dta[i].d[j].pw.length(); 2619 pwLen = dta[i].d[j].pw.length();
2620 commentLen = dta[i].d[j].comment.length(); 2620 commentLen = dta[i].d[j].comment.length();
2621 entry[0] = new char[descLen + 1]; 2621 entry[0] = new char[descLen + 1];
2622 entry[1] = new char[nameLen + 1]; 2622 entry[1] = new char[nameLen + 1];
2623 entry[2] = new char[pwLen + 1]; 2623 entry[2] = new char[pwLen + 1];
2624 entry[3] = new char[commentLen + 1]; 2624 entry[3] = new char[commentLen + 1];
2625 strcpy(entry[0], descLen == 0 ? " " : dta[i].d[j].desc.c_str()); 2625 strcpy(entry[0], descLen == 0 ? " " : dta[i].d[j].desc.c_str());
2626 strcpy(entry[1], nameLen == 0 ? " " : dta[i].d[j].name.c_str()); 2626 strcpy(entry[1], nameLen == 0 ? " " : dta[i].d[j].name.c_str());
2627 strcpy(entry[2], pwLen == 0 ? " " : dta[i].d[j].pw.c_str()); 2627 strcpy(entry[2], pwLen == 0 ? " " : dta[i].d[j].pw.c_str());
2628 strcpy(entry[3], commentLen == 0 ? " " : dta[i].d[j].comment.c_str()); 2628 strcpy(entry[3], commentLen == 0 ? " " : dta[i].d[j].comment.c_str());
2629 entry[0][descLen == 0 ? descLen + 1 : descLen] = '\0'; 2629 entry[0][descLen == 0 ? descLen + 1 : descLen] = '\0';
2630 entry[1][nameLen == 0 ? nameLen + 1 : nameLen] = '\0'; 2630 entry[1][nameLen == 0 ? nameLen + 1 : nameLen] = '\0';
2631 entry[2][pwLen == 0 ? pwLen + 1 : pwLen] = '\0'; 2631 entry[2][pwLen == 0 ? pwLen + 1 : pwLen] = '\0';
2632 entry[3][commentLen == 0 ? commentLen + 1 : commentLen] = '\0'; 2632 entry[3][commentLen == 0 ? commentLen + 1 : commentLen] = '\0';
2633 2633
2634 ret = gp.save_entry(entry); 2634 ret = gp.save_entry(entry);
2635 if (ret == -1){ 2635 if (ret == -1){
2636 delete [] entry[0]; 2636 delete [] entry[0];
2637 delete [] entry[1]; 2637 delete [] entry[1];
2638 delete [] entry[2]; 2638 delete [] entry[2];
2639 delete [] entry[3]; 2639 delete [] entry[3];
2640 gp.save_finalize(); 2640 gp.save_finalize();
2641 unlockAll_tempoary(true); 2641 unlockAll_tempoary(true);
2642 return e_writeFile; 2642 return e_writeFile;
2643 } 2643 }
2644 2644
2645 delete [] entry[0]; 2645 delete [] entry[0];
2646 delete [] entry[1]; 2646 delete [] entry[1];
2647 delete [] entry[2]; 2647 delete [] entry[2];
2648 delete [] entry[3]; 2648 delete [] entry[3];
2649 } 2649 }
2650 } 2650 }
2651 unlockAll_tempoary(true); 2651 unlockAll_tempoary(true);
2652 if (gp.save_finalize() == -1) 2652 if (gp.save_finalize() == -1)
2653 return e_writeFile; 2653 return e_writeFile;
2654 2654
2655 return e_success; 2655 return e_success;
2656} 2656}
2657 2657
2658PwMerror PwMDoc::importFromGpasman(const QString *file) 2658PwMerror PwMDoc::importFromGpasman(const QString *file)
2659{ 2659{
2660 PWM_ASSERT(file); 2660 PWM_ASSERT(file);
2661 QString pw = requestMpw(false); 2661 QString pw = requestMpw(false);
2662 if (pw == "") 2662 if (pw == "")
2663 return e_noPw; 2663 return e_noPw;
2664 GpasmanFile gp; 2664 GpasmanFile gp;
2665 int ret, i; 2665 int ret, i;
2666 PwMerror ret2; 2666 PwMerror ret2;
2667 char *entry[4]; 2667 char *entry[4];
2668 PwMDataItem tmpData; 2668 PwMDataItem tmpData;
2669 ret = gp.load_init(file->latin1(), pw.latin1()); 2669 ret = gp.load_init(file->latin1(), pw.latin1());
2670 if (ret != 1) 2670 if (ret != 1)
2671 return e_accessFile; 2671 return e_accessFile;
2672 2672
2673 do { 2673 do {
2674 ret = gp.load_entry(entry); 2674 ret = gp.load_entry(entry);
2675 if(ret != 1) 2675 if(ret != 1)
2676 break; 2676 break;
2677 tmpData.desc = entry[0]; 2677 tmpData.desc = entry[0];
2678 tmpData.name = entry[1]; 2678 tmpData.name = entry[1];
2679 tmpData.pw = entry[2]; 2679 tmpData.pw = entry[2];
2680 tmpData.comment = entry[3]; 2680 tmpData.comment = entry[3];
2681 tmpData.lockStat = true; 2681 tmpData.lockStat = true;
2682 tmpData.listViewPos = -1; 2682 tmpData.listViewPos = -1;
2683 ret2 = addEntry(DEFAULT_CATEGORY, &tmpData, true); 2683 ret2 = addEntry(DEFAULT_CATEGORY, &tmpData, true);
2684 for (i = 0; i < 4; ++i) 2684 for (i = 0; i < 4; ++i)
2685 free(entry[i]); 2685 free(entry[i]);
2686 if (ret2 == e_maxAllowedEntr) { 2686 if (ret2 == e_maxAllowedEntr) {
2687 gp.load_finalize(); 2687 gp.load_finalize();
2688 return e_maxAllowedEntr; 2688 return e_maxAllowedEntr;
2689 } 2689 }
2690 } while (1); 2690 } while (1);
2691 gp.load_finalize(); 2691 gp.load_finalize();
2692 if (isDocEmpty()) 2692 if (isDocEmpty())
2693 return e_wrongPw; // we assume this. 2693 return e_wrongPw; // we assume this.
2694 2694
2695 flagDirty(); 2695 flagDirty();
2696 return e_success; 2696 return e_success;
2697} 2697}
2698 2698
2699void PwMDoc::ensureLvp() 2699void PwMDoc::ensureLvp()
2700{ 2700{
2701 if (isDocEmpty()) 2701 if (isDocEmpty())
2702 return; 2702 return;
2703 2703
2704 vector< vector<PwMDataItem>::iterator > undefined; 2704 vector< vector<PwMDataItem>::iterator > undefined;
2705 vector< vector<PwMDataItem>::iterator >::iterator undefBegin, 2705 vector< vector<PwMDataItem>::iterator >::iterator undefBegin,
2706 undefEnd, 2706 undefEnd,
2707 undefI; 2707 undefI;
2708 vector<PwMCategoryItem>::iterator catBegin = dta.begin(), 2708 vector<PwMCategoryItem>::iterator catBegin = dta.begin(),
2709 catEnd = dta.end(), 2709 catEnd = dta.end(),
2710 catI = catBegin; 2710 catI = catBegin;
2711 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; 2711 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI;
2712 int lvpTop, tmpLvp; 2712 int lvpTop, tmpLvp;
2713 2713
2714 while (catI != catEnd) { 2714 while (catI != catEnd) {
2715 lvpTop = -1; 2715 lvpTop = -1;
2716 undefined.clear(); 2716 undefined.clear();
2717 2717
2718 entrBegin = catI->d.begin(); 2718 entrBegin = catI->d.begin();
2719 entrEnd = catI->d.end(); 2719 entrEnd = catI->d.end();
2720 entrI = entrBegin; 2720 entrI = entrBegin;
2721 2721
2722 while (entrI != entrEnd) { 2722 while (entrI != entrEnd) {
2723 tmpLvp = entrI->listViewPos; 2723 tmpLvp = entrI->listViewPos;
2724 if (tmpLvp == -1) 2724 if (tmpLvp == -1)
2725 undefined.push_back(entrI); 2725 undefined.push_back(entrI);
2726 else if (tmpLvp > lvpTop) 2726 else if (tmpLvp > lvpTop)
2727 lvpTop = tmpLvp; 2727 lvpTop = tmpLvp;
2728 ++entrI; 2728 ++entrI;
2729 } 2729 }
2730 undefBegin = undefined.begin(); 2730 undefBegin = undefined.begin();
2731 undefEnd = undefined.end(); 2731 undefEnd = undefined.end();
2732 undefI = undefBegin; 2732 undefI = undefBegin;
2733 while (undefI != undefEnd) { 2733 while (undefI != undefEnd) {
2734 (*undefI)->listViewPos = ++lvpTop; 2734 (*undefI)->listViewPos = ++lvpTop;
2735 ++undefI; 2735 ++undefI;
2736 } 2736 }
2737 ++catI; 2737 ++catI;
2738 } 2738 }
2739} 2739}
2740 2740
2741QString PwMDoc::getTitle() 2741QString PwMDoc::getTitle()
2742{ 2742{
2743 /* NOTE: We have to ensure, that the returned title 2743 /* NOTE: We have to ensure, that the returned title
2744 * is unique and not reused somewhere else while 2744 * is unique and not reused somewhere else while
2745 * this document is valid (open). 2745 * this document is valid (open).
2746 */ 2746 */
2747 QString title(getFilename()); 2747 QString title(getFilename());
2748 if (title.isEmpty()) { 2748 if (title.isEmpty()) {
2749 if (unnamedNum == 0) { 2749 if (unnamedNum == 0) {
2750 unnamedNum = PwMDocList::getNewUnnamedNumber(); 2750 unnamedNum = PwMDocList::getNewUnnamedNumber();
2751 PWM_ASSERT(unnamedNum != 0); 2751 PWM_ASSERT(unnamedNum != 0);
2752 } 2752 }
2753 title = DEFAULT_TITLE; 2753 title = DEFAULT_TITLE;
2754 title += " "; 2754 title += " ";
2755 title += tostr(unnamedNum).c_str(); 2755 title += tostr(unnamedNum).c_str();
2756 } 2756 }
2757 return title; 2757 return title;
2758} 2758}
2759 2759
2760bool PwMDoc::tryDelete() 2760bool PwMDoc::tryDelete()
2761{ 2761{
2762 if (deleted) 2762 if (deleted)
2763 return true; 2763 return true;
2764 int ret; 2764 int ret;
2765 if (isDirty()) { 2765 if (isDirty()) {
2766 ret = dirtyAskSave(getTitle()); 2766 ret = dirtyAskSave(getTitle());
2767 if (ret == 0) { // save to disk 2767 if (ret == 0) { // save to disk
2768 if (!saveDocUi(this)) 2768 if (!saveDocUi(this))
2769 goto out_ignore; 2769 goto out_ignore;
2770 } else if (ret == 1) { // don't save and delete 2770 } else if (ret == 1) { // don't save and delete
2771 goto out_accept; 2771 goto out_accept;
2772 } else { // cancel operation 2772 } else { // cancel operation
2773 goto out_ignore; 2773 goto out_ignore;
2774 } 2774 }
2775 } 2775 }
2776out_accept: 2776out_accept:
2777 deleted = true; 2777 deleted = true;
2778 delete this; 2778 delete this;
2779 return true; 2779 return true;
2780out_ignore: 2780out_ignore:
2781 return false; 2781 return false;
2782} 2782}
2783 2783
2784
2785
2786#ifdef PWM_EMBEDDED
2787//US ENH: this is the magic function that syncronizes the this doc with the remote doc
2788PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* syncRemote, int mode )
2789{
2790 bool syncOK = true;
2791 int addedPasswordsLocal = 0;
2792 int addedPasswordsRemote = 0;
2793 int deletedPasswordsRemote = 0;
2794 int deletedPasswordsLocal = 0;
2795 int changedLocal = 0;
2796 int changedRemote = 0;
2797
2798 QString mCurrentSyncName = manager->getCurrentSyncName();
2799 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809 return e_success;
2810}
2811
2812
2813
2814//this are the overwritten callbackmethods from the syncinterface
2815bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode)
2816{
2817 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2818
2819 // construct on the stack = automatic cleanup.
2820 PwMDoc syncTarget(this, "synctarget");
2821
2822 PwMerror err = syncTarget.openDoc(&filename, 2 /*== deeplocked*/);
2823
2824 if (err != e_success)
2825 return false;
2826
2827 qDebug("PWM file loaded %s,sync mode %d",filename.latin1(), mode );
2828
2829
2830 err = syncronize(manager, this, &syncTarget, mode );
2831
2832 if (err == e_success) {
2833 if ( PWMPrefs::instance()->mWriteBackFile ){
2834 qDebug("Saving remote PWManager file");
2835 err = syncTarget.saveDoc(conf()->confGlobCompression());
2836 if (err != e_success)
2837 return false;
2838
2839 }
2840
2841 flagDirty();
2842 return true;
2843 }
2844 else {
2845 return false;
2846 }
2847}
2848
2849//called by the syncmanager to indicate that the work has to marked as dirty.
2850void PwMDoc::sync_setModified()
2851{
2852 flagDirty();
2853}
2854
2855//called by the syncmanager to ask if the dirty flag is set.
2856bool PwMDoc::sync_isModified()
2857{
2858 return isDirty();
2859}
2860
2861//called by the syncmanager to indicate that the work has to be saved.
2862void PwMDoc::sync_save()
2863{
2864 PwMerror ret = saveDoc(conf()->confGlobCompression());
2865}
2866
2867#endif
2868
2869
2870
2871
2872
2873
2874
2875
2784#ifndef PWM_EMBEDDED 2876#ifndef PWM_EMBEDDED
2785#include "pwmdoc.moc" 2877#include "pwmdoc.moc"
2786#endif 2878#endif
diff --git a/pwmanager/pwmanager/pwmdoc.h b/pwmanager/pwmanager/pwmdoc.h
index 193247e..ea4d687 100644
--- a/pwmanager/pwmanager/pwmdoc.h
+++ b/pwmanager/pwmanager/pwmdoc.h
@@ -1,701 +1,724 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2003, 2004 by Michael Buesch * 3 * copyright (C) 2003, 2004 by Michael Buesch *
4 * email: mbuesch@freenet.de * 4 * email: mbuesch@freenet.de *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License version 2 * 7 * it under the terms of the GNU General Public License version 2 *
8 * as published by the Free Software Foundation. * 8 * as published by the Free Software Foundation. *
9 * * 9 * *
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12/*************************************************************************** 12/***************************************************************************
13 * copyright (C) 2004 by Ulf Schenk 13 * copyright (C) 2004 by Ulf Schenk
14 * This file is originaly based on version 2.0 of pwmanager 14 * This file is originaly based on version 2.0 of pwmanager
15 * and was modified to run on embedded devices that run microkde 15 * and was modified to run on embedded devices that run microkde
16 * 16 *
17 * $Id$ 17 * $Id$
18 **************************************************************************/ 18 **************************************************************************/
19 19
20#ifndef __PWMDOC_H 20#ifndef __PWMDOC_H
21#define __PWMDOC_H 21#define __PWMDOC_H
22 22
23 #define PWM_FILE_VER (static_cast<char>(0x05)) 23 #define PWM_FILE_VER (static_cast<char>(0x05))
24 24
25 #define PWM_HASH_SHA1 (static_cast<char>(0x01)) 25 #define PWM_HASH_SHA1 (static_cast<char>(0x01))
26 #define PWM_HASH_SHA256 (static_cast<char>(0x02)) 26 #define PWM_HASH_SHA256 (static_cast<char>(0x02))
27 #define PWM_HASH_SHA384 (static_cast<char>(0x03)) 27 #define PWM_HASH_SHA384 (static_cast<char>(0x03))
28 #define PWM_HASH_SHA512 (static_cast<char>(0x04)) 28 #define PWM_HASH_SHA512 (static_cast<char>(0x04))
29 #define PWM_HASH_MD5 (static_cast<char>(0x05)) 29 #define PWM_HASH_MD5 (static_cast<char>(0x05))
30 #define PWM_HASH_RMD160 (static_cast<char>(0x06)) 30 #define PWM_HASH_RMD160 (static_cast<char>(0x06))
31 #define PWM_HASH_TIGER (static_cast<char>(0x07)) 31 #define PWM_HASH_TIGER (static_cast<char>(0x07))
32 32
33 #define PWM_CRYPT_BLOWFISH(static_cast<char>(0x01)) 33 #define PWM_CRYPT_BLOWFISH(static_cast<char>(0x01))
34 #define PWM_CRYPT_AES128(static_cast<char>(0x02)) 34 #define PWM_CRYPT_AES128(static_cast<char>(0x02))
35 #define PWM_CRYPT_AES192(static_cast<char>(0x03)) 35 #define PWM_CRYPT_AES192(static_cast<char>(0x03))
36 #define PWM_CRYPT_AES256(static_cast<char>(0x04)) 36 #define PWM_CRYPT_AES256(static_cast<char>(0x04))
37 #define PWM_CRYPT_3DES (static_cast<char>(0x05)) 37 #define PWM_CRYPT_3DES (static_cast<char>(0x05))
38 #define PWM_CRYPT_TWOFISH(static_cast<char>(0x06)) 38 #define PWM_CRYPT_TWOFISH(static_cast<char>(0x06))
39 #define PWM_CRYPT_TWOFISH128(static_cast<char>(0x07)) 39 #define PWM_CRYPT_TWOFISH128(static_cast<char>(0x07))
40 40
41 #define PWM_COMPRESS_NONE(static_cast<char>(0x00)) 41 #define PWM_COMPRESS_NONE(static_cast<char>(0x00))
42 #define PWM_COMPRESS_GZIP(static_cast<char>(0x01)) 42 #define PWM_COMPRESS_GZIP(static_cast<char>(0x01))
43 #define PWM_COMPRESS_BZIP2(static_cast<char>(0x02)) 43 #define PWM_COMPRESS_BZIP2(static_cast<char>(0x02))
44 44
45 #define DEFAULT_MAX_ENTRIES(~(static_cast<unsigned int>(0))) 45 #define DEFAULT_MAX_ENTRIES(~(static_cast<unsigned int>(0)))
46 #define FILE_ID_HEADER "PWM_PASSWORD_FILE" 46 #define FILE_ID_HEADER "PWM_PASSWORD_FILE"
47 47
48 48
49#include "pwmexception.h" 49#include "pwmexception.h"
50#include "pwmdocui.h" 50#include "pwmdocui.h"
51 51
52#include <qobject.h> 52#include <qobject.h>
53#include <qtimer.h> 53#include <qtimer.h>
54#include <qdatetime.h> 54#include <qdatetime.h>
55 55
56#include <kprocess.h> 56#include <kprocess.h>
57 57
58#ifndef PWM_EMBEDDED 58#ifndef PWM_EMBEDDED
59#include "configuration.h" 59#include "configuration.h"
60#else 60#else
61#include <kapplication.h> 61#include <kapplication.h>
62#include <ksyncmanager.h>
62#endif 63#endif
63 64
64#include <string> 65#include <string>
65#include <vector> 66#include <vector>
66#include <utility> 67#include <utility>
67 68
68using std::vector; 69using std::vector;
69using std::string; 70using std::string;
70using std::pair; 71using std::pair;
71 72
72/* used in findEntry() function */ 73/* used in findEntry() function */
73 #define SEARCH_IN_DESC (1) 74 #define SEARCH_IN_DESC (1)
74 #define SEARCH_IN_NAME (1 << 1) 75 #define SEARCH_IN_NAME (1 << 1)
75 #define SEARCH_IN_PW (1 << 2) 76 #define SEARCH_IN_PW (1 << 2)
76 #define SEARCH_IN_COMMENT(1 << 3) 77 #define SEARCH_IN_COMMENT(1 << 3)
77 #define SEARCH_IN_URL (1 << 4) 78 #define SEARCH_IN_URL (1 << 4)
78 #define SEARCH_IN_LAUNCHER(1 << 5) 79 #define SEARCH_IN_LAUNCHER(1 << 5)
79 #define SEARCH_IN_ALL (SEARCH_IN_DESC | SEARCH_IN_NAME| \ 80 #define SEARCH_IN_ALL (SEARCH_IN_DESC | SEARCH_IN_NAME| \
80 SEARCH_IN_PW | SEARCH_IN_COMMENT| \ 81 SEARCH_IN_PW | SEARCH_IN_COMMENT| \
81 SEARCH_IN_URL| SEARCH_IN_LAUNCHER) 82 SEARCH_IN_URL| SEARCH_IN_LAUNCHER)
82 83
83/** document deeplocked. Data is out for lunch to disk */ 84/** document deeplocked. Data is out for lunch to disk */
84 #define DOC_STAT_DEEPLOCKED (1) 85 #define DOC_STAT_DEEPLOCKED (1)
85/** encrypted document on disk is dirty. data has to go to disk. */ 86/** encrypted document on disk is dirty. data has to go to disk. */
86 #define DOC_STAT_DISK_DIRTY (1 << 1) 87 #define DOC_STAT_DISK_DIRTY (1 << 1)
87/** we are using a chipcard to encrypt the data */ 88/** we are using a chipcard to encrypt the data */
88 #define DOC_STAT_USE_CHIPCARD (1 << 2) 89 #define DOC_STAT_USE_CHIPCARD (1 << 2)
89/** use "currentPw" to unlock. (This flag is set/unset by a timer) */ 90/** use "currentPw" to unlock. (This flag is set/unset by a timer) */
90 #define DOC_STAT_UNLOCK_WITHOUT_PW(1 << 3) 91 #define DOC_STAT_UNLOCK_WITHOUT_PW(1 << 3)
91 92
92class PwMDoc; 93class PwMDoc;
93class PwMView; 94class PwMView;
94class QFile; 95class QFile;
95 96
96/* meta data for a PwMDataItem */ 97/* meta data for a PwMDataItem */
97struct PwMMetaData 98struct PwMMetaData
98{ 99{
99 PwMMetaData() 100 PwMMetaData()
100 : updateInt (0) 101 : updateInt (0)
101 { } 102 { }
102 /** creation date of the PwMDataItem to which 103 /** creation date of the PwMDataItem to which
103 * this meta data belongs. 104 * this meta data belongs.
104 */ 105 */
105 QDateTimecreate; 106 QDateTimecreate;
106 /** becomes valid on this date */ 107 /** becomes valid on this date */
107 QDateTimevalid; 108 QDateTimevalid;
108 /** expire date */ 109 /** expire date */
109 QDateTimeexpire; 110 QDateTimeexpire;
110 /** update date (last updated at this date) */ 111 /** update date (last updated at this date) */
111 QDateTimeupdate; 112 QDateTimeupdate;
112 /** update interval (in minutes). Time since the 113 /** update interval (in minutes). Time since the
113 * last update to remind the user to update the item. 114 * last update to remind the user to update the item.
114 * 0 disables. 115 * 0 disables.
115 */ 116 */
116 unsigned long updateInt; 117 unsigned long updateInt;
117 118
118 //US ENH: enhancements of the filestructure 119 //US ENH: enhancements of the filestructure
119 /* each entry gets a unique id assigned */ 120 /* each entry gets a unique id assigned */
120 QString uniqueid; 121 QString uniqueid;
121 122
122 123
123 void clear() 124 void clear()
124 { 125 {
125 create = QDateTime(); 126 create = QDateTime();
126 expire = QDateTime(); 127 expire = QDateTime();
127 update = QDateTime(); 128 update = QDateTime();
128 updateInt = 0; 129 updateInt = 0;
129 uniqueid = KApplication::randomString(8); 130 uniqueid = KApplication::randomString(8);
130 } 131 }
131 inline bool isValid() const 132 inline bool isValid() const
132 { 133 {
133 if (valid.isNull()) 134 if (valid.isNull())
134 return true; 135 return true;
135 return (valid < QDateTime::currentDateTime()); 136 return (valid < QDateTime::currentDateTime());
136 } 137 }
137 inline bool isExpired() const 138 inline bool isExpired() const
138 { 139 {
139 if (expire.isNull()) 140 if (expire.isNull())
140 return false; 141 return false;
141 return (expire < QDateTime::currentDateTime()); 142 return (expire < QDateTime::currentDateTime());
142 } 143 }
143 inline bool isUpdateIntOver() const 144 inline bool isUpdateIntOver() const
144 { 145 {
145 if (updateInt == 0 || 146 if (updateInt == 0 ||
146 update.isNull()) 147 update.isNull())
147 return false; 148 return false;
148 QDateTime d(update); 149 QDateTime d(update);
149 return (d.addSecs(updateInt * 60) < QDateTime::currentDateTime()); 150 return (d.addSecs(updateInt * 60) < QDateTime::currentDateTime());
150 } 151 }
151}; 152};
152 153
153struct PwMDataItem 154struct PwMDataItem
154{ 155{
155 PwMDataItem() 156 PwMDataItem()
156 : lockStat (true) 157 : lockStat (true)
157 , listViewPos (-1) 158 , listViewPos (-1)
158 , binary (false) 159 , binary (false)
159 , rev (0) 160 , rev (0)
160 { } 161 { }
161 162
162 /** password description */ 163 /** password description */
163 stringdesc; 164 stringdesc;
164 /** user-name */ 165 /** user-name */
165 stringname; 166 stringname;
166 /** the password itself */ 167 /** the password itself */
167 stringpw; 168 stringpw;
168 /** some comment */ 169 /** some comment */
169 stringcomment; 170 stringcomment;
170 /** an URL string */ 171 /** an URL string */
171 stringurl; 172 stringurl;
172 /** launcher. Can be executed as a system() command */ 173 /** launcher. Can be executed as a system() command */
173 stringlauncher; 174 stringlauncher;
174 /** locking status. If locked (true), pw is not emitted through getEntry() */ 175 /** locking status. If locked (true), pw is not emitted through getEntry() */
175 boollockStat; 176 boollockStat;
176 /** position of this item in main "list-view" 177 /** position of this item in main "list-view"
177 * If -1, the position is not yet specified and should be appended to the list 178 * If -1, the position is not yet specified and should be appended to the list
178 */ 179 */
179 intlistViewPos; 180 intlistViewPos;
180 /** does this entry contain binary data? */ 181 /** does this entry contain binary data? */
181 bool binary; 182 bool binary;
182 /** meta data for this data item. */ 183 /** meta data for this data item. */
183 PwMMetaData meta; 184 PwMMetaData meta;
184 /** data revision counter. This counter can be used 185 /** data revision counter. This counter can be used
185 * to easily, efficiently determine if this data item 186 * to easily, efficiently determine if this data item
186 * has changed since some time. 187 * has changed since some time.
187 * This counter is incremented on every update. 188 * This counter is incremented on every update.
188 */ 189 */
189 unsigned int rev; 190 unsigned int rev;
190 191
191 void clear(bool clearMeta = true) 192 void clear(bool clearMeta = true)
192 { 193 {
193 /* NOTE: Don't use .clear() here to be 194 /* NOTE: Don't use .clear() here to be
194 * backward compatible with gcc-2 (Debian Woody) 195 * backward compatible with gcc-2 (Debian Woody)
195 */ 196 */
196 desc = ""; 197 desc = "";
197 name = ""; 198 name = "";
198 pw = ""; 199 pw = "";
199 comment = ""; 200 comment = "";
200 url = ""; 201 url = "";
201 launcher = ""; 202 launcher = "";
202 lockStat = true; 203 lockStat = true;
203 listViewPos = -1; 204 listViewPos = -1;
204 binary = false; 205 binary = false;
205 if (clearMeta) 206 if (clearMeta)
206 meta.clear(); 207 meta.clear();
207 } 208 }
208}; 209};
209 210
210struct PwMCategoryItem 211struct PwMCategoryItem
211{ 212{
212 /** all PwMDataItems (all passwords) within this category */ 213 /** all PwMDataItems (all passwords) within this category */
213 vector<PwMDataItem>d; 214 vector<PwMDataItem>d;
214 /** category name/description */ 215 /** category name/description */
215 string name; 216 string name;
216 217
217 void clear() 218 void clear()
218 { 219 {
219 d.clear(); 220 d.clear();
220 name = ""; 221 name = "";
221 } 222 }
222}; 223};
223 224
224/** "Function Object" for sort()ing PwMDataItem::listViewPos */ 225/** "Function Object" for sort()ing PwMDataItem::listViewPos */
225class dta_lvp_greater 226class dta_lvp_greater
226{ 227{
227public: 228public:
228 bool operator() (const pair<unsigned int, unsigned int> &d1, 229 bool operator() (const pair<unsigned int, unsigned int> &d1,
229 const pair<unsigned int, unsigned int> &d2) 230 const pair<unsigned int, unsigned int> &d2)
230 { 231 {
231 return d1.second > d2.second; 232 return d1.second > d2.second;
232 } 233 }
233}; 234};
234 235
235/** list of PwMDoc documents and it's IDs */ 236/** list of PwMDoc documents and it's IDs */
236class PwMDocList 237class PwMDocList
237{ 238{
238public: 239public:
239 struct listItem 240 struct listItem
240 { 241 {
241 /** document filename (known as ID, here) */ 242 /** document filename (known as ID, here) */
242 string docId; 243 string docId;
243 /** pointer to the document class */ 244 /** pointer to the document class */
244 PwMDoc *doc; 245 PwMDoc *doc;
245 }; 246 };
246 247
247 PwMDocList() {} 248 PwMDocList() {}
248 249
249 /** add a new item to the list */ 250 /** add a new item to the list */
250 void add(PwMDoc *doc, const string &id); 251 void add(PwMDoc *doc, const string &id);
251 /** changes the contents of an existing item */ 252 /** changes the contents of an existing item */
252 void edit(PwMDoc *doc, const string &newId); 253 void edit(PwMDoc *doc, const string &newId);
253 /** remove the given item */ 254 /** remove the given item */
254 void del(PwMDoc *doc); 255 void del(PwMDoc *doc);
255 /** get the item at index */ 256 /** get the item at index */
256 listItem getAt(int index) 257 listItem getAt(int index)
257 { return docList[index]; } 258 { return docList[index]; }
258 /** find an entry with this id */ 259 /** find an entry with this id */
259 bool find(const string &id, listItem *ret = 0); 260 bool find(const string &id, listItem *ret = 0);
260 /** returns a copy of the list */ 261 /** returns a copy of the list */
261 const vector<listItem>* getList() const 262 const vector<listItem>* getList() const
262 { return &docList; } 263 { return &docList; }
263 264
264 265
265 /** returns a new unique number to extend the name of 266 /** returns a new unique number to extend the name of
266 * an unnamed document. 267 * an unnamed document.
267 */ 268 */
268 static unsigned int getNewUnnamedNumber() 269 static unsigned int getNewUnnamedNumber()
269 { return unnamedDocCnt++; } 270 { return unnamedDocCnt++; }
270 271
271protected: 272protected:
272 /* Hm, I think we shouldn't really use a "list" here, should we? 273 /* Hm, I think we shouldn't really use a "list" here, should we?
273 * So I decided to actually use a vector. 274 * So I decided to actually use a vector.
274 */ 275 */
275 vector<listItem> docList; 276 vector<listItem> docList;
276 /** This value is used to get a new number for yet unnamed 277 /** This value is used to get a new number for yet unnamed
277 * documents. It is incremented on every request. So it's 278 * documents. It is incremented on every request. So it's
278 * theoretically possible to overflow it, but... :) 279 * theoretically possible to overflow it, but... :)
279 */ 280 */
280 static unsigned int unnamedDocCnt; 281 static unsigned int unnamedDocCnt;
281}; 282};
282 283
283/** implements timers for the document */ 284/** implements timers for the document */
284class DocTimer : public QObject 285class DocTimer : public QObject
285{ 286{
286 Q_OBJECT 287 Q_OBJECT
287public: 288public:
288 enum TimerIDs 289 enum TimerIDs
289 { 290 {
290 id_mpwTimer, 291 id_mpwTimer,
291 id_autoLockTimer, 292 id_autoLockTimer,
292 id_metaCheckTimer 293 id_metaCheckTimer
293 }; 294 };
294 295
295public: 296public:
296 DocTimer(PwMDoc *_doc); 297 DocTimer(PwMDoc *_doc);
297 ~DocTimer(); 298 ~DocTimer();
298 299
299 /** start the timer */ 300 /** start the timer */
300 void start(TimerIDs timer); 301 void start(TimerIDs timer);
301 /** stop the timer */ 302 /** stop the timer */
302 void stop(TimerIDs timer); 303 void stop(TimerIDs timer);
303 /** get the lock for a timer. 304 /** get the lock for a timer.
304 * This lock is a recursive lock. When a lock is 305 * This lock is a recursive lock. When a lock is
305 * held, the timer will be stopped and timeout is 306 * held, the timer will be stopped and timeout is
306 * guaranteed to not happen 307 * guaranteed to not happen
307 */ 308 */
308 void getLock(TimerIDs timer); 309 void getLock(TimerIDs timer);
309 /** put a recursive timer lock */ 310 /** put a recursive timer lock */
310 void putLock(TimerIDs timer); 311 void putLock(TimerIDs timer);
311 312
312protected slots: 313protected slots:
313 /** timeout slot for the mpw timer */ 314 /** timeout slot for the mpw timer */
314 void mpwTimeout(); 315 void mpwTimeout();
315 /** timeout slot for the autoLock timer */ 316 /** timeout slot for the autoLock timer */
316 void autoLockTimeout(); 317 void autoLockTimeout();
317 /** timeout slot for the metaCheck timer */ 318 /** timeout slot for the metaCheck timer */
318 void metaCheckTimeout(); 319 void metaCheckTimeout();
319 320
320protected: 321protected:
321 /** pointer to the document associated with this timer. */ 322 /** pointer to the document associated with this timer. */
322 PwMDoc *doc; 323 PwMDoc *doc;
323 /** timer object for mpw timer */ 324 /** timer object for mpw timer */
324 QTimer *mpwTimer; 325 QTimer *mpwTimer;
325 /** timer object for the autoLock timer */ 326 /** timer object for the autoLock timer */
326 QTimer *autoLockTimer; 327 QTimer *autoLockTimer;
327 /** timer object for the metaCheck timer */ 328 /** timer object for the metaCheck timer */
328 QTimer *metaCheckTimer; 329 QTimer *metaCheckTimer;
329 /** lock counter for the mpw timer */ 330 /** lock counter for the mpw timer */
330 unsigned int mpwLock; 331 unsigned int mpwLock;
331 /** lock counter for the autoLock timer */ 332 /** lock counter for the autoLock timer */
332 unsigned int autoLockLock; 333 unsigned int autoLockLock;
333 /** lock counter for the metaCheck timer */ 334 /** lock counter for the metaCheck timer */
334 unsigned int metaCheckLock; 335 unsigned int metaCheckLock;
335}; 336};
336 337
337/** Document class for PwM */ 338/** Document class for PwM */
338class PwMDoc : public PwMDocUi 339//US ENH: derived from KSyncInterfaces, to get called by PwM when a sync is required.
340// But PwMDoc is handling the sync by itself.
341class PwMDoc : public PwMDocUi, public KSyncInterface
342
339{ 343{
340 Q_OBJECT 344 Q_OBJECT
341 friend class DocTimer; 345 friend class DocTimer;
342 346
343public: 347public:
344 /** construtor */ 348 /** construtor */
345 PwMDoc(QObject* parent = 0, const char *name = 0); 349 PwMDoc(QObject* parent = 0, const char *name = 0);
346 /** destructor */ 350 /** destructor */
347 ~PwMDoc(); 351 ~PwMDoc();
348 352
349 /** returns a pointer to a list of all open documents */ 353 /** returns a pointer to a list of all open documents */
350 static PwMDocList* getOpenDocList() 354 static PwMDocList* getOpenDocList()
351 { return &openDocList; } 355 { return &openDocList; }
352 356
353 /** flag document dirty. dta changed */ 357 /** flag document dirty. dta changed */
354 void flagDirty() 358 void flagDirty()
355 { 359 {
356 setDocStatFlag(DOC_STAT_DISK_DIRTY); 360 setDocStatFlag(DOC_STAT_DISK_DIRTY);
357 emitDataChanged(this); 361 emitDataChanged(this);
358 } 362 }
359 /** modified? */ 363 /** modified? */
360 bool isDirty() 364 bool isDirty()
361 { return getDocStatFlag(DOC_STAT_DISK_DIRTY); } 365 { return getDocStatFlag(DOC_STAT_DISK_DIRTY); }
362 /** save document to disk */ 366 /** save document to disk */
363 PwMerror saveDoc(char compress, const QString *file = 0); 367 PwMerror saveDoc(char compress, const QString *file = 0);
364 /** read document from file. 368 /** read document from file.
365 * "openLocked is must be set to either of these values: 369 * "openLocked is must be set to either of these values:
366 * 0 == open with all entries unlocked 370 * 0 == open with all entries unlocked
367 * 1 == open with all entries locked 371 * 1 == open with all entries locked
368 * 2 == open deep-locked 372 * 2 == open deep-locked
369 */ 373 */
370 PwMerror openDoc(const QString *file, int openLocked); 374 PwMerror openDoc(const QString *file, int openLocked);
371 /** export document to ascii-textfile */ 375 /** export document to ascii-textfile */
372 PwMerror exportToText(const QString *file); 376 PwMerror exportToText(const QString *file);
373 /** export document to gpasman / kpasman file */ 377 /** export document to gpasman / kpasman file */
374 PwMerror exportToGpasman(const QString *file); 378 PwMerror exportToGpasman(const QString *file);
375 /** import document from ascii-textfile */ 379 /** import document from ascii-textfile */
376 PwMerror importFromText(const QString *file, int format = -1); 380 PwMerror importFromText(const QString *file, int format = -1);
377 /** import document from gpasman / kpasman file */ 381 /** import document from gpasman / kpasman file */
378 PwMerror importFromGpasman(const QString *file); 382 PwMerror importFromGpasman(const QString *file);
379 /** add new entry */ 383 /** add new entry */
380 PwMerror addEntry(const QString &category, PwMDataItem *d, 384 PwMerror addEntry(const QString &category, PwMDataItem *d,
381 bool dontFlagDirty = false, bool updateMeta = true); 385 bool dontFlagDirty = false, bool updateMeta = true);
382 /** add new category. This function doesn't flag the document dirty! */ 386 /** add new category. This function doesn't flag the document dirty! */
383 PwMerror addCategory(const QString &category, unsigned int *categoryIndex, 387 PwMerror addCategory(const QString &category, unsigned int *categoryIndex,
384 bool checkIfExist = true); 388 bool checkIfExist = true);
385 /** rename an existing category */ 389 /** rename an existing category */
386 bool renameCategory(const QString &category, const QString &newName); 390 bool renameCategory(const QString &category, const QString &newName);
387 /** rename an existing category */ 391 /** rename an existing category */
388 bool renameCategory(unsigned int category, const QString &newName, 392 bool renameCategory(unsigned int category, const QString &newName,
389 bool dontFlagDirty = false); 393 bool dontFlagDirty = false);
390 /** delete an existing category */ 394 /** delete an existing category */
391 bool delCategory(const QString &category); 395 bool delCategory(const QString &category);
392 /** delete an existing category */ 396 /** delete an existing category */
393 bool delCategory(unsigned int category, bool dontFlagDirty = false); 397 bool delCategory(unsigned int category, bool dontFlagDirty = false);
394 /** returns a list of all category-names */ 398 /** returns a list of all category-names */
395 void getCategoryList(vector<string> *list); 399 void getCategoryList(vector<string> *list);
396 /** returns a list of all category-names */ 400 /** returns a list of all category-names */
397 void getCategoryList(QStringList *list); 401 void getCategoryList(QStringList *list);
398 /** returns a list of all entry-descs in the given category */ 402 /** returns a list of all entry-descs in the given category */
399 void getEntryList(const QString &category, QStringList *list); 403 void getEntryList(const QString &category, QStringList *list);
400 /** returns a list of all entry-descs in the given category */ 404 /** returns a list of all entry-descs in the given category */
401 void getEntryList(const QString &category, vector<string> *list); 405 void getEntryList(const QString &category, vector<string> *list);
402 /** returns a list of all entry-descs in the given category */ 406 /** returns a list of all entry-descs in the given category */
403 void getEntryList(unsigned int category, vector<string> *list); 407 void getEntryList(unsigned int category, vector<string> *list);
404 /** returns a list of all entry-descs in the given category */ 408 /** returns a list of all entry-descs in the given category */
405 void getEntryList(unsigned int category, QStringList *list); 409 void getEntryList(unsigned int category, QStringList *list);
406 /** delete entry */ 410 /** delete entry */
407 bool delEntry(const QString &category, unsigned int index, bool dontFlagDirty = false); 411 bool delEntry(const QString &category, unsigned int index, bool dontFlagDirty = false);
408 /** delete entry */ 412 /** delete entry */
409 bool delEntry(unsigned int category, unsigned int index, bool dontFlagDirty = false); 413 bool delEntry(unsigned int category, unsigned int index, bool dontFlagDirty = false);
410 /** edit entry */ 414 /** edit entry */
411 bool editEntry(const QString &oldCategory, const QString &newCategory, 415 bool editEntry(const QString &oldCategory, const QString &newCategory,
412 unsigned int index, PwMDataItem *d, bool updateMeta = true); 416 unsigned int index, PwMDataItem *d, bool updateMeta = true);
413 /** edit entry */ 417 /** edit entry */
414 bool editEntry(unsigned int oldCategory, const QString &newCategory, 418 bool editEntry(unsigned int oldCategory, const QString &newCategory,
415 unsigned int index, PwMDataItem *d, bool updateMeta = true); 419 unsigned int index, PwMDataItem *d, bool updateMeta = true);
416 /** finds the category with the "name" and return it's index */ 420 /** finds the category with the "name" and return it's index */
417 bool findCategory(const QString &name, unsigned int *index); 421 bool findCategory(const QString &name, unsigned int *index);
418 /** search for an entry "find" and check while searching only for 422 /** search for an entry "find" and check while searching only for
419 * the data-fields specified by "searchIn". To set the "searchIn" 423 * the data-fields specified by "searchIn". To set the "searchIn"
420 * value, we may use one or more of the SEARCH_IN_* defines at 424 * value, we may use one or more of the SEARCH_IN_* defines at
421 * the top of this header-file. It returns the positions of all 425 * the top of this header-file. It returns the positions of all
422 * matched entries in "foundPositions". If "breakAfterFound" is true, 426 * matched entries in "foundPositions". If "breakAfterFound" is true,
423 * the function terminates after the first occurence of the entry 427 * the function terminates after the first occurence of the entry
424 * and doesn't go on searching. So foundPositions->size() is never 428 * and doesn't go on searching. So foundPositions->size() is never
425 * > 1 if breakAfterFound is true. 429 * > 1 if breakAfterFound is true.
426 */ 430 */
427 void findEntry(unsigned int category, PwMDataItem find, unsigned int searchIn, 431 void findEntry(unsigned int category, PwMDataItem find, unsigned int searchIn,
428 vector<unsigned int> *foundPositions, bool breakAfterFound = false, 432 vector<unsigned int> *foundPositions, bool breakAfterFound = false,
429 bool caseSensitive = true, bool exactWordMatch = true, 433 bool caseSensitive = true, bool exactWordMatch = true,
430 bool sortByLvp = false); 434 bool sortByLvp = false);
431 /** see the above funtion. This function allows to set the category by name. */ 435 /** see the above funtion. This function allows to set the category by name. */
432 void findEntry(const QString &category, PwMDataItem find, unsigned int searchIn, 436 void findEntry(const QString &category, PwMDataItem find, unsigned int searchIn,
433 vector<unsigned int> *foundPositions, bool breakAfterFound = false, 437 vector<unsigned int> *foundPositions, bool breakAfterFound = false,
434 bool caseSensitive = true, bool exactWordMatch = true, 438 bool caseSensitive = true, bool exactWordMatch = true,
435 bool sortByLvp = false); 439 bool sortByLvp = false);
436 /** returns number of entries */ 440 /** returns number of entries */
437 unsigned int numEntries(const QString &category); 441 unsigned int numEntries(const QString &category);
438 unsigned int numEntries(unsigned int category) 442 unsigned int numEntries(unsigned int category)
439 { return dta[category].d.size(); } 443 { return dta[category].d.size(); }
440 /** returns number of categories */ 444 /** returns number of categories */
441 unsigned int numCategories() 445 unsigned int numCategories()
442 { return dta.size(); } 446 { return dta.size(); }
443 /** returns the name of the category at "index" */ 447 /** returns the name of the category at "index" */
444 const string* getCategory(unsigned int index) 448 const string* getCategory(unsigned int index)
445 { return (&(dta[index].name)); } 449 { return (&(dta[index].name)); }
446 /** returns the data of item at "index". 450 /** returns the data of item at "index".
447 * It unlocks the entry if it's locked and unlockIfLocked is true. 451 * It unlocks the entry if it's locked and unlockIfLocked is true.
448 * If the entry is locked, but unlockIfLocked is false, it'll not return 452 * If the entry is locked, but unlockIfLocked is false, it'll not return
449 * the pw. 453 * the pw.
450 */ 454 */
451 bool getEntry(const QString &category, unsigned int index, 455 bool getEntry(const QString &category, unsigned int index,
452 PwMDataItem *d, bool unlockIfLocked = false); 456 PwMDataItem *d, bool unlockIfLocked = false);
453 bool getEntry(unsigned int category, unsigned int index, 457 bool getEntry(unsigned int category, unsigned int index,
454 PwMDataItem *d, bool unlockIfLocked = false); 458 PwMDataItem *d, bool unlockIfLocked = false);
455 /** returns the comment-string by looking at the category 459 /** returns the comment-string by looking at the category
456 * and the listViewPos 460 * and the listViewPos
457 */ 461 */
458 PwMerror getCommentByLvp(const QString &category, int listViewPos, 462 PwMerror getCommentByLvp(const QString &category, int listViewPos,
459 string *foundComment); 463 string *foundComment);
460 /** checks if a password is already available. (currentPw) */ 464 /** checks if a password is already available. (currentPw) */
461 bool isPwAvailable() 465 bool isPwAvailable()
462 { return (currentPw != ""); } 466 { return (currentPw != ""); }
463 /** un/lock entry at "index". If needed, ask for password. */ 467 /** un/lock entry at "index". If needed, ask for password. */
464 bool lockAt(const QString &category, unsigned int index, 468 bool lockAt(const QString &category, unsigned int index,
465 bool lock = true); 469 bool lock = true);
466 bool lockAt(unsigned int category, unsigned int index, 470 bool lockAt(unsigned int category, unsigned int index,
467 bool lock = true); 471 bool lock = true);
468 /** returns the lock-status at "index" */ 472 /** returns the lock-status at "index" */
469 bool isLocked(const QString &category, unsigned int index); 473 bool isLocked(const QString &category, unsigned int index);
470 bool isLocked(unsigned int category, unsigned int index) 474 bool isLocked(unsigned int category, unsigned int index)
471 { return dta[category].d[index].lockStat; } 475 { return dta[category].d[index].lockStat; }
472 /** returns the deeplock status */ 476 /** returns the deeplock status */
473 bool isDeepLocked() 477 bool isDeepLocked()
474 { return getDocStatFlag(DOC_STAT_DEEPLOCKED); } 478 { return getDocStatFlag(DOC_STAT_DEEPLOCKED); }
475 /** (un)lock all entries */ 479 /** (un)lock all entries */
476 bool lockAll(bool lock); 480 bool lockAll(bool lock);
477 /** unlocks all entries tempoarly. 481 /** unlocks all entries tempoarly.
478 * 1st NOTE: Be very careful with this function! :) 482 * 1st NOTE: Be very careful with this function! :)
479 * 2nd NOTE: After you have called unlockAll_Tempoary(); , 483 * 2nd NOTE: After you have called unlockAll_Tempoary(); ,
480 * please DON'T forget to call unlockAll_Tempoary(true); 484 * please DON'T forget to call unlockAll_Tempoary(true);
481 * _before_ the user (or someone else) is able to change 485 * _before_ the user (or someone else) is able to change
482 * the document! 486 * the document!
483 * 3rd NOTE: Please DON'T change "dta" while the data is tempoary 487 * 3rd NOTE: Please DON'T change "dta" while the data is tempoary
484 * unlocked! This will cause corruption. 488 * unlocked! This will cause corruption.
485 */ 489 */
486 bool unlockAll_tempoary(bool revert = false); 490 bool unlockAll_tempoary(bool revert = false);
487 /** deep-(un)locks the document. 491 /** deep-(un)locks the document.
488 * deep-locking writes all data to the file, deletes all data 492 * deep-locking writes all data to the file, deletes all data
489 * in memory, but doesn't close the document. 493 * in memory, but doesn't close the document.
490 * deep-locking is only available, if the user previously saved 494 * deep-locking is only available, if the user previously saved
491 * the doc to a file (with a password). 495 * the doc to a file (with a password).
492 * If "saveToFile" is false, it does NOT write the data to the file! 496 * If "saveToFile" is false, it does NOT write the data to the file!
493 */ 497 */
494 PwMerror deepLock(bool lock = true, bool saveToFile = true); 498 PwMerror deepLock(bool lock = true, bool saveToFile = true);
495 /** is unlockable without pw? */ 499 /** is unlockable without pw? */
496 bool unlockWoPw() 500 bool unlockWoPw()
497 { return getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); } 501 { return getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); }
498 /** get the "currentPassword" */ 502 /** get the "currentPassword" */
499 const QString& getCurrentPw() 503 const QString& getCurrentPw()
500 { return currentPw; } 504 { return currentPw; }
501 /** open a window and request the user to change the mpw */ 505 /** open a window and request the user to change the mpw */
502 void changeCurrentPw(); 506 void changeCurrentPw();
503 /** set the "listViewPos" variable of "dta" */ 507 /** set the "listViewPos" variable of "dta" */
504 void setListViewPos(const QString &category, unsigned int index, 508 void setListViewPos(const QString &category, unsigned int index,
505 int pos); 509 int pos);
506 /** set the "listViewPos" variable of "dta" */ 510 /** set the "listViewPos" variable of "dta" */
507 void setListViewPos(unsigned int category, unsigned int index, 511 void setListViewPos(unsigned int category, unsigned int index,
508 int pos); 512 int pos);
509 /** get the "listViewPos" variable of "dta" */ 513 /** get the "listViewPos" variable of "dta" */
510 int getListViewPos(const QString &category, unsigned int index); 514 int getListViewPos(const QString &category, unsigned int index);
511 /** set the maximum number of entries allowed */ 515 /** set the maximum number of entries allowed */
512 void setMaxNumEntries(unsigned int num = DEFAULT_MAX_ENTRIES) 516 void setMaxNumEntries(unsigned int num = DEFAULT_MAX_ENTRIES)
513 { maxEntries = num; } 517 { maxEntries = num; }
514 /** get the maximum number of entries allowed */ 518 /** get the maximum number of entries allowed */
515 unsigned int getMaxNumEntries() 519 unsigned int getMaxNumEntries()
516 { return maxEntries; } 520 { return maxEntries; }
517 /** ensure all listViewPos of all dta items are set. (are ! -1). 521 /** ensure all listViewPos of all dta items are set. (are ! -1).
518 * If there are some undefined entries, add them to the end of 522 * If there are some undefined entries, add them to the end of
519 * the listViewPos(itions). */ 523 * the listViewPos(itions). */
520 void ensureLvp(); 524 void ensureLvp();
521 /** execute the "launcher" of this entry */ 525 /** execute the "launcher" of this entry */
522 bool execLauncher(const QString &category, unsigned int entryIndex); 526 bool execLauncher(const QString &category, unsigned int entryIndex);
523 /** see above */ 527 /** see above */
524 bool execLauncher(unsigned int category, unsigned int entryIndex); 528 bool execLauncher(unsigned int category, unsigned int entryIndex);
525 /** open a browser with the URL-section of the given entry */ 529 /** open a browser with the URL-section of the given entry */
526 bool goToURL(const QString &category, unsigned int entryIndex); 530 bool goToURL(const QString &category, unsigned int entryIndex);
527 /** see above */ 531 /** see above */
528 bool goToURL(unsigned int category, unsigned int entryIndex); 532 bool goToURL(unsigned int category, unsigned int entryIndex);
529 /** returns true if there is no entry present in the document. 533 /** returns true if there is no entry present in the document.
530 * Note: The "default" Category is present everytime, so 534 * Note: The "default" Category is present everytime, so
531 * it's checked for it's entries. 535 * it's checked for it's entries.
532 */ 536 */
533 bool isDocEmpty() 537 bool isDocEmpty()
534 { 538 {
535 if (numCategories() > 1) 539 if (numCategories() > 1)
536 return false; 540 return false;
537 if (numEntries(0)) 541 if (numEntries(0))
538 return false; 542 return false;
539 return true; 543 return true;
540 } 544 }
541 /** returns the filename of this doc */ 545 /** returns the filename of this doc */
542 const QString& getFilename() 546 const QString& getFilename()
543 { return filename; } 547 { return filename; }
544 /** returns the title of the doc */ 548 /** returns the title of the doc */
545 QString getTitle(); 549 QString getTitle();
546 /** sets the list-view-pointer hold in the doc */ 550 /** sets the list-view-pointer hold in the doc */
547 void setListViewPointer(PwMView *_listView) 551 void setListViewPointer(PwMView *_listView)
548 { listView = _listView; } 552 { listView = _listView; }
549 /** returns the list-view-pointer */ 553 /** returns the list-view-pointer */
550 PwMView * getListViewPointer() 554 PwMView * getListViewPointer()
551 { return listView; } 555 { return listView; }
552 /** try to delete the doc. The user may be asked to save 556 /** try to delete the doc. The user may be asked to save
553 * the data. The user may cancel the whole operation. 557 * the data. The user may cancel the whole operation.
554 * false is returned, then. 558 * false is returned, then.
555 */ 559 */
556 bool tryDelete(); 560 bool tryDelete();
557 /** is the doc deleted? (with tryDelete() ) */ 561 /** is the doc deleted? (with tryDelete() ) */
558 bool isDeleted() 562 bool isDeleted()
559 { return deleted; } 563 { return deleted; }
560 /** returns the document timer object */ 564 /** returns the document timer object */
561 DocTimer * timer() 565 DocTimer * timer()
562 { return _timer; } 566 { return _timer; }
563 /** get a lock on the dataChanged signal. 567 /** get a lock on the dataChanged signal.
564 * If someone is holding a lock, the signal is not emitted. 568 * If someone is holding a lock, the signal is not emitted.
565 */ 569 */
566 void getDataChangedLock() 570 void getDataChangedLock()
567 { ++dataChangedLock; } 571 { ++dataChangedLock; }
568 /** put the dataChanged lock */ 572 /** put the dataChanged lock */
569 void putDataChangedLock() 573 void putDataChangedLock()
570 { --dataChangedLock; } 574 { --dataChangedLock; }
571 /** returns the revision count of the item at cat/index */ 575 /** returns the revision count of the item at cat/index */
572 unsigned int getEntryRevCnt(unsigned int category, unsigned int index) 576 unsigned int getEntryRevCnt(unsigned int category, unsigned int index)
573 { return dta[category].d[index].rev; } 577 { return dta[category].d[index].rev; }
574 /** returns a const pointer to the entries meta */ 578 /** returns a const pointer to the entries meta */
575 const PwMMetaData * getEntryMeta(unsigned int category, unsigned int index) 579 const PwMMetaData * getEntryMeta(unsigned int category, unsigned int index)
576 { return &(dta[category].d[index].meta); } 580 { return &(dta[category].d[index].meta); }
577 /** is the entry at "category" "index" a binary entry? */ 581 /** is the entry at "category" "index" a binary entry? */
578 bool isBinEntry(unsigned int category, unsigned int index) 582 bool isBinEntry(unsigned int category, unsigned int index)
579 { return dta[category].d[index].binary; } 583 { return dta[category].d[index].binary; }
580 584
581public slots: 585public slots:
582 /** wrapper for PwMTray */ 586 /** wrapper for PwMTray */
583 void _deepUnlock(); 587 void _deepUnlock();
584 588
585signals: 589signals:
586 /** the data of the document has changed and must be updated 590 /** the data of the document has changed and must be updated
587 * in all views. 591 * in all views.
588 * NOTE: use emitDataChanged(PwMDoc *document) to emit this signal! 592 * NOTE: use emitDataChanged(PwMDoc *document) to emit this signal!
589 */ 593 */
590 void dataChanged(PwMDoc *document); 594 void dataChanged(PwMDoc *document);
591 /** the document class is going to close. This signal may be 595 /** the document class is going to close. This signal may be
592 * used to nofify all views, that the user closed the document, 596 * used to nofify all views, that the user closed the document,
593 * so the views can go down, too. 597 * so the views can go down, too.
594 */ 598 */
595 void docClosed(PwMDoc *document); 599 void docClosed(PwMDoc *document);
596 /** somebody just opened the document */ 600 /** somebody just opened the document */
597 void docOpened(PwMDoc *document); 601 void docOpened(PwMDoc *document);
598 /** this document object just got created */ 602 /** this document object just got created */
599 void docCreated(PwMDoc *document); 603 void docCreated(PwMDoc *document);
600 604
601public: 605public:
602 /** emit the dataChanged signal after checking for a lock */ 606 /** emit the dataChanged signal after checking for a lock */
603 void emitDataChanged(PwMDoc *document) 607 void emitDataChanged(PwMDoc *document)
604 { 608 {
605 if (!dataChangedLock) 609 if (!dataChangedLock)
606 emit dataChanged(document); 610 emit dataChanged(document);
607 } 611 }
608 612
609protected: 613protected:
610 /** current file for this doc */ 614 /** current file for this doc */
611 QString filename; 615 QString filename;
612 /** holds all data */ 616 /** holds all data */
613 vector<PwMCategoryItem> dta; 617 vector<PwMCategoryItem> dta;
614 /** maximum number of entries */ 618 /** maximum number of entries */
615 unsigned int maxEntries; 619 unsigned int maxEntries;
616 /** currently used password to encrypt data */ 620 /** currently used password to encrypt data */
617 QString currentPw; 621 QString currentPw;
618 /** current global document status flags */ 622 /** current global document status flags */
619 unsigned int curDocStat; 623 unsigned int curDocStat;
620 /** browser process for goToURL() */ 624 /** browser process for goToURL() */
621 KProcess browserProc; 625 KProcess browserProc;
622 /** pointer to the list-view, using this document. 626 /** pointer to the list-view, using this document.
623 * As there can only be one list-view per doc, we 627 * As there can only be one list-view per doc, we
624 * don't need a list here. 628 * don't need a list here.
625 */ 629 */
626 PwMView *listView; 630 PwMView *listView;
627 /** unnamedNum is used to store the "unnamed counter" 631 /** unnamedNum is used to store the "unnamed counter"
628 * for this document, while it's unnamed. If it's 0, 632 * for this document, while it's unnamed. If it's 0,
629 * we have to get a new unique one. 633 * we have to get a new unique one.
630 */ 634 */
631 unsigned int unnamedNum; 635 unsigned int unnamedNum;
632 /** is this doc going to be deleted (executing in destructor context) */ 636 /** is this doc going to be deleted (executing in destructor context) */
633 bool deleted; 637 bool deleted;
634 /** document timer */ 638 /** document timer */
635 DocTimer *_timer; 639 DocTimer *_timer;
636 /** lock counter for the "dataChanged" signal */ 640 /** lock counter for the "dataChanged" signal */
637 unsigned int dataChangedLock; 641 unsigned int dataChangedLock;
638 642
639 /** list of all open documents */ 643 /** list of all open documents */
640 static PwMDocList openDocList; 644 static PwMDocList openDocList;
641 645
642protected: 646protected:
643 /** serialize "dta" and return it in "d". */ 647 /** serialize "dta" and return it in "d". */
644 bool serializeDta(string *d); 648 bool serializeDta(string *d);
645 /** de-serialize "d" and overwrite "dta" */ 649 /** de-serialize "d" and overwrite "dta" */
646 bool deSerializeDta(const string *d, bool entriesLocked); 650 bool deSerializeDta(const string *d, bool entriesLocked);
647 /** write header to file */ 651 /** write header to file */
648 PwMerror writeFileHeader(char keyHash, char dataHash, char crypt, char compress, 652 PwMerror writeFileHeader(char keyHash, char dataHash, char crypt, char compress,
649 QString *pw, QFile *f); 653 QString *pw, QFile *f);
650 /** write data-hash to file */ 654 /** write data-hash to file */
651 PwMerror writeDataHash(char dataHash, string *d, QFile *f); 655 PwMerror writeDataHash(char dataHash, string *d, QFile *f);
652 /** check header. Read header info and verify key-hash and filever. 656 /** check header. Read header info and verify key-hash and filever.
653 * returns length of header in "headerLength" */ 657 * returns length of header in "headerLength" */
654 PwMerror checkHeader(char *cryptAlgo, QString *pw, char *compress, 658 PwMerror checkHeader(char *cryptAlgo, QString *pw, char *compress,
655 unsigned int *headerLength, char *dataHashType, 659 unsigned int *headerLength, char *dataHashType,
656 string *dataHash, QFile *f); 660 string *dataHash, QFile *f);
657 /** check the data-hash */ 661 /** check the data-hash */
658 PwMerror checkDataHash(char dataHashType, const string *dataHash, const string *dataStream); 662 PwMerror checkDataHash(char dataHashType, const string *dataHash, const string *dataStream);
659 /** encrypt data "d" and write to "filename" */ 663 /** encrypt data "d" and write to "filename" */
660 PwMerror encrypt(string *d, const QString *pw, QFile *f, char algo); 664 PwMerror encrypt(string *d, const QString *pw, QFile *f, char algo);
661 /** read data from file beginning at "pos", decrypt and return it */ 665 /** read data from file beginning at "pos", decrypt and return it */
662 PwMerror decrypt(string *d, unsigned int pos, const QString *pw, char algo, QFile *f); 666 PwMerror decrypt(string *d, unsigned int pos, const QString *pw, char algo, QFile *f);
663 /** compress the data */ 667 /** compress the data */
664 bool compressDta(string *d, char algo); 668 bool compressDta(string *d, char algo);
665 /** uncompress the data */ 669 /** uncompress the data */
666 bool decompressDta(string *d, char algo); 670 bool decompressDta(string *d, char algo);
667 /** internal import function for a text-file generated by PwM. 671 /** internal import function for a text-file generated by PwM.
668 * If this is not a valid PwM-exported file, it returns e_fileFormat */ 672 * If this is not a valid PwM-exported file, it returns e_fileFormat */
669 PwMerror importText_PwM(const QString *file); 673 PwMerror importText_PwM(const QString *file);
670 /** PwM-text-import helper function to extract the name/pw/comment out 674 /** PwM-text-import helper function to extract the name/pw/comment out
671 * of one entry-line */ 675 * of one entry-line */
672 bool textExtractEntry_PwM(const char *in, ssize_t in_size, string *out); 676 bool textExtractEntry_PwM(const char *in, ssize_t in_size, string *out);
673 /** compare two strings */ 677 /** compare two strings */
674 bool compareString(const string &s1, const string &s2, bool caseSensitive, 678 bool compareString(const string &s1, const string &s2, bool caseSensitive,
675 bool exactWordMatch); 679 bool exactWordMatch);
676 /** clears all document-data */ 680 /** clears all document-data */
677 void clearDoc(); 681 void clearDoc();
678 /** delete all empty categories */ 682 /** delete all empty categories */
679 void delAllEmptyCat(bool dontFlagDirty); 683 void delAllEmptyCat(bool dontFlagDirty);
680 /** set a document status flag */ 684 /** set a document status flag */
681 void setDocStatFlag(unsigned int statFlag) 685 void setDocStatFlag(unsigned int statFlag)
682 { curDocStat |= statFlag; } 686 { curDocStat |= statFlag; }
683 /** unset a document status flag */ 687 /** unset a document status flag */
684 void unsetDocStatFlag(unsigned int statFlag) 688 void unsetDocStatFlag(unsigned int statFlag)
685 { curDocStat &= ~statFlag; } 689 { curDocStat &= ~statFlag; }
686 /** get a document status flag */ 690 /** get a document status flag */
687 bool getDocStatFlag(unsigned int statFlag) const 691 bool getDocStatFlag(unsigned int statFlag) const
688 { return (curDocStat & statFlag); } 692 { return (curDocStat & statFlag); }
689 /** set the "currentPassword" */ 693 /** set the "currentPassword" */
690 void setCurrentPw(const QString &pw) 694 void setCurrentPw(const QString &pw)
691 { 695 {
692 currentPw = pw; 696 currentPw = pw;
693 setDocStatFlag(DOC_STAT_DISK_DIRTY); 697 setDocStatFlag(DOC_STAT_DISK_DIRTY);
694 } 698 }
695 /** make a backup-copy of the given file */ 699 /** make a backup-copy of the given file */
696 bool backupFile(const QString &filePath); 700 bool backupFile(const QString &filePath);
697 /** copy a file from src to dst */ 701 /** copy a file from src to dst */
698 bool copyFile(const QString &src, const QString &dst); 702 bool copyFile(const QString &src, const QString &dst);
703
704
705 public:
706#ifdef PWM_EMBEDDED
707 //US ENH: this is the magic function that syncronizes the local doc with the remote doc.
708 PwMerror syncronize(KSyncManager* manager, PwMDoc* syncLocal, PwMDoc* syncRemote, int mode );
709
710
711 //the following methods are the overwritten callbackmethods from the syncinterface
712 virtual bool sync(KSyncManager* manager, QString filename, int mode);
713
714 //called by the syncmanager to indicate that the work has to be marked as dirty.
715 virtual void sync_setModified();
716 //called by the syncmanager to ask if the dirty flag is set.
717 virtual bool sync_isModified();
718 //called by the syncmanager to indicate that the work has to be saved.
719 virtual void sync_save();
720#endif
721
699}; 722};
700 723
701#endif 724#endif