author | zautrix <zautrix> | 2005-11-28 05:53:55 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-11-28 05:53:55 (UTC) |
commit | 29c3ed5181b8a33aac73eec90956819b71641048 (patch) (unidiff) | |
tree | 8733a18a337b28545ccda5e178cab1b1977314d5 | |
parent | c09ac6c4c77ee1ed50cd9d86a6798eebdede3991 (diff) | |
download | kdepimpi-29c3ed5181b8a33aac73eec90956819b71641048.zip kdepimpi-29c3ed5181b8a33aac73eec90956819b71641048.tar.gz kdepimpi-29c3ed5181b8a33aac73eec90956819b71641048.tar.bz2 |
sync
-rw-r--r-- | pwmanager/pwmanager/pwm.cpp | 4 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwm.h | 2 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.cpp | 2 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.h | 2 |
4 files changed, 5 insertions, 5 deletions
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp index e12dc49..8373850 100644 --- a/pwmanager/pwmanager/pwm.cpp +++ b/pwmanager/pwmanager/pwm.cpp | |||
@@ -1056,544 +1056,544 @@ bool PwM::importFromText() | |||
1056 | i18n("import failed")); | 1056 | i18n("import failed")); |
1057 | goto cancelImport; | 1057 | goto cancelImport; |
1058 | } | 1058 | } |
1059 | setVirgin(false); | 1059 | setVirgin(false); |
1060 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1060 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1061 | return true; | 1061 | return true; |
1062 | 1062 | ||
1063 | cancelImport: | 1063 | cancelImport: |
1064 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1064 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1065 | return false; | 1065 | return false; |
1066 | } | 1066 | } |
1067 | 1067 | ||
1068 | void PwM::exportToGpasman() | 1068 | void PwM::exportToGpasman() |
1069 | { | 1069 | { |
1070 | PWM_ASSERT(curDoc()); | 1070 | PWM_ASSERT(curDoc()); |
1071 | if (curDoc()->isDocEmpty()) { | 1071 | if (curDoc()->isDocEmpty()) { |
1072 | KMessageBox::information(this, | 1072 | KMessageBox::information(this, |
1073 | i18n | 1073 | i18n |
1074 | ("Sorry, there's nothing to export.\n" | 1074 | ("Sorry, there's nothing to export.\n" |
1075 | "Please first add some passwords."), | 1075 | "Please first add some passwords."), |
1076 | i18n("nothing to do")); | 1076 | i18n("nothing to do")); |
1077 | return; | 1077 | return; |
1078 | } | 1078 | } |
1079 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1079 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1080 | QString fn(KFileDialog::getSaveFileName(QString::null, | 1080 | QString fn(KFileDialog::getSaveFileName(QString::null, |
1081 | i18n("*|Gpasman or Kpasman file"), | 1081 | i18n("*|Gpasman or Kpasman file"), |
1082 | this)); | 1082 | this)); |
1083 | if (fn == "") { | 1083 | if (fn == "") { |
1084 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1084 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1085 | return; | 1085 | return; |
1086 | } | 1086 | } |
1087 | 1087 | ||
1088 | PwMerror ret = curDoc()->exportToGpasman(&fn); | 1088 | PwMerror ret = curDoc()->exportToGpasman(&fn); |
1089 | if (ret != e_success) { | 1089 | if (ret != e_success) { |
1090 | if (ret == e_noPw) { | 1090 | if (ret == e_noPw) { |
1091 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1091 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1092 | return; | 1092 | return; |
1093 | } | 1093 | } |
1094 | KMessageBox::error(this, | 1094 | KMessageBox::error(this, |
1095 | i18n("Error: Couldn't write to file.\n" | 1095 | i18n("Error: Couldn't write to file.\n" |
1096 | "Please check if you have permission to write " | 1096 | "Please check if you have permission to write " |
1097 | "to the file in that directory."), | 1097 | "to the file in that directory."), |
1098 | i18n("error while writing")); | 1098 | i18n("error while writing")); |
1099 | } else | 1099 | } else |
1100 | showStatMsg(i18n("Successfully exported data.")); | 1100 | showStatMsg(i18n("Successfully exported data.")); |
1101 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1101 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1102 | } | 1102 | } |
1103 | 1103 | ||
1104 | 1104 | ||
1105 | 1105 | ||
1106 | void PwM::exportToCsv() | 1106 | void PwM::exportToCsv() |
1107 | { | 1107 | { |
1108 | PWM_ASSERT(curDoc()); | 1108 | PWM_ASSERT(curDoc()); |
1109 | if (curDoc()->isDocEmpty()) { | 1109 | if (curDoc()->isDocEmpty()) { |
1110 | KMessageBox::information(this, | 1110 | KMessageBox::information(this, |
1111 | i18n | 1111 | i18n |
1112 | ("Sorry, there is nothing to export;\n" | 1112 | ("Sorry, there is nothing to export;\n" |
1113 | "please add some passwords first."), | 1113 | "please add some passwords first."), |
1114 | i18n("Nothing to Do")); | 1114 | i18n("Nothing to Do")); |
1115 | return; | 1115 | return; |
1116 | } | 1116 | } |
1117 | 1117 | ||
1118 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1118 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1119 | QString fn(KFileDialog::getSaveFileName("*.csv", i18n("*|CSV Text File"), this)); | 1119 | QString fn(KFileDialog::getSaveFileName("*.csv", i18n("*|CSV Text File"), this)); |
1120 | if (fn.isEmpty()) { | 1120 | if (fn.isEmpty()) { |
1121 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1121 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1122 | return; | 1122 | return; |
1123 | } | 1123 | } |
1124 | 1124 | ||
1125 | Csv csv(this); | 1125 | Csv csv(this); |
1126 | if (!csv.exportData(fn, curDoc())) { | 1126 | if (!csv.exportData(fn, curDoc())) { |
1127 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1127 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1128 | showStatMsg(i18n("CSV file export failed.")); | 1128 | showStatMsg(i18n("CSV file export failed.")); |
1129 | return; | 1129 | return; |
1130 | } | 1130 | } |
1131 | showStatMsg(i18n("Successfully exported data.")); | 1131 | showStatMsg(i18n("Successfully exported data.")); |
1132 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1132 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1133 | } | 1133 | } |
1134 | 1134 | ||
1135 | bool PwM::importCsv() | 1135 | bool PwM::importCsv() |
1136 | { | 1136 | { |
1137 | Csv csv(this); | 1137 | Csv csv(this); |
1138 | if (!isVirgin()) { | 1138 | if (!isVirgin()) { |
1139 | if (KMessageBox::questionYesNo(this, | 1139 | if (KMessageBox::questionYesNo(this, |
1140 | i18n("Do you want to import the data\n" | 1140 | i18n("Do you want to import the data\n" |
1141 | "into the current document? (If you\n" | 1141 | "into the current document? (If you\n" |
1142 | "select \"no\", a new document will be\n" | 1142 | "select \"no\", a new document will be\n" |
1143 | "opened.)"), | 1143 | "opened.)"), |
1144 | i18n("Import into This Document?")) | 1144 | i18n("Import into This Document?")) |
1145 | == KMessageBox::No) { | 1145 | == KMessageBox::No) { |
1146 | // import the data to a new window. | 1146 | // import the data to a new window. |
1147 | PwM *newInstance = init->createMainWnd(); | 1147 | PwM *newInstance = init->createMainWnd(); |
1148 | bool ok = newInstance->importCsv(); | 1148 | bool ok = newInstance->importCsv(); |
1149 | if (!ok) { | 1149 | if (!ok) { |
1150 | newInstance->setForceQuit(true); | 1150 | newInstance->setForceQuit(true); |
1151 | delete_and_null(newInstance); | 1151 | delete_and_null(newInstance); |
1152 | } | 1152 | } |
1153 | return ok; | 1153 | return ok; |
1154 | } | 1154 | } |
1155 | } | 1155 | } |
1156 | 1156 | ||
1157 | QString filename = KFileDialog::getOpenFileName("*.csv", i18n("*|CSV Text File"), this); | 1157 | QString filename = KFileDialog::getOpenFileName("*.csv", i18n("*|CSV Text File"), this); |
1158 | if (filename.isEmpty()) | 1158 | if (filename.isEmpty()) |
1159 | return false; | 1159 | return false; |
1160 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1160 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1161 | if (!csv.importData(filename, curDoc())) { | 1161 | if (!csv.importData(filename, curDoc())) { |
1162 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1162 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1163 | showStatMsg(i18n("CSV file import failed.")); | 1163 | showStatMsg(i18n("CSV file import failed.")); |
1164 | return false; | 1164 | return false; |
1165 | } | 1165 | } |
1166 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1166 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1167 | KMessageBox::information(this, | 1167 | KMessageBox::information(this, |
1168 | i18n("Successfully imported the CSV data\n" | 1168 | i18n("Successfully imported the CSV data\n" |
1169 | "into the current document."), i18n("Successfully Imported")); | 1169 | "into the current document."), i18n("Successfully Imported")); |
1170 | showStatMsg(i18n("Successfully imported")); | 1170 | showStatMsg(i18n("Successfully imported")); |
1171 | setVirgin(false); | 1171 | setVirgin(false); |
1172 | return true; | 1172 | return true; |
1173 | } | 1173 | } |
1174 | 1174 | ||
1175 | 1175 | ||
1176 | void PwM::exportToKWallet() | 1176 | void PwM::exportToKWallet() |
1177 | { | 1177 | { |
1178 | #ifdef CONFIG_KWALLETIF | 1178 | #ifdef CONFIG_KWALLETIF |
1179 | if (!checkAndAskForKWalletEmu()) | 1179 | if (!checkAndAskForKWalletEmu()) |
1180 | return; | 1180 | return; |
1181 | PWM_ASSERT(curDoc()); | 1181 | PWM_ASSERT(curDoc()); |
1182 | if (curDoc()->isDocEmpty()) { | 1182 | if (curDoc()->isDocEmpty()) { |
1183 | KMessageBox::information(this, | 1183 | KMessageBox::information(this, |
1184 | i18n | 1184 | i18n |
1185 | ("Sorry, there's nothing to export.\n" | 1185 | ("Sorry, there's nothing to export.\n" |
1186 | "Please first add some passwords."), | 1186 | "Please first add some passwords."), |
1187 | i18n("nothing to do")); | 1187 | i18n("nothing to do")); |
1188 | init->initKWalletEmu(); | 1188 | init->initKWalletEmu(); |
1189 | return; | 1189 | return; |
1190 | } | 1190 | } |
1191 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1191 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1192 | KWalletIf walletIf(this); | 1192 | KWalletIf walletIf(this); |
1193 | if (walletIf.kwalletExport(curDoc())) { | 1193 | if (walletIf.kwalletExport(curDoc())) { |
1194 | KMessageBox::information(this, | 1194 | KMessageBox::information(this, |
1195 | i18n("Successfully exported the data of the current " | 1195 | i18n("Successfully exported the data of the current " |
1196 | "document to KWallet."), | 1196 | "document to KWallet."), |
1197 | i18n("Successfully exported data.")); | 1197 | i18n("Successfully exported data.")); |
1198 | showStatMsg(i18n("Successfully exported data.")); | 1198 | showStatMsg(i18n("Successfully exported data.")); |
1199 | } | 1199 | } |
1200 | init->initKWalletEmu(); | 1200 | init->initKWalletEmu(); |
1201 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1201 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1202 | #endif // CONFIG_KWALLETIF | 1202 | #endif // CONFIG_KWALLETIF |
1203 | } | 1203 | } |
1204 | 1204 | ||
1205 | bool PwM::importFromGpasman() | 1205 | bool PwM::importFromGpasman() |
1206 | { | 1206 | { |
1207 | if (!isVirgin()) { | 1207 | if (!isVirgin()) { |
1208 | if (KMessageBox::questionYesNo(this, | 1208 | if (KMessageBox::questionYesNo(this, |
1209 | i18n("Do you want to import the data\n" | 1209 | i18n("Do you want to import the data\n" |
1210 | "into the current document? (If you\n" | 1210 | "into the current document? (If you\n" |
1211 | "select \"no\", a new document will be\n" | 1211 | "select \"no\", a new document will be\n" |
1212 | "opened.)"), | 1212 | "opened.)"), |
1213 | i18n("import into this document?")) | 1213 | i18n("import into this document?")) |
1214 | == KMessageBox::No) { | 1214 | == KMessageBox::No) { |
1215 | // import the data to a new window. | 1215 | // import the data to a new window. |
1216 | PwM *newInstance = init->createMainWnd(); | 1216 | PwM *newInstance = init->createMainWnd(); |
1217 | bool ok = newInstance->importFromGpasman(); | 1217 | bool ok = newInstance->importFromGpasman(); |
1218 | if (!ok) { | 1218 | if (!ok) { |
1219 | newInstance->setForceQuit(true); | 1219 | newInstance->setForceQuit(true); |
1220 | delete_and_null(newInstance); | 1220 | delete_and_null(newInstance); |
1221 | } | 1221 | } |
1222 | return ok; | 1222 | return ok; |
1223 | } | 1223 | } |
1224 | } | 1224 | } |
1225 | 1225 | ||
1226 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1226 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1227 | PwMerror ret; | 1227 | PwMerror ret; |
1228 | QString path(KFileDialog::getOpenFileName(QString::null, | 1228 | QString path(KFileDialog::getOpenFileName(QString::null, |
1229 | i18n("*|Gpasman or Kpasman file"), this)); | 1229 | i18n("*|Gpasman or Kpasman file"), this)); |
1230 | if (path == "") | 1230 | if (path == "") |
1231 | goto cancelImport; | 1231 | goto cancelImport; |
1232 | ret = curDoc()->importFromGpasman(&path); | 1232 | ret = curDoc()->importFromGpasman(&path); |
1233 | if (ret == e_wrongPw) { | 1233 | if (ret == e_wrongPw) { |
1234 | if (KMessageBox::questionYesNo(this, | 1234 | if (KMessageBox::questionYesNo(this, |
1235 | i18n | 1235 | i18n |
1236 | ("This is probably the wrong master-password\n" | 1236 | ("This is probably the wrong master-password\n" |
1237 | "you have typed in.\n" | 1237 | "you have typed in.\n" |
1238 | "There is no real way to determine the\n" | 1238 | "There is no real way to determine the\n" |
1239 | "correctness of the password in the Gpasman\n" | 1239 | "correctness of the password in the Gpasman\n" |
1240 | "file-format. But I think this\n" | 1240 | "file-format. But I think this\n" |
1241 | "password ist wrong.\n" | 1241 | "password ist wrong.\n" |
1242 | "Do you want to continue nevertheless?"), | 1242 | "Do you want to continue nevertheless?"), |
1243 | i18n("password error")) | 1243 | i18n("password error")) |
1244 | == KMessageBox::No) { | 1244 | == KMessageBox::No) { |
1245 | goto cancelImport; | 1245 | goto cancelImport; |
1246 | } | 1246 | } |
1247 | } else if (ret != e_success) { | 1247 | } else if (ret != e_success) { |
1248 | KMessageBox::error(this, | 1248 | KMessageBox::error(this, |
1249 | i18n("Could not import file!\n" | 1249 | i18n("Could not import file!\n" |
1250 | "Do you have permission to read this file?"), | 1250 | "Do you have permission to read this file?"), |
1251 | i18n("import failed")); | 1251 | i18n("import failed")); |
1252 | goto cancelImport; | 1252 | goto cancelImport; |
1253 | } | 1253 | } |
1254 | setVirgin(false); | 1254 | setVirgin(false); |
1255 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1255 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1256 | return true; | 1256 | return true; |
1257 | 1257 | ||
1258 | cancelImport: | 1258 | cancelImport: |
1259 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1259 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1260 | return false; | 1260 | return false; |
1261 | } | 1261 | } |
1262 | 1262 | ||
1263 | #ifdef CONFIG_KWALLETIF | 1263 | #ifdef CONFIG_KWALLETIF |
1264 | bool PwM::checkAndAskForKWalletEmu() | 1264 | bool PwM::checkAndAskForKWalletEmu() |
1265 | { | 1265 | { |
1266 | if (init->kwalletEmu()) { | 1266 | if (init->kwalletEmu()) { |
1267 | /* KWallet emulation is enabled. We can't import/export | 1267 | /* KWallet emulation is enabled. We can't import/export |
1268 | * data from/to it, while emulation is active. | 1268 | * data from/to it, while emulation is active. |
1269 | */ | 1269 | */ |
1270 | if (KMessageBox::questionYesNo(this, | 1270 | if (KMessageBox::questionYesNo(this, |
1271 | i18n("KWallet emulation is enabled.\n" | 1271 | i18n("KWallet emulation is enabled.\n" |
1272 | "You can't import or export data from/to " | 1272 | "You can't import or export data from/to " |
1273 | "the original KWallet, while the emulation " | 1273 | "the original KWallet, while the emulation " |
1274 | "is active.\n" | 1274 | "is active.\n" |
1275 | "Do you want to tempoarly disable the KWallet emulation?"), | 1275 | "Do you want to tempoarly disable the KWallet emulation?"), |
1276 | i18n("Tempoarly disable KWallet emulation?")) | 1276 | i18n("Tempoarly disable KWallet emulation?")) |
1277 | == KMessageBox::Yes) { | 1277 | == KMessageBox::Yes) { |
1278 | init->initKWalletEmu(true); | 1278 | init->initKWalletEmu(true); |
1279 | PWM_ASSERT(!init->kwalletEmu()); | 1279 | PWM_ASSERT(!init->kwalletEmu()); |
1280 | return true; | 1280 | return true; |
1281 | } | 1281 | } |
1282 | return false; | 1282 | return false; |
1283 | } | 1283 | } |
1284 | return true; | 1284 | return true; |
1285 | } | 1285 | } |
1286 | #endif // CONFIG_KWALLETIF | 1286 | #endif // CONFIG_KWALLETIF |
1287 | 1287 | ||
1288 | bool PwM::importKWallet() | 1288 | bool PwM::importKWallet() |
1289 | { | 1289 | { |
1290 | #ifdef CONFIG_KWALLETIF | 1290 | #ifdef CONFIG_KWALLETIF |
1291 | if (!checkAndAskForKWalletEmu()) | 1291 | if (!checkAndAskForKWalletEmu()) |
1292 | return false; | 1292 | return false; |
1293 | KWalletIf walletIf(this); | 1293 | KWalletIf walletIf(this); |
1294 | if (!isVirgin()) { | 1294 | if (!isVirgin()) { |
1295 | if (KMessageBox::questionYesNo(this, | 1295 | if (KMessageBox::questionYesNo(this, |
1296 | i18n("Do you want to import the data " | 1296 | i18n("Do you want to import the data " |
1297 | "into the current document? (If you " | 1297 | "into the current document? (If you " |
1298 | "select \"no\", a new document will be " | 1298 | "select \"no\", a new document will be " |
1299 | "opened.)"), | 1299 | "opened.)"), |
1300 | i18n("import into this document?")) | 1300 | i18n("import into this document?")) |
1301 | == KMessageBox::No) { | 1301 | == KMessageBox::No) { |
1302 | // import the data to a new window. | 1302 | // import the data to a new window. |
1303 | PwM *newInstance = init->createMainWnd(); | 1303 | PwM *newInstance = init->createMainWnd(); |
1304 | bool ok = newInstance->importKWallet(); | 1304 | bool ok = newInstance->importKWallet(); |
1305 | if (!ok) { | 1305 | if (!ok) { |
1306 | newInstance->setForceQuit(true); | 1306 | newInstance->setForceQuit(true); |
1307 | delete_and_null(newInstance); | 1307 | delete_and_null(newInstance); |
1308 | goto exit_fail; | 1308 | goto exit_fail; |
1309 | } else { | 1309 | } else { |
1310 | goto exit_ok; | 1310 | goto exit_ok; |
1311 | } | 1311 | } |
1312 | } | 1312 | } |
1313 | } | 1313 | } |
1314 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1314 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1315 | if (!walletIf.kwalletImport(curDoc())) { | 1315 | if (!walletIf.kwalletImport(curDoc())) { |
1316 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1316 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1317 | showStatMsg(i18n("KWallet import failed")); | 1317 | showStatMsg(i18n("KWallet import failed")); |
1318 | goto exit_fail; | 1318 | goto exit_fail; |
1319 | } | 1319 | } |
1320 | KMessageBox::information(this, | 1320 | KMessageBox::information(this, |
1321 | i18n("Successfully imported the KWallet data " | 1321 | i18n("Successfully imported the KWallet data " |
1322 | "into the current document."), | 1322 | "into the current document."), |
1323 | i18n("successfully imported")); | 1323 | i18n("successfully imported")); |
1324 | showStatMsg(i18n("successfully imported")); | 1324 | showStatMsg(i18n("successfully imported")); |
1325 | setVirgin(false); | 1325 | setVirgin(false); |
1326 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1326 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1327 | 1327 | ||
1328 | exit_ok: | 1328 | exit_ok: |
1329 | init->initKWalletEmu(); | 1329 | init->initKWalletEmu(); |
1330 | return true; | 1330 | return true; |
1331 | 1331 | ||
1332 | exit_fail: | 1332 | exit_fail: |
1333 | init->initKWalletEmu(); | 1333 | init->initKWalletEmu(); |
1334 | #endif // CONFIG_KWALLETIF | 1334 | #endif // CONFIG_KWALLETIF |
1335 | return false; | 1335 | return false; |
1336 | } | 1336 | } |
1337 | 1337 | ||
1338 | void PwM::print_slot() | 1338 | void PwM::print_slot() |
1339 | { | 1339 | { |
1340 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1340 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1341 | #ifndef PWM_EMBEDDED | 1341 | #ifndef PWM_EMBEDDED |
1342 | PwMPrint p(curDoc(), this); | 1342 | PwMPrint p(curDoc(), this); |
1343 | p.printNow(); | 1343 | p.printNow(); |
1344 | #else | 1344 | #else |
1345 | qDebug("PwM::print_slot , PRINTING IS NOT IMPLEMENTED"); | 1345 | qDebug("PwM::print_slot , PRINTING IS NOT IMPLEMENTED"); |
1346 | #endif | 1346 | #endif |
1347 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1347 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1348 | } | 1348 | } |
1349 | 1349 | ||
1350 | void PwM::genNewCard_slot() | 1350 | void PwM::genNewCard_slot() |
1351 | { | 1351 | { |
1352 | #ifdef CONFIG_KEYCARD | 1352 | #ifdef CONFIG_KEYCARD |
1353 | init->keycard()->genNewCard(); | 1353 | init->keycard()->genNewCard(); |
1354 | #endif | 1354 | #endif |
1355 | } | 1355 | } |
1356 | 1356 | ||
1357 | void PwM::eraseCard_slot() | 1357 | void PwM::eraseCard_slot() |
1358 | { | 1358 | { |
1359 | #ifdef CONFIG_KEYCARD | 1359 | #ifdef CONFIG_KEYCARD |
1360 | init->keycard()->eraseCard(); | 1360 | init->keycard()->eraseCard(); |
1361 | #endif | 1361 | #endif |
1362 | } | 1362 | } |
1363 | 1363 | ||
1364 | void PwM::readCardId_slot() | 1364 | void PwM::readCardId_slot() |
1365 | { | 1365 | { |
1366 | #ifdef CONFIG_KEYCARD | 1366 | #ifdef CONFIG_KEYCARD |
1367 | init->keycard()->displayKey(); | 1367 | init->keycard()->displayKey(); |
1368 | #endif | 1368 | #endif |
1369 | } | 1369 | } |
1370 | 1370 | ||
1371 | void PwM::makeCardBackup_slot() | 1371 | void PwM::makeCardBackup_slot() |
1372 | { | 1372 | { |
1373 | #ifdef CONFIG_KEYCARD | 1373 | #ifdef CONFIG_KEYCARD |
1374 | init->keycard()->makeBackupImage(); | 1374 | init->keycard()->makeBackupImage(); |
1375 | #endif | 1375 | #endif |
1376 | } | 1376 | } |
1377 | 1377 | ||
1378 | void PwM::replayCardBackup_slot() | 1378 | void PwM::replayCardBackup_slot() |
1379 | { | 1379 | { |
1380 | #ifdef CONFIG_KEYCARD | 1380 | #ifdef CONFIG_KEYCARD |
1381 | init->keycard()->replayBackupImage(); | 1381 | init->keycard()->replayBackupImage(); |
1382 | #endif | 1382 | #endif |
1383 | } | 1383 | } |
1384 | 1384 | ||
1385 | void PwM::execLauncher_slot() | 1385 | void PwM::execLauncher_slot() |
1386 | { | 1386 | { |
1387 | PWM_ASSERT(curDoc()); | 1387 | PWM_ASSERT(curDoc()); |
1388 | if (curDoc()->isDeepLocked()) | 1388 | if (curDoc()->isDeepLocked()) |
1389 | return; | 1389 | return; |
1390 | unsigned int curEntryIndex; | 1390 | unsigned int curEntryIndex; |
1391 | if (!view->getCurEntryIndex(&curEntryIndex)) | 1391 | if (!view->getCurEntryIndex(&curEntryIndex)) |
1392 | return; | 1392 | return; |
1393 | bool ret = curDoc()->execLauncher(view->getCurrentCategory(), | 1393 | bool ret = curDoc()->execLauncher(view->getCurrentCategory(), |
1394 | curEntryIndex); | 1394 | curEntryIndex); |
1395 | if (ret) | 1395 | if (ret) |
1396 | showStatMsg(i18n("Executed the \"Launcher\".")); | 1396 | showStatMsg(i18n("Executed the \"Launcher\".")); |
1397 | else | 1397 | else |
1398 | showStatMsg(i18n("ERROR: Couldn't execute the \"Launcher\"!")); | 1398 | showStatMsg(i18n("ERROR: Couldn't execute the \"Launcher\"!")); |
1399 | } | 1399 | } |
1400 | 1400 | ||
1401 | void PwM::goToURL_slot() | 1401 | void PwM::goToURL_slot() |
1402 | { | 1402 | { |
1403 | PWM_ASSERT(curDoc()); | 1403 | PWM_ASSERT(curDoc()); |
1404 | if (curDoc()->isDeepLocked()) | 1404 | if (curDoc()->isDeepLocked()) |
1405 | return; | 1405 | return; |
1406 | unsigned int curEntryIndex; | 1406 | unsigned int curEntryIndex; |
1407 | if (!view->getCurEntryIndex(&curEntryIndex)) | 1407 | if (!view->getCurEntryIndex(&curEntryIndex)) |
1408 | return; | 1408 | return; |
1409 | bool ret = curDoc()->goToURL(view->getCurrentCategory(), | 1409 | bool ret = curDoc()->goToURL(view->getCurrentCategory(), |
1410 | curEntryIndex); | 1410 | curEntryIndex); |
1411 | if (ret) | 1411 | if (ret) |
1412 | showStatMsg(i18n("started browser with current URL.")); | 1412 | showStatMsg(i18n("started browser with current URL.")); |
1413 | else | 1413 | else |
1414 | showStatMsg(i18n("ERROR: Couldn't start browser! Maybe invalid URL?")); | 1414 | showStatMsg(i18n("ERROR: Couldn't start browser! Maybe invalid URL?")); |
1415 | } | 1415 | } |
1416 | 1416 | ||
1417 | void PwM::copyToClipboard(const QString &s) | 1417 | void PwM::copyToClipboard(const QString &s) |
1418 | { | 1418 | { |
1419 | QClipboard *cb = QApplication::clipboard(); | 1419 | QClipboard *cb = QApplication::clipboard(); |
1420 | #ifndef PWM_EMBEDDED | 1420 | #ifndef PWM_EMBEDDED |
1421 | if (cb->supportsSelection()) | 1421 | if (cb->supportsSelection()) |
1422 | cb->setText(s, QClipboard::Selection); | 1422 | cb->setText(s, QClipboard::Selection); |
1423 | cb->setText(s, QClipboard::Clipboard); | 1423 | cb->setText(s, QClipboard::Clipboard); |
1424 | #else | 1424 | #else |
1425 | cb->setText(s); | 1425 | cb->setText(s); |
1426 | 1426 | ||
1427 | #endif | 1427 | #endif |
1428 | 1428 | ||
1429 | } | 1429 | } |
1430 | 1430 | ||
1431 | 1431 | ||
1432 | void PwM::showStatMsg(const QString &msg) | 1432 | void PwM::showStatMsg(const QString &msg) |
1433 | { | 1433 | { |
1434 | #ifdef DESKTOP_VERSION | 1434 | #ifdef DESKTOP_VERSION |
1435 | statusBar()->message(msg, STATUSBAR_MSG_TIMEOUT * 1000); | 1435 | statusBar()->message(msg, STATUSBAR_MSG_TIMEOUT * 1000); |
1436 | #else | 1436 | #else |
1437 | //qDebug("Statusbar : %s",msg.latin1()); | 1437 | //qDebug("Statusbar : %s",msg.latin1()); |
1438 | Global::statusMessage(msg); | 1438 | Global::statusMessage(msg); |
1439 | #endif | 1439 | #endif |
1440 | } | 1440 | } |
1441 | 1441 | ||
1442 | void PwM::focusInEvent(QFocusEvent *e) | 1442 | void PwM::focusInEvent(QFocusEvent *e) |
1443 | { | 1443 | { |
1444 | if (e->gotFocus()) { | 1444 | if (e->gotFocus()) { |
1445 | emit gotFocus(this); | 1445 | emit gotFocus(this); |
1446 | } else if (e->lostFocus()) { | 1446 | } else if (e->lostFocus()) { |
1447 | emit lostFocus(this); | 1447 | emit lostFocus(this); |
1448 | } | 1448 | } |
1449 | } | 1449 | } |
1450 | 1450 | ||
1451 | 1451 | ||
1452 | #ifdef PWM_EMBEDDED | 1452 | #ifdef PWM_EMBEDDED |
1453 | 1453 | ||
1454 | void PwM::category_slot() | 1454 | void PwM::category_slot() |
1455 | { | 1455 | { |
1456 | PwMDoc *doc = curDoc(); | 1456 | PwMDoc *doc = curDoc(); |
1457 | PWM_ASSERT(doc); | 1457 | PWM_ASSERT(doc); |
1458 | doc->timer()->getLock(DocTimer::id_autoLockTimer); | 1458 | doc->timer()->getLock(DocTimer::id_autoLockTimer); |
1459 | 1459 | ||
1460 | editCategoryWnd w(doc, this, "editcategory"); | 1460 | editCategoryWnd w(doc, this, "editcategory"); |
1461 | /* | 1461 | /* |
1462 | vector<string> catList; | 1462 | vector<string> catList; |
1463 | doc->getCategoryList(&catList); | 1463 | doc->getCategoryList(&catList); |
1464 | unsigned i, size = catList.size(); | 1464 | unsigned i, size = catList.size(); |
1465 | for (i = 0; i < size; ++i) { | 1465 | for (i = 0; i < size; ++i) { |
1466 | w.addCategory(catList[i].c_str()); | 1466 | w.addCategory(catList[i].c_str()); |
1467 | } | 1467 | } |
1468 | w.setCurrCategory(view->getCurrentCategory()); | 1468 | w.setCurrCategory(view->getCurrentCategory()); |
1469 | if (pw) | 1469 | if (pw) |
1470 | w.pwLineEdit->setText(*pw); | 1470 | w.pwLineEdit->setText(*pw); |
1471 | */ | 1471 | */ |
1472 | w.setCurrCategory(view->getCurrentCategory()); | 1472 | w.setCurrCategory(view->getCurrentCategory()); |
1473 | 1473 | ||
1474 | tryAgain: | 1474 | tryAgain: |
1475 | if (w.exec() == 1) | 1475 | if (w.exec() == 1) |
1476 | { | 1476 | { |
1477 | PwMDataItem d; | 1477 | PwMDataItem d; |
1478 | 1478 | ||
1479 | //US BUG: to initialize all values of curEntr with meaningfulldata, | 1479 | //US BUG: to initialize all values of curEntr with meaningfulldata, |
1480 | // we call clear on it. Reason: Metadata will be uninitialized otherwise. | 1480 | // we call clear on it. Reason: Metadata will be uninitialized otherwise. |
1481 | // another option would be to create a constructor for PwMDataItem | 1481 | // another option would be to create a constructor for PwMDataItem |
1482 | d.clear(true); | 1482 | d.clear(true); |
1483 | /* | 1483 | /* |
1484 | d.desc = w.getDescription().latin1(); | 1484 | d.desc = w.getDescription().latin1(); |
1485 | d.name = w.getUsername().latin1(); | 1485 | d.name = w.getUsername().latin1(); |
1486 | d.pw = w.getPassword().latin1(); | 1486 | d.pw = w.getPassword().latin1(); |
1487 | d.comment = w.getComment().latin1(); | 1487 | d.comment = w.getComment().latin1(); |
1488 | d.url = w.getUrl().latin1(); | 1488 | d.url = w.getUrl().latin1(); |
1489 | d.launcher = w.getLauncher().latin1(); | 1489 | d.launcher = w.getLauncher().latin1(); |
1490 | PwMerror ret = doc->addEntry(w.getCategory(), &d); | 1490 | PwMerror ret = doc->addEntry(w.getCategory(), &d); |
1491 | if (ret == e_entryExists) { | 1491 | if (ret == e_entryExists) { |
1492 | KMessageBox::error(this, | 1492 | KMessageBox::error(this, |
1493 | i18n | 1493 | i18n |
1494 | ("An entry with this \"Description\",\n" | 1494 | ("An entry with this \"Description\",\n" |
1495 | "does already exist.\n" | 1495 | "does already exist.\n" |
1496 | "Please select another description."), | 1496 | "Please select another description."), |
1497 | i18n("entry already exists.")); | 1497 | i18n("entry already exists.")); |
1498 | goto tryAgain; | 1498 | goto tryAgain; |
1499 | } else if (ret == e_maxAllowedEntr) { | 1499 | } else if (ret == e_maxAllowedEntr) { |
1500 | KMessageBox::error(this, i18n("The maximum possible number of\nentries" | 1500 | KMessageBox::error(this, i18n("The maximum possible number of\nentries" |
1501 | "has been reached.\nYou can't add more entries."), | 1501 | "has been reached.\nYou can't add more entries."), |
1502 | i18n("maximum number of entries")); | 1502 | i18n("maximum number of entries")); |
1503 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 1503 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
1504 | return; | 1504 | return; |
1505 | } | 1505 | } |
1506 | */ | 1506 | */ |
1507 | } | 1507 | } |
1508 | setVirgin(false); | 1508 | setVirgin(false); |
1509 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 1509 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
1510 | } | 1510 | } |
1511 | 1511 | ||
1512 | 1512 | ||
1513 | void PwM::whatsnew_slot() | 1513 | void PwM::whatsnew_slot() |
1514 | { | 1514 | { |
1515 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 1515 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
1516 | } | 1516 | } |
1517 | 1517 | ||
1518 | void PwM::showLicense_slot() | 1518 | void PwM::showLicense_slot() |
1519 | { | 1519 | { |
1520 | KApplication::showLicence(); | 1520 | KApplication::showLicence(); |
1521 | } | 1521 | } |
1522 | 1522 | ||
1523 | void PwM::faq_slot() | 1523 | void PwM::faq_slot() |
1524 | { | 1524 | { |
1525 | KApplication::showFile( "PWM/Pi FAQ", "kdepim/pwmanager/pwmanagerFAQ.txt" ); | 1525 | KApplication::showFile( "PWM/Pi FAQ", "kdepim/pwmanager/pwmanagerFAQ.txt" ); |
1526 | } | 1526 | } |
1527 | 1527 | ||
1528 | void PwM::syncHowTo_slot() | 1528 | void PwM::syncHowTo_slot() |
1529 | { | 1529 | { |
1530 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 1530 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
1531 | } | 1531 | } |
1532 | 1532 | ||
1533 | 1533 | ||
1534 | void PwM::createAboutData_slot() | 1534 | void PwM::createAboutData_slot() |
1535 | { | 1535 | { |
1536 | QString version; | 1536 | QString version; |
1537 | #include <../version> | 1537 | #include <../version> |
1538 | ; | 1538 | ; |
1539 | QMessageBox::about( this, "About PwManager/Pi", | 1539 | QMessageBox::about( this, "About PwManager/Pi", |
1540 | "PwManager/Platform-independent\n" | 1540 | "PwManager/Platform-independent\n" |
1541 | "(PWM/Pi) " +version + " - " + | 1541 | "(PWM/Pi) " +version + " - " + |
1542 | #ifdef DESKTOP_VERSION | 1542 | #ifdef DESKTOP_VERSION |
1543 | "Desktop Edition\n" | 1543 | "Desktop Edition\n" |
1544 | #else | 1544 | #else |
1545 | "PDA-Edition\n" | 1545 | "PDA-Edition\n" |
1546 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 1546 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
1547 | #endif | 1547 | #endif |
1548 | 1548 | ||
1549 | "(c) 2004 Ulf Schenk\n" | 1549 | "(c) 2004 Ulf Schenk\n" |
1550 | "(c) 2004 Lutz Rogowski\n" | 1550 | "(c) 2004 Lutz Rogowski\n" |
1551 | "(c) 1997-2004, The KDE PIM Team\n" | 1551 | "(c) 1997-2004, The KDE PIM Team\n" |
1552 | 1552 | ||
1553 | "(c) Michael Buesch - main programming\nand current maintainer\nmbuesch@freenet.de\n" | 1553 | "(c) Michael Buesch - main programming\nand current maintainer\nmbuesch@freenet.de\n" |
1554 | "Matt Scifo - mscifo@o1.com\n" | 1554 | "Matt Scifo - mscifo@o1.com\n" |
1555 | "Elias Probst - elias.probst@gmx.de\n" | 1555 | "Elias Probst - elias.probst@gmx.de\n" |
1556 | "George Staikos - staikos@kde.org\n" | 1556 | "George Staikos - staikos@kde.org\n" |
1557 | "Matthew Palmer - mjp16@uow.edu.au\n" | 1557 | "Matthew Palmer - mjp16@uow.edu.au\n" |
1558 | "Olivier Sessink - gpasman@nl.linux.org\n" | 1558 | "Olivier Sessink - gpasman@nl.linux.org\n" |
1559 | "The libgcrypt developers -\nBlowfish and SHA1 algorithms\nftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/\n" | 1559 | "The libgcrypt developers -\nBlowfish and SHA1 algorithms\nftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/\n" |
1560 | "Troy Engel - tengel@sonic.net\n" | 1560 | "Troy Engel - tengel@sonic.net\n" |
1561 | "Wickey - wickey@gmx.at\n" | 1561 | "Wickey - wickey@gmx.at\n" |
1562 | "Ian MacGregor - original documentation author.\n" | 1562 | "Ian MacGregor - original documentation author.\n" |
1563 | ); | 1563 | ); |
1564 | } | 1564 | } |
1565 | 1565 | ||
1566 | 1566 | ||
1567 | //this are the overwritten callbackmethods from the syncinterface | 1567 | //this are the overwritten callbackmethods from the syncinterface |
1568 | bool PwM::sync(KSyncManager* manager, QString filename, int mode) | 1568 | bool PwM::sync(KSyncManager* manager, QString filename, int mode,QString resource) |
1569 | { | 1569 | { |
1570 | PWM_ASSERT(curDoc()); | 1570 | PWM_ASSERT(curDoc()); |
1571 | 1571 | ||
1572 | bool ret = curDoc()->sync(manager, filename, mode); | 1572 | bool ret = curDoc()->sync(manager, filename, mode,resource); |
1573 | 1573 | ||
1574 | qDebug("PwM::sync save now: ret=%i", ret); | 1574 | qDebug("PwM::sync save now: ret=%i", ret); |
1575 | 1575 | ||
1576 | if (ret == true) { | 1576 | if (ret == true) { |
1577 | //US BUG: what can we call here to update the view of the current doc? | 1577 | //US BUG: what can we call here to update the view of the current doc? |
1578 | //mViewManager->refreshView(); | 1578 | //mViewManager->refreshView(); |
1579 | 1579 | ||
1580 | //US curDoc()->sync sets the dirtyFlag in case the sync was successfull. | 1580 | //US curDoc()->sync sets the dirtyFlag in case the sync was successfull. |
1581 | save(); | 1581 | save(); |
1582 | } | 1582 | } |
1583 | 1583 | ||
1584 | return ret; | 1584 | return ret; |
1585 | } | 1585 | } |
1586 | 1586 | ||
1587 | void PwM::removeSyncInfo( QString syncProfile) | 1587 | void PwM::removeSyncInfo( QString syncProfile) |
1588 | { | 1588 | { |
1589 | qDebug("PWM:removeSyncInfo for profile %s ", syncProfile.latin1()); | 1589 | qDebug("PWM:removeSyncInfo for profile %s ", syncProfile.latin1()); |
1590 | curDoc()->removeSyncInfo( syncProfile ); | 1590 | curDoc()->removeSyncInfo( syncProfile ); |
1591 | //US curDoc()->removeSyncInfo sets the dirtyFlag. | 1591 | //US curDoc()->removeSyncInfo sets the dirtyFlag. |
1592 | } | 1592 | } |
1593 | 1593 | ||
1594 | #endif | 1594 | #endif |
1595 | 1595 | ||
1596 | 1596 | ||
1597 | #ifndef PWM_EMBEDDED | 1597 | #ifndef PWM_EMBEDDED |
1598 | #include "pwm.moc" | 1598 | #include "pwm.moc" |
1599 | #endif | 1599 | #endif |
diff --git a/pwmanager/pwmanager/pwm.h b/pwmanager/pwmanager/pwm.h index 2d1b854..c4bbb4e 100644 --- a/pwmanager/pwmanager/pwm.h +++ b/pwmanager/pwmanager/pwm.h | |||
@@ -1,300 +1,300 @@ | |||
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 1.0.1 of pwmanager | 14 | * This file is originaly based on version 1.0.1 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 __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 | ||
48 | class PwMInit; | 48 | class PwMInit; |
49 | class KSyncManager; | 49 | class 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 |
54 | class PwM : public KMainWindow | 54 | class PwM : public KMainWindow |
55 | //MOC_SKIP_END | 55 | //MOC_SKIP_END |
56 | #else | 56 | #else |
57 | class PwM : public KMainWindow, public KSyncInterface | 57 | class PwM : public KMainWindow, public KSyncInterface |
58 | #endif | 58 | #endif |
59 | { | 59 | { |
60 | Q_OBJECT | 60 | Q_OBJECT |
61 | public: | 61 | public: |
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 | ||
106 | public slots: | 106 | public 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/export/csv triggered */ | 127 | /** file/export/csv triggered */ |
128 | void exportToCsv(); | 128 | void exportToCsv(); |
129 | /** file/import/text triggered */ | 129 | /** file/import/text triggered */ |
130 | bool importFromText(); | 130 | bool importFromText(); |
131 | /** file/import/gpasman triggered */ | 131 | /** file/import/gpasman triggered */ |
132 | bool importFromGpasman(); | 132 | bool importFromGpasman(); |
133 | /** file/import/kwallet triggered */ | 133 | /** file/import/kwallet triggered */ |
134 | bool importKWallet(); | 134 | bool importKWallet(); |
135 | /** file/import/csv triggered */ | 135 | /** file/import/csv triggered */ |
136 | bool importCsv(); | 136 | bool importCsv(); |
137 | /** file/print triggered */ | 137 | /** file/print triggered */ |
138 | void print_slot(); | 138 | void print_slot(); |
139 | /** manage/add triggered */ | 139 | /** manage/add triggered */ |
140 | //US ENH : changed code to run with older MOC | 140 | //US ENH : changed code to run with older MOC |
141 | 141 | ||
142 | void addPwd_slot(); | 142 | void addPwd_slot(); |
143 | void addPwd_slot1(QString *pw, PwMDoc *_doc); | 143 | void addPwd_slot1(QString *pw, PwMDoc *_doc); |
144 | /** manage/edit triggered */ | 144 | /** manage/edit triggered */ |
145 | //US ENH : changed code to run with older MOC | 145 | //US ENH : changed code to run with older MOC |
146 | void editPwd_slot(); | 146 | void editPwd_slot(); |
147 | void editPwd_slot1(const QString *category); | 147 | void editPwd_slot1(const QString *category); |
148 | void editPwd_slot3(const QString *category, const int *index ,PwMDoc *_doc ); | 148 | void editPwd_slot3(const QString *category, const int *index ,PwMDoc *_doc ); |
149 | 149 | ||
150 | /** manage/delete triggered */ | 150 | /** manage/delete triggered */ |
151 | void deletePwd_slot(); | 151 | void deletePwd_slot(); |
152 | /** execute the "Launcher" entry */ | 152 | /** execute the "Launcher" entry */ |
153 | void execLauncher_slot(); | 153 | void execLauncher_slot(); |
154 | /** open browser with URL entry */ | 154 | /** open browser with URL entry */ |
155 | void goToURL_slot(); | 155 | void goToURL_slot(); |
156 | /** manage/changeMasterPwd triggered */ | 156 | /** manage/changeMasterPwd triggered */ |
157 | void changeMasterPwd_slot(); | 157 | void changeMasterPwd_slot(); |
158 | /** lock current document */ | 158 | /** lock current document */ |
159 | void lockWnd_slot(); | 159 | void lockWnd_slot(); |
160 | /** deeplock current document */ | 160 | /** deeplock current document */ |
161 | void deepLockWnd_slot(); | 161 | void deepLockWnd_slot(); |
162 | /** window/unlock triggered */ | 162 | /** window/unlock triggered */ |
163 | void unlockWnd_slot(); | 163 | void unlockWnd_slot(); |
164 | /** find item */ | 164 | /** find item */ |
165 | void find_slot(); | 165 | void find_slot(); |
166 | /** configure clicked */ | 166 | /** configure clicked */ |
167 | void config_slot(); | 167 | void config_slot(); |
168 | void config_global_slot(); | 168 | void config_global_slot(); |
169 | /** (de)activate the "change master pw" button in the menu-bar */ | 169 | /** (de)activate the "change master pw" button in the menu-bar */ |
170 | void activateMpButton(bool activate = true); | 170 | void activateMpButton(bool activate = true); |
171 | /** generate a new chipcard */ | 171 | /** generate a new chipcard */ |
172 | void genNewCard_slot(); | 172 | void genNewCard_slot(); |
173 | /** completely erase the current card */ | 173 | /** completely erase the current card */ |
174 | void eraseCard_slot(); | 174 | void eraseCard_slot(); |
175 | /** returns the ID number of the current card */ | 175 | /** returns the ID number of the current card */ |
176 | void readCardId_slot(); | 176 | void readCardId_slot(); |
177 | /** make backup image of the current card */ | 177 | /** make backup image of the current card */ |
178 | void makeCardBackup_slot(); | 178 | void makeCardBackup_slot(); |
179 | /** write backup image to current card */ | 179 | /** write backup image to current card */ |
180 | void replayCardBackup_slot(); | 180 | void replayCardBackup_slot(); |
181 | 181 | ||
182 | #ifdef PWM_EMBEDDED | 182 | #ifdef PWM_EMBEDDED |
183 | void category_slot(); | 183 | void category_slot(); |
184 | void whatsnew_slot(); | 184 | void whatsnew_slot(); |
185 | void showLicense_slot(); | 185 | void showLicense_slot(); |
186 | void faq_slot(); | 186 | void faq_slot(); |
187 | void createAboutData_slot(); | 187 | void createAboutData_slot(); |
188 | void syncHowTo_slot(); | 188 | void syncHowTo_slot(); |
189 | #endif | 189 | #endif |
190 | 190 | ||
191 | protected: | 191 | protected: |
192 | /** is this window virgin? */ | 192 | /** is this window virgin? */ |
193 | bool isVirgin() | 193 | bool isVirgin() |
194 | { return virgin; } | 194 | { return virgin; } |
195 | /** add/remove virginity */ | 195 | /** add/remove virginity */ |
196 | void setVirgin(bool v); | 196 | void setVirgin(bool v); |
197 | /** initialize the menubar */ | 197 | /** initialize the menubar */ |
198 | void initMenubar(); | 198 | void initMenubar(); |
199 | /** initialize the toolbar */ | 199 | /** initialize the toolbar */ |
200 | void initToolbar(); | 200 | void initToolbar(); |
201 | /** initialize the window-metrics */ | 201 | /** initialize the window-metrics */ |
202 | void initMetrics(); | 202 | void initMetrics(); |
203 | /** close-event */ | 203 | /** close-event */ |
204 | void closeEvent(QCloseEvent *e); | 204 | void closeEvent(QCloseEvent *e); |
205 | /** creates a new PwM-ListView and returns it */ | 205 | /** creates a new PwM-ListView and returns it */ |
206 | PwMView * makeNewListView(PwMDoc *doc); | 206 | PwMView * makeNewListView(PwMDoc *doc); |
207 | /** Window hide-event */ | 207 | /** Window hide-event */ |
208 | void hideEvent(QHideEvent *); | 208 | void hideEvent(QHideEvent *); |
209 | /** is this window minimized? */ | 209 | /** is this window minimized? */ |
210 | bool isMinimized() | 210 | bool isMinimized() |
211 | { | 211 | { |
212 | #ifndef PWM_EMBEDDED | 212 | #ifndef PWM_EMBEDDED |
213 | #if KDE_VERSION >= KDE_MAKE_VERSION(3, 2, 0) | 213 | #if KDE_VERSION >= KDE_MAKE_VERSION(3, 2, 0) |
214 | return KWin::windowInfo(winId()).isMinimized(); | 214 | return KWin::windowInfo(winId()).isMinimized(); |
215 | #else // KDE_VERSION | 215 | #else // KDE_VERSION |
216 | return KWin::info(winId()).isIconified(); | 216 | return KWin::info(winId()).isIconified(); |
217 | #endif // KDE_VERSION | 217 | #endif // KDE_VERSION |
218 | #else | 218 | #else |
219 | return false; | 219 | return false; |
220 | #endif | 220 | #endif |
221 | } | 221 | } |
222 | /** window got the focus */ | 222 | /** window got the focus */ |
223 | void focusInEvent(QFocusEvent *e); | 223 | void focusInEvent(QFocusEvent *e); |
224 | /** update the caption string */ | 224 | /** update the caption string */ |
225 | void updateCaption(); | 225 | void updateCaption(); |
226 | #ifdef CONFIG_KWALLETIF | 226 | #ifdef CONFIG_KWALLETIF |
227 | /** check if kwalletemu is enabled and ask the user what to do */ | 227 | /** check if kwalletemu is enabled and ask the user what to do */ |
228 | bool checkAndAskForKWalletEmu(); | 228 | bool checkAndAskForKWalletEmu(); |
229 | #endif // CONFIG_KWALLETIF | 229 | #endif // CONFIG_KWALLETIF |
230 | 230 | ||
231 | protected slots: | 231 | protected slots: |
232 | /** doc got closed */ | 232 | /** doc got closed */ |
233 | void docClosed(PwMDoc *doc); | 233 | void docClosed(PwMDoc *doc); |
234 | 234 | ||
235 | signals: | 235 | signals: |
236 | /** window got closed (by user or someone else) */ | 236 | /** window got closed (by user or someone else) */ |
237 | void closed(PwM *wnd); | 237 | void closed(PwM *wnd); |
238 | /** window got the focus (was brought to foreground) */ | 238 | /** window got the focus (was brought to foreground) */ |
239 | void gotFocus(PwM *wnd); | 239 | void gotFocus(PwM *wnd); |
240 | /** window lost the focus */ | 240 | /** window lost the focus */ |
241 | void lostFocus(PwM *wnd); | 241 | void lostFocus(PwM *wnd); |
242 | 242 | ||
243 | protected: | 243 | protected: |
244 | /** pointer to the view active in this KMainWindow */ | 244 | /** pointer to the view active in this KMainWindow */ |
245 | PwMView *view; | 245 | PwMView *view; |
246 | /** pointer to the init class */ | 246 | /** pointer to the init class */ |
247 | PwMInit *init; | 247 | PwMInit *init; |
248 | /** has this window already lost its virginity? | 248 | /** has this window already lost its virginity? |
249 | * Means is there an open working document | 249 | * Means is there an open working document |
250 | */ | 250 | */ |
251 | bool virgin; | 251 | bool virgin; |
252 | /** "file" popup-menu */ | 252 | /** "file" popup-menu */ |
253 | KPopupMenu *filePopup; | 253 | KPopupMenu *filePopup; |
254 | 254 | ||
255 | /** "manage" popup-menu */ | 255 | /** "manage" popup-menu */ |
256 | KPopupMenu *managePopup; | 256 | KPopupMenu *managePopup; |
257 | #ifdef CONFIG_KEYCARD | 257 | #ifdef CONFIG_KEYCARD |
258 | /** "chipcard" popup-menu */ | 258 | /** "chipcard" popup-menu */ |
259 | KPopupMenu *chipcardPopup; | 259 | KPopupMenu *chipcardPopup; |
260 | #endif // CONFIG_KEYCARD | 260 | #endif // CONFIG_KEYCARD |
261 | /** "view" popup-menu */ | 261 | /** "view" popup-menu */ |
262 | KPopupMenu *viewPopup; | 262 | KPopupMenu *viewPopup; |
263 | /** "options" popup-menu */ | 263 | /** "options" popup-menu */ |
264 | KPopupMenu *optionsPopup; | 264 | KPopupMenu *optionsPopup; |
265 | /** "help" popup-menu */ | 265 | /** "help" popup-menu */ |
266 | KPopupMenu *helpPopup; | 266 | KPopupMenu *helpPopup; |
267 | /** "export" popup-menu */ | 267 | /** "export" popup-menu */ |
268 | KPopupMenu *exportPopup; | 268 | KPopupMenu *exportPopup; |
269 | /** "import" popup-menu */ | 269 | /** "import" popup-menu */ |
270 | KPopupMenu *importPopup; | 270 | KPopupMenu *importPopup; |
271 | /** force quit this window? */ | 271 | /** force quit this window? */ |
272 | bool forceQuit; | 272 | bool forceQuit; |
273 | /** force minimize this window to the tray */ | 273 | /** force minimize this window to the tray */ |
274 | bool forceMinimizeToTray; | 274 | bool forceMinimizeToTray; |
275 | 275 | ||
276 | 276 | ||
277 | 277 | ||
278 | 278 | ||
279 | private: | 279 | private: |
280 | #ifdef PWM_EMBEDDED | 280 | #ifdef PWM_EMBEDDED |
281 | //this are the overwritten callbackmethods from the syncinterface | 281 | //this are the overwritten callbackmethods from the syncinterface |
282 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 282 | virtual bool sync(KSyncManager* manager, QString filename, int mode,QString resource); |
283 | virtual void removeSyncInfo( QString syncProfile); | 283 | virtual void removeSyncInfo( QString syncProfile); |
284 | 284 | ||
285 | // LR ******************************* | 285 | // LR ******************************* |
286 | // sync stuff! | 286 | // sync stuff! |
287 | QPopupMenu *syncPopup; | 287 | QPopupMenu *syncPopup; |
288 | KSyncManager* syncManager; | 288 | KSyncManager* syncManager; |
289 | #endif | 289 | #endif |
290 | 290 | ||
291 | 291 | ||
292 | 292 | ||
293 | 293 | ||
294 | 294 | ||
295 | 295 | ||
296 | 296 | ||
297 | 297 | ||
298 | }; | 298 | }; |
299 | 299 | ||
300 | #endif | 300 | #endif |
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp index 1f3c58b..b58d7e2 100644 --- a/pwmanager/pwmanager/pwmdoc.cpp +++ b/pwmanager/pwmanager/pwmdoc.cpp | |||
@@ -2935,700 +2935,700 @@ PwMerror PwMDoc::exportToGpasman(const QString *file) | |||
2935 | } | 2935 | } |
2936 | 2936 | ||
2937 | PwMerror PwMDoc::importFromGpasman(const QString *file) | 2937 | PwMerror PwMDoc::importFromGpasman(const QString *file) |
2938 | { | 2938 | { |
2939 | PWM_ASSERT(file); | 2939 | PWM_ASSERT(file); |
2940 | QString pw = requestMpw(false); | 2940 | QString pw = requestMpw(false); |
2941 | if (pw == "") | 2941 | if (pw == "") |
2942 | return e_noPw; | 2942 | return e_noPw; |
2943 | GpasmanFile gp; | 2943 | GpasmanFile gp; |
2944 | int ret, i; | 2944 | int ret, i; |
2945 | PwMerror ret2; | 2945 | PwMerror ret2; |
2946 | char *entry[4]; | 2946 | char *entry[4]; |
2947 | PwMDataItem tmpData; | 2947 | PwMDataItem tmpData; |
2948 | ret = gp.load_init(file->latin1(), pw.latin1()); | 2948 | ret = gp.load_init(file->latin1(), pw.latin1()); |
2949 | if (ret != 1) | 2949 | if (ret != 1) |
2950 | return e_accessFile; | 2950 | return e_accessFile; |
2951 | 2951 | ||
2952 | do { | 2952 | do { |
2953 | ret = gp.load_entry(entry); | 2953 | ret = gp.load_entry(entry); |
2954 | if(ret != 1) | 2954 | if(ret != 1) |
2955 | break; | 2955 | break; |
2956 | tmpData.desc = entry[0]; | 2956 | tmpData.desc = entry[0]; |
2957 | tmpData.name = entry[1]; | 2957 | tmpData.name = entry[1]; |
2958 | tmpData.pw = entry[2]; | 2958 | tmpData.pw = entry[2]; |
2959 | tmpData.comment = entry[3]; | 2959 | tmpData.comment = entry[3]; |
2960 | tmpData.lockStat = true; | 2960 | tmpData.lockStat = true; |
2961 | tmpData.listViewPos = -1; | 2961 | tmpData.listViewPos = -1; |
2962 | ret2 = addEntry(DEFAULT_CATEGORY, &tmpData, true); | 2962 | ret2 = addEntry(DEFAULT_CATEGORY, &tmpData, true); |
2963 | for (i = 0; i < 4; ++i) | 2963 | for (i = 0; i < 4; ++i) |
2964 | free(entry[i]); | 2964 | free(entry[i]); |
2965 | if (ret2 == e_maxAllowedEntr) { | 2965 | if (ret2 == e_maxAllowedEntr) { |
2966 | gp.load_finalize(); | 2966 | gp.load_finalize(); |
2967 | return e_maxAllowedEntr; | 2967 | return e_maxAllowedEntr; |
2968 | } | 2968 | } |
2969 | } while (1); | 2969 | } while (1); |
2970 | gp.load_finalize(); | 2970 | gp.load_finalize(); |
2971 | if (isDocEmpty()) | 2971 | if (isDocEmpty()) |
2972 | return e_wrongPw; // we assume this. | 2972 | return e_wrongPw; // we assume this. |
2973 | 2973 | ||
2974 | flagDirty(); | 2974 | flagDirty(); |
2975 | return e_success; | 2975 | return e_success; |
2976 | } | 2976 | } |
2977 | 2977 | ||
2978 | 2978 | ||
2979 | //US: we use the stl sort algorythm to sort all elements in the order | 2979 | //US: we use the stl sort algorythm to sort all elements in the order |
2980 | //of its listViewPos (in the order 1,2,3,5,...,x,-1, -1, -1 | 2980 | //of its listViewPos (in the order 1,2,3,5,...,x,-1, -1, -1 |
2981 | struct PwMDataItemListViewPosSort | 2981 | struct PwMDataItemListViewPosSort |
2982 | { | 2982 | { |
2983 | bool operator()(PwMDataItem* rpStart, PwMDataItem* rpEnd) | 2983 | bool operator()(PwMDataItem* rpStart, PwMDataItem* rpEnd) |
2984 | { | 2984 | { |
2985 | //qDebug("pwMDoc::PwMDataItemListViewPosSort()"); | 2985 | //qDebug("pwMDoc::PwMDataItemListViewPosSort()"); |
2986 | if ((rpEnd)->listViewPos < 0) | 2986 | if ((rpEnd)->listViewPos < 0) |
2987 | return false; | 2987 | return false; |
2988 | else | 2988 | else |
2989 | return (rpStart)->listViewPos < (rpEnd)->listViewPos; | 2989 | return (rpStart)->listViewPos < (rpEnd)->listViewPos; |
2990 | } | 2990 | } |
2991 | }; | 2991 | }; |
2992 | 2992 | ||
2993 | void PwMDoc::ensureLvp() | 2993 | void PwMDoc::ensureLvp() |
2994 | { | 2994 | { |
2995 | if (isDocEmpty()) | 2995 | if (isDocEmpty()) |
2996 | return; | 2996 | return; |
2997 | 2997 | ||
2998 | //US ENH BUG: when using syncronizing, this way of sorting | 2998 | //US ENH BUG: when using syncronizing, this way of sorting |
2999 | //is not sufficient, because there might be empty spaces | 2999 | //is not sufficient, because there might be empty spaces |
3000 | // at the beginning. But the old algorythm only can add elements | 3000 | // at the beginning. But the old algorythm only can add elements |
3001 | //to the end.The result are crashes because of list overflows | 3001 | //to the end.The result are crashes because of list overflows |
3002 | //we need something to fill all gaps. | 3002 | //we need something to fill all gaps. |
3003 | vector<PwMDataItem*> sorted; | 3003 | vector<PwMDataItem*> sorted; |
3004 | vector< PwMDataItem*>::iterator sortedBegin, | 3004 | vector< PwMDataItem*>::iterator sortedBegin, |
3005 | sortedEnd, | 3005 | sortedEnd, |
3006 | sortedI; | 3006 | sortedI; |
3007 | vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), | 3007 | vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), |
3008 | catEnd = dti.dta.end(), | 3008 | catEnd = dti.dta.end(), |
3009 | catI = catBegin; | 3009 | catI = catBegin; |
3010 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; | 3010 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; |
3011 | int lvpTop, tmpLvp; | 3011 | int lvpTop, tmpLvp; |
3012 | 3012 | ||
3013 | //qDebug("collect:"); | 3013 | //qDebug("collect:"); |
3014 | 3014 | ||
3015 | while (catI != catEnd) { | 3015 | while (catI != catEnd) { |
3016 | lvpTop = -1; | 3016 | lvpTop = -1; |
3017 | sorted.clear(); | 3017 | sorted.clear(); |
3018 | 3018 | ||
3019 | entrBegin = catI->d.begin(); | 3019 | entrBegin = catI->d.begin(); |
3020 | entrEnd = catI->d.end(); | 3020 | entrEnd = catI->d.end(); |
3021 | entrI = entrBegin; | 3021 | entrI = entrBegin; |
3022 | 3022 | ||
3023 | //US: we use the stl sort algorythm to sort all elements in the order | 3023 | //US: we use the stl sort algorythm to sort all elements in the order |
3024 | //of its listViewPos (in the order 1,2,2,3,5,...,x,-1, -1, -1 | 3024 | //of its listViewPos (in the order 1,2,2,3,5,...,x,-1, -1, -1 |
3025 | while (entrI != entrEnd) { | 3025 | while (entrI != entrEnd) { |
3026 | //qDebug("found: %s, pos=%i", (*entrI).desc.c_str(), (*entrI).listViewPos); | 3026 | //qDebug("found: %s, pos=%i", (*entrI).desc.c_str(), (*entrI).listViewPos); |
3027 | sorted.push_back((PwMDataItem*)&(*entrI)); | 3027 | sorted.push_back((PwMDataItem*)&(*entrI)); |
3028 | ++entrI; | 3028 | ++entrI; |
3029 | } | 3029 | } |
3030 | 3030 | ||
3031 | sortedBegin = sorted.begin(); | 3031 | sortedBegin = sorted.begin(); |
3032 | sortedEnd = sorted.end(); | 3032 | sortedEnd = sorted.end(); |
3033 | 3033 | ||
3034 | sort(sortedBegin, sortedEnd, PwMDataItemListViewPosSort()); | 3034 | sort(sortedBegin, sortedEnd, PwMDataItemListViewPosSort()); |
3035 | 3035 | ||
3036 | // qDebug("resort:"); | 3036 | // qDebug("resort:"); |
3037 | //now we have all sorted in a collection | 3037 | //now we have all sorted in a collection |
3038 | //Now start with the sorted and reset listviewpos. | 3038 | //Now start with the sorted and reset listviewpos. |
3039 | sortedBegin = sorted.begin(); | 3039 | sortedBegin = sorted.begin(); |
3040 | sortedEnd = sorted.end(); | 3040 | sortedEnd = sorted.end(); |
3041 | sortedI = sortedBegin; | 3041 | sortedI = sortedBegin; |
3042 | 3042 | ||
3043 | while (sortedI != sortedEnd) { | 3043 | while (sortedI != sortedEnd) { |
3044 | // qDebug("reset defined: %s, from pos=%i to pos=%i", (*sortedI)->desc.c_str(), (*sortedI)->listViewPos, lvpTop+1); | 3044 | // qDebug("reset defined: %s, from pos=%i to pos=%i", (*sortedI)->desc.c_str(), (*sortedI)->listViewPos, lvpTop+1); |
3045 | (*sortedI)->listViewPos = ++lvpTop; | 3045 | (*sortedI)->listViewPos = ++lvpTop; |
3046 | ++sortedI; | 3046 | ++sortedI; |
3047 | } | 3047 | } |
3048 | 3048 | ||
3049 | /*/debug | 3049 | /*/debug |
3050 | entrBegin = catI->d.begin(); | 3050 | entrBegin = catI->d.begin(); |
3051 | entrEnd = catI->d.end(); | 3051 | entrEnd = catI->d.end(); |
3052 | entrI = entrBegin; | 3052 | entrI = entrBegin; |
3053 | 3053 | ||
3054 | while (entrI != entrEnd) { | 3054 | while (entrI != entrEnd) { |
3055 | qDebug("check: %s, pos=%i", (*entrI).desc.c_str(), (*entrI).listViewPos); | 3055 | qDebug("check: %s, pos=%i", (*entrI).desc.c_str(), (*entrI).listViewPos); |
3056 | ++entrI; | 3056 | ++entrI; |
3057 | } | 3057 | } |
3058 | */ | 3058 | */ |
3059 | 3059 | ||
3060 | ++catI; | 3060 | ++catI; |
3061 | } | 3061 | } |
3062 | } | 3062 | } |
3063 | 3063 | ||
3064 | QString PwMDoc::getTitle() | 3064 | QString PwMDoc::getTitle() |
3065 | { | 3065 | { |
3066 | /* NOTE: We have to ensure, that the returned title | 3066 | /* NOTE: We have to ensure, that the returned title |
3067 | * is unique and not reused somewhere else while | 3067 | * is unique and not reused somewhere else while |
3068 | * this document is valid (open). | 3068 | * this document is valid (open). |
3069 | */ | 3069 | */ |
3070 | QString title(getFilename()); | 3070 | QString title(getFilename()); |
3071 | 3071 | ||
3072 | //US ENH: The whole filename on PDAs is too long. So use only the last characters | 3072 | //US ENH: The whole filename on PDAs is too long. So use only the last characters |
3073 | if (QApplication::desktop()->width() < 640) | 3073 | if (QApplication::desktop()->width() < 640) |
3074 | { | 3074 | { |
3075 | if (title.length() > 30) | 3075 | if (title.length() > 30) |
3076 | title = "..." + title.right(30); | 3076 | title = "..." + title.right(30); |
3077 | 3077 | ||
3078 | } | 3078 | } |
3079 | 3079 | ||
3080 | 3080 | ||
3081 | if (title.isEmpty()) { | 3081 | if (title.isEmpty()) { |
3082 | if (unnamedNum == 0) { | 3082 | if (unnamedNum == 0) { |
3083 | unnamedNum = PwMDocList::getNewUnnamedNumber(); | 3083 | unnamedNum = PwMDocList::getNewUnnamedNumber(); |
3084 | PWM_ASSERT(unnamedNum != 0); | 3084 | PWM_ASSERT(unnamedNum != 0); |
3085 | } | 3085 | } |
3086 | title = DEFAULT_TITLE; | 3086 | title = DEFAULT_TITLE; |
3087 | title += " "; | 3087 | title += " "; |
3088 | title += tostr(unnamedNum).c_str(); | 3088 | title += tostr(unnamedNum).c_str(); |
3089 | } | 3089 | } |
3090 | return title; | 3090 | return title; |
3091 | } | 3091 | } |
3092 | 3092 | ||
3093 | bool PwMDoc::tryDelete() | 3093 | bool PwMDoc::tryDelete() |
3094 | { | 3094 | { |
3095 | 3095 | ||
3096 | if (deleted) | 3096 | if (deleted) |
3097 | return true; | 3097 | return true; |
3098 | int ret; | 3098 | int ret; |
3099 | if (isDirty()) { | 3099 | if (isDirty()) { |
3100 | ret = dirtyAskSave(getTitle()); | 3100 | ret = dirtyAskSave(getTitle()); |
3101 | if (ret == 0) { // save to disk | 3101 | if (ret == 0) { // save to disk |
3102 | if (!saveDocUi(this)) | 3102 | if (!saveDocUi(this)) |
3103 | goto out_ignore; | 3103 | goto out_ignore; |
3104 | } else if (ret == 1) { // don't save and delete | 3104 | } else if (ret == 1) { // don't save and delete |
3105 | goto out_accept; | 3105 | goto out_accept; |
3106 | } else { // cancel operation | 3106 | } else { // cancel operation |
3107 | goto out_ignore; | 3107 | goto out_ignore; |
3108 | } | 3108 | } |
3109 | } | 3109 | } |
3110 | out_accept: | 3110 | out_accept: |
3111 | deleted = true; | 3111 | deleted = true; |
3112 | delete this; | 3112 | delete this; |
3113 | return true; | 3113 | return true; |
3114 | out_ignore: | 3114 | out_ignore: |
3115 | return false; | 3115 | return false; |
3116 | } | 3116 | } |
3117 | 3117 | ||
3118 | 3118 | ||
3119 | 3119 | ||
3120 | #ifdef PWM_EMBEDDED | 3120 | #ifdef PWM_EMBEDDED |
3121 | //US ENH: this is the magic function that syncronizes the this doc with the remote doc | 3121 | //US ENH: this is the magic function that syncronizes the this doc with the remote doc |
3122 | //US it could have been defined as static, but I did not want to. | 3122 | //US it could have been defined as static, but I did not want to. |
3123 | PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* syncRemote, int mode ) | 3123 | PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* syncRemote, int mode ) |
3124 | { | 3124 | { |
3125 | int addedPasswordsLocal = 0; | 3125 | int addedPasswordsLocal = 0; |
3126 | int addedPasswordsRemote = 0; | 3126 | int addedPasswordsRemote = 0; |
3127 | int deletedPasswordsRemote = 0; | 3127 | int deletedPasswordsRemote = 0; |
3128 | int deletedPasswordsLocal = 0; | 3128 | int deletedPasswordsLocal = 0; |
3129 | int changedLocal = 0; | 3129 | int changedLocal = 0; |
3130 | int changedRemote = 0; | 3130 | int changedRemote = 0; |
3131 | 3131 | ||
3132 | PwMSyncItem* syncItemLocal; | 3132 | PwMSyncItem* syncItemLocal; |
3133 | PwMSyncItem* syncItemRemote; | 3133 | PwMSyncItem* syncItemRemote; |
3134 | 3134 | ||
3135 | QString mCurrentSyncName = manager->getCurrentSyncName(); | 3135 | QString mCurrentSyncName = manager->getCurrentSyncName(); |
3136 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3136 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3137 | 3137 | ||
3138 | bool mSyncLauncher = true; | 3138 | bool mSyncLauncher = true; |
3139 | 3139 | ||
3140 | bool fullDateRange = false; | 3140 | bool fullDateRange = false; |
3141 | int take; | 3141 | int take; |
3142 | // local->resetTempSyncStat(); | 3142 | // local->resetTempSyncStat(); |
3143 | QDateTime mLastSync = QDateTime::currentDateTime(); | 3143 | QDateTime mLastSync = QDateTime::currentDateTime(); |
3144 | QDateTime modifiedSync = mLastSync; | 3144 | QDateTime modifiedSync = mLastSync; |
3145 | 3145 | ||
3146 | unsigned int index; | 3146 | unsigned int index; |
3147 | //Step 1. Find syncinfo in Local file and create if not existent. | 3147 | //Step 1. Find syncinfo in Local file and create if not existent. |
3148 | bool found = syncLocal->findSyncData(mCurrentSyncDevice, &index); | 3148 | bool found = syncLocal->findSyncData(mCurrentSyncDevice, &index); |
3149 | if (found == false) | 3149 | if (found == false) |
3150 | { | 3150 | { |
3151 | PwMSyncItem newSyncItemLocal; | 3151 | PwMSyncItem newSyncItemLocal; |
3152 | newSyncItemLocal.syncName = mCurrentSyncDevice.latin1(); | 3152 | newSyncItemLocal.syncName = mCurrentSyncDevice.latin1(); |
3153 | newSyncItemLocal.lastSyncDate = mLastSync; | 3153 | newSyncItemLocal.lastSyncDate = mLastSync; |
3154 | syncLocal->addSyncDataEntry(&newSyncItemLocal, true); | 3154 | syncLocal->addSyncDataEntry(&newSyncItemLocal, true); |
3155 | found = syncLocal->findSyncData(mCurrentSyncDevice, &index); | 3155 | found = syncLocal->findSyncData(mCurrentSyncDevice, &index); |
3156 | if (found == false) { | 3156 | if (found == false) { |
3157 | qDebug("PwMDoc::syncronize : newly created local sync data could not be found"); | 3157 | qDebug("PwMDoc::syncronize : newly created local sync data could not be found"); |
3158 | return e_syncError; | 3158 | return e_syncError; |
3159 | } | 3159 | } |
3160 | } | 3160 | } |
3161 | 3161 | ||
3162 | syncItemLocal = syncLocal->getSyncDataEntry(index); | 3162 | syncItemLocal = syncLocal->getSyncDataEntry(index); |
3163 | qDebug("Last Sync Local %s ", syncItemLocal->lastSyncDate.toString().latin1()); | 3163 | qDebug("Last Sync Local %s ", syncItemLocal->lastSyncDate.toString().latin1()); |
3164 | 3164 | ||
3165 | //Step 2. Find syncinfo in remote file and create if not existent. | 3165 | //Step 2. Find syncinfo in remote file and create if not existent. |
3166 | found = syncRemote->findSyncData(mCurrentSyncName, &index); | 3166 | found = syncRemote->findSyncData(mCurrentSyncName, &index); |
3167 | if (found == false) | 3167 | if (found == false) |
3168 | { | 3168 | { |
3169 | qDebug("FULLDATE 1"); | 3169 | qDebug("FULLDATE 1"); |
3170 | fullDateRange = true; | 3170 | fullDateRange = true; |
3171 | PwMSyncItem newSyncItemRemote; | 3171 | PwMSyncItem newSyncItemRemote; |
3172 | newSyncItemRemote.syncName = mCurrentSyncName.latin1(); | 3172 | newSyncItemRemote.syncName = mCurrentSyncName.latin1(); |
3173 | newSyncItemRemote.lastSyncDate = mLastSync; | 3173 | newSyncItemRemote.lastSyncDate = mLastSync; |
3174 | syncRemote->addSyncDataEntry(&newSyncItemRemote, true); | 3174 | syncRemote->addSyncDataEntry(&newSyncItemRemote, true); |
3175 | found = syncRemote->findSyncData(mCurrentSyncName, &index); | 3175 | found = syncRemote->findSyncData(mCurrentSyncName, &index); |
3176 | if (found == false) { | 3176 | if (found == false) { |
3177 | qDebug("PwMDoc::syncronize : newly created remote sync data could not be found"); | 3177 | qDebug("PwMDoc::syncronize : newly created remote sync data could not be found"); |
3178 | return e_syncError; | 3178 | return e_syncError; |
3179 | } | 3179 | } |
3180 | } | 3180 | } |
3181 | 3181 | ||
3182 | syncItemRemote = syncRemote->getSyncDataEntry(index); | 3182 | syncItemRemote = syncRemote->getSyncDataEntry(index); |
3183 | qDebug("Last Sync Remote %s ", syncItemRemote->lastSyncDate.toString().latin1()); | 3183 | qDebug("Last Sync Remote %s ", syncItemRemote->lastSyncDate.toString().latin1()); |
3184 | //and remove the found entry here. We will reenter it later again. | 3184 | //and remove the found entry here. We will reenter it later again. |
3185 | //US syncRemote->delSyncDataEntry(index, true); | 3185 | //US syncRemote->delSyncDataEntry(index, true); |
3186 | 3186 | ||
3187 | 3187 | ||
3188 | if ( syncItemLocal->lastSyncDate == mLastSync ) { | 3188 | if ( syncItemLocal->lastSyncDate == mLastSync ) { |
3189 | qDebug("FULLDATE 2"); | 3189 | qDebug("FULLDATE 2"); |
3190 | fullDateRange = true; | 3190 | fullDateRange = true; |
3191 | } | 3191 | } |
3192 | 3192 | ||
3193 | if ( ! fullDateRange ) { | 3193 | if ( ! fullDateRange ) { |
3194 | if ( syncItemLocal->lastSyncDate != syncItemRemote->lastSyncDate ) { | 3194 | if ( syncItemLocal->lastSyncDate != syncItemRemote->lastSyncDate ) { |
3195 | 3195 | ||
3196 | fullDateRange = true; | 3196 | fullDateRange = true; |
3197 | qDebug("FULLDATE 3 %s %s", syncItemLocal->lastSyncDate.toString().latin1() , syncItemRemote->lastSyncDate.toString().latin1() ); | 3197 | qDebug("FULLDATE 3 %s %s", syncItemLocal->lastSyncDate.toString().latin1() , syncItemRemote->lastSyncDate.toString().latin1() ); |
3198 | } | 3198 | } |
3199 | } | 3199 | } |
3200 | // fullDateRange = true; // debug only! | 3200 | // fullDateRange = true; // debug only! |
3201 | if ( fullDateRange ) | 3201 | if ( fullDateRange ) |
3202 | mLastSync = QDateTime::currentDateTime().addDays( -100*365); | 3202 | mLastSync = QDateTime::currentDateTime().addDays( -100*365); |
3203 | else | 3203 | else |
3204 | mLastSync = syncItemLocal->lastSyncDate; | 3204 | mLastSync = syncItemLocal->lastSyncDate; |
3205 | 3205 | ||
3206 | 3206 | ||
3207 | qDebug("*************************** "); | 3207 | qDebug("*************************** "); |
3208 | qDebug("mLastSync %s ",mLastSync.toString().latin1() ); | 3208 | qDebug("mLastSync %s ",mLastSync.toString().latin1() ); |
3209 | QStringList er = syncRemote->getIDEntryList(); | 3209 | QStringList er = syncRemote->getIDEntryList(); |
3210 | PwMDataItem* inRemote ;//= er.first(); | 3210 | PwMDataItem* inRemote ;//= er.first(); |
3211 | PwMDataItem* inLocal; | 3211 | PwMDataItem* inLocal; |
3212 | unsigned int catLocal, indexLocal; | 3212 | unsigned int catLocal, indexLocal; |
3213 | unsigned int catRemote, indexRemote; | 3213 | unsigned int catRemote, indexRemote; |
3214 | 3214 | ||
3215 | QString uid; | 3215 | QString uid; |
3216 | manager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 3216 | manager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
3217 | 3217 | ||
3218 | int modulo = (er.count()/10)+1; | 3218 | int modulo = (er.count()/10)+1; |
3219 | unsigned int incCounter = 0; | 3219 | unsigned int incCounter = 0; |
3220 | while ( incCounter < er.count()) { | 3220 | while ( incCounter < er.count()) { |
3221 | if (manager->isProgressBarCanceled()) | 3221 | if (manager->isProgressBarCanceled()) |
3222 | return e_syncError; | 3222 | return e_syncError; |
3223 | if ( incCounter % modulo == 0 ) | 3223 | if ( incCounter % modulo == 0 ) |
3224 | manager->showProgressBar(incCounter); | 3224 | manager->showProgressBar(incCounter); |
3225 | 3225 | ||
3226 | uid = er[ incCounter ]; | 3226 | uid = er[ incCounter ]; |
3227 | qDebug("sync uid %s from remote file", uid.latin1()); | 3227 | qDebug("sync uid %s from remote file", uid.latin1()); |
3228 | 3228 | ||
3229 | qApp->processEvents(); | 3229 | qApp->processEvents(); |
3230 | 3230 | ||
3231 | inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); | 3231 | inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); |
3232 | inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); | 3232 | inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); |
3233 | PWM_ASSERT(inRemote); | 3233 | PWM_ASSERT(inRemote); |
3234 | if ( inLocal != 0 ) { // maybe conflict - same uid in both files | 3234 | if ( inLocal != 0 ) { // maybe conflict - same uid in both files |
3235 | if ( (take = takePwMDataItem( inLocal, inRemote, mLastSync, mode, fullDateRange) ) ) { | 3235 | if ( (take = takePwMDataItem( inLocal, inRemote, mLastSync, mode, fullDateRange) ) ) { |
3236 | qDebug("take %d %s ", take, inLocal->desc.c_str()); | 3236 | qDebug("take %d %s ", take, inLocal->desc.c_str()); |
3237 | if ( take == 3 ) | 3237 | if ( take == 3 ) |
3238 | return e_syncError; | 3238 | return e_syncError; |
3239 | if ( take == 1 ) {// take local | 3239 | if ( take == 1 ) {// take local |
3240 | inRemote->syncItem(*inLocal, mSyncLauncher); | 3240 | inRemote->syncItem(*inLocal, mSyncLauncher); |
3241 | ++changedRemote; | 3241 | ++changedRemote; |
3242 | } else { // take == 2 take remote | 3242 | } else { // take == 2 take remote |
3243 | inLocal->syncItem(*inRemote, mSyncLauncher); | 3243 | inLocal->syncItem(*inRemote, mSyncLauncher); |
3244 | ++changedLocal; | 3244 | ++changedLocal; |
3245 | } | 3245 | } |
3246 | } | 3246 | } |
3247 | } else { // no conflict | 3247 | } else { // no conflict |
3248 | if ( inRemote->meta.update > mLastSync || mode == 5 ) { | 3248 | if ( inRemote->meta.update > mLastSync || mode == 5 ) { |
3249 | inRemote->meta.update = modifiedSync; | 3249 | inRemote->meta.update = modifiedSync; |
3250 | 3250 | ||
3251 | //first check if we have a matching category in the local file | 3251 | //first check if we have a matching category in the local file |
3252 | const string* remotecat = syncRemote->getCategory(catRemote); | 3252 | const string* remotecat = syncRemote->getCategory(catRemote); |
3253 | syncLocal->addEntry(remotecat->c_str(), inRemote, true, false); | 3253 | syncLocal->addEntry(remotecat->c_str(), inRemote, true, false); |
3254 | 3254 | ||
3255 | ++addedPasswordsLocal; | 3255 | ++addedPasswordsLocal; |
3256 | } else { | 3256 | } else { |
3257 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 3257 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
3258 | syncRemote->delEntry(catRemote, indexRemote, true); | 3258 | syncRemote->delEntry(catRemote, indexRemote, true); |
3259 | ++deletedPasswordsRemote; | 3259 | ++deletedPasswordsRemote; |
3260 | } | 3260 | } |
3261 | } | 3261 | } |
3262 | 3262 | ||
3263 | ++incCounter; | 3263 | ++incCounter; |
3264 | } | 3264 | } |
3265 | 3265 | ||
3266 | 3266 | ||
3267 | er.clear(); | 3267 | er.clear(); |
3268 | QStringList el = syncLocal->getIDEntryList(); | 3268 | QStringList el = syncLocal->getIDEntryList(); |
3269 | modulo = (el.count()/10)+1; | 3269 | modulo = (el.count()/10)+1; |
3270 | 3270 | ||
3271 | manager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 3271 | manager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
3272 | incCounter = 0; | 3272 | incCounter = 0; |
3273 | while ( incCounter < el.count()) { | 3273 | while ( incCounter < el.count()) { |
3274 | qApp->processEvents(); | 3274 | qApp->processEvents(); |
3275 | if (manager->isProgressBarCanceled()) | 3275 | if (manager->isProgressBarCanceled()) |
3276 | return e_syncError; | 3276 | return e_syncError; |
3277 | if ( incCounter % modulo == 0 ) | 3277 | if ( incCounter % modulo == 0 ) |
3278 | manager->showProgressBar(incCounter); | 3278 | manager->showProgressBar(incCounter); |
3279 | uid = el[ incCounter ]; | 3279 | uid = el[ incCounter ]; |
3280 | qDebug("sync uid %s from local file", uid.latin1()); | 3280 | qDebug("sync uid %s from local file", uid.latin1()); |
3281 | 3281 | ||
3282 | inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); | 3282 | inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); |
3283 | inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); | 3283 | inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); |
3284 | PWM_ASSERT(inLocal); | 3284 | PWM_ASSERT(inLocal); |
3285 | 3285 | ||
3286 | if ( inRemote == 0 ) { | 3286 | if ( inRemote == 0 ) { |
3287 | if ( inLocal->meta.update < mLastSync && mode != 4 ) { | 3287 | if ( inLocal->meta.update < mLastSync && mode != 4 ) { |
3288 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 3288 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
3289 | syncLocal->delEntry(catLocal, indexLocal, true); | 3289 | syncLocal->delEntry(catLocal, indexLocal, true); |
3290 | ++deletedPasswordsLocal; | 3290 | ++deletedPasswordsLocal; |
3291 | } else { | 3291 | } else { |
3292 | if ( ! manager->mWriteBackExistingOnly ) { | 3292 | if ( ! manager->mWriteBackExistingOnly ) { |
3293 | ++addedPasswordsRemote; | 3293 | ++addedPasswordsRemote; |
3294 | inLocal->meta.update = modifiedSync; | 3294 | inLocal->meta.update = modifiedSync; |
3295 | 3295 | ||
3296 | //first check if we have a matching category in the remote file | 3296 | //first check if we have a matching category in the remote file |
3297 | const string* localcat = syncLocal->getCategory(catLocal); | 3297 | const string* localcat = syncLocal->getCategory(catLocal); |
3298 | 3298 | ||
3299 | PwMDataItem newEntry; | 3299 | PwMDataItem newEntry; |
3300 | newEntry = *inLocal; | 3300 | newEntry = *inLocal; |
3301 | inRemote = &newEntry; | 3301 | inRemote = &newEntry; |
3302 | 3302 | ||
3303 | //USsyncRemote->insertAddressee( inRemote, false ); | 3303 | //USsyncRemote->insertAddressee( inRemote, false ); |
3304 | syncRemote->addEntry(localcat->c_str(), inRemote, true, false); | 3304 | syncRemote->addEntry(localcat->c_str(), inRemote, true, false); |
3305 | 3305 | ||
3306 | } | 3306 | } |
3307 | } | 3307 | } |
3308 | 3308 | ||
3309 | } | 3309 | } |
3310 | ++incCounter; | 3310 | ++incCounter; |
3311 | } | 3311 | } |
3312 | el.clear(); | 3312 | el.clear(); |
3313 | manager->hideProgressBar(); | 3313 | manager->hideProgressBar(); |
3314 | 3314 | ||
3315 | // Now write the info back into the sync data space of the files | 3315 | // Now write the info back into the sync data space of the files |
3316 | 3316 | ||
3317 | mLastSync = QDateTime::currentDateTime().addSecs( 1 ); | 3317 | mLastSync = QDateTime::currentDateTime().addSecs( 1 ); |
3318 | // get rid of micro seconds | 3318 | // get rid of micro seconds |
3319 | QTime t = mLastSync.time(); | 3319 | QTime t = mLastSync.time(); |
3320 | mLastSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 3320 | mLastSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
3321 | 3321 | ||
3322 | 3322 | ||
3323 | syncItemLocal->lastSyncDate = mLastSync; | 3323 | syncItemLocal->lastSyncDate = mLastSync; |
3324 | syncItemRemote->lastSyncDate = mLastSync; | 3324 | syncItemRemote->lastSyncDate = mLastSync; |
3325 | 3325 | ||
3326 | QString mes; | 3326 | QString mes; |
3327 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedPasswordsLocal, addedPasswordsRemote, changedLocal, changedRemote, deletedPasswordsLocal, deletedPasswordsRemote ); | 3327 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedPasswordsLocal, addedPasswordsRemote, changedLocal, changedRemote, deletedPasswordsLocal, deletedPasswordsRemote ); |
3328 | if ( manager->mShowSyncSummary ) { | 3328 | if ( manager->mShowSyncSummary ) { |
3329 | KMessageBox::information(0, mes, i18n("PWM/Pi Synchronization") ); | 3329 | KMessageBox::information(0, mes, i18n("PWM/Pi Synchronization") ); |
3330 | } | 3330 | } |
3331 | qDebug( mes ); | 3331 | qDebug( mes ); |
3332 | return e_success; | 3332 | return e_success; |
3333 | } | 3333 | } |
3334 | 3334 | ||
3335 | 3335 | ||
3336 | int PwMDoc::takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full ) | 3336 | int PwMDoc::takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full ) |
3337 | { | 3337 | { |
3338 | // 0 equal | 3338 | // 0 equal |
3339 | // 1 take local | 3339 | // 1 take local |
3340 | // 2 take remote | 3340 | // 2 take remote |
3341 | // 3 cancel | 3341 | // 3 cancel |
3342 | QDateTime localMod = local->meta.update; | 3342 | QDateTime localMod = local->meta.update; |
3343 | QDateTime remoteMod = remote->meta.update; | 3343 | QDateTime remoteMod = remote->meta.update; |
3344 | 3344 | ||
3345 | if ( localMod == remoteMod ) | 3345 | if ( localMod == remoteMod ) |
3346 | return 0; | 3346 | return 0; |
3347 | 3347 | ||
3348 | qDebug(" %d %d conflict on %s %s ", mode, full, local->desc.c_str(), remote->desc.c_str() ); | 3348 | qDebug(" %d %d conflict on %s %s ", mode, full, local->desc.c_str(), remote->desc.c_str() ); |
3349 | 3349 | ||
3350 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); | 3350 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); |
3351 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 3351 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
3352 | //full = true; //debug only | 3352 | //full = true; //debug only |
3353 | if ( full ) { | 3353 | if ( full ) { |
3354 | bool equ = ( (*local) == (*remote) ); | 3354 | bool equ = ( (*local) == (*remote) ); |
3355 | if ( equ ) { | 3355 | if ( equ ) { |
3356 | //qDebug("equal "); | 3356 | //qDebug("equal "); |
3357 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 3357 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
3358 | return 0; | 3358 | return 0; |
3359 | 3359 | ||
3360 | }//else //debug only | 3360 | }//else //debug only |
3361 | //qDebug("not equal %s %s ", local->desc.c_str(), remote->desc.c_str()); | 3361 | //qDebug("not equal %s %s ", local->desc.c_str(), remote->desc.c_str()); |
3362 | } | 3362 | } |
3363 | 3363 | ||
3364 | int result; | 3364 | int result; |
3365 | bool localIsNew; | 3365 | bool localIsNew; |
3366 | //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() ); | 3366 | //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() ); |
3367 | 3367 | ||
3368 | if ( full && mode < SYNC_PREF_NEWEST ) | 3368 | if ( full && mode < SYNC_PREF_NEWEST ) |
3369 | mode = SYNC_PREF_ASK; | 3369 | mode = SYNC_PREF_ASK; |
3370 | 3370 | ||
3371 | switch( mode ) { | 3371 | switch( mode ) { |
3372 | case SYNC_PREF_LOCAL: | 3372 | case SYNC_PREF_LOCAL: |
3373 | if ( lastSync > remoteMod ) | 3373 | if ( lastSync > remoteMod ) |
3374 | return 1; | 3374 | return 1; |
3375 | if ( lastSync > localMod ) | 3375 | if ( lastSync > localMod ) |
3376 | return 2; | 3376 | return 2; |
3377 | return 1; | 3377 | return 1; |
3378 | break; | 3378 | break; |
3379 | case SYNC_PREF_REMOTE: | 3379 | case SYNC_PREF_REMOTE: |
3380 | if ( lastSync > remoteMod ) | 3380 | if ( lastSync > remoteMod ) |
3381 | return 1; | 3381 | return 1; |
3382 | if ( lastSync > localMod ) | 3382 | if ( lastSync > localMod ) |
3383 | return 2; | 3383 | return 2; |
3384 | return 2; | 3384 | return 2; |
3385 | break; | 3385 | break; |
3386 | case SYNC_PREF_NEWEST: | 3386 | case SYNC_PREF_NEWEST: |
3387 | if ( localMod > remoteMod ) | 3387 | if ( localMod > remoteMod ) |
3388 | return 1; | 3388 | return 1; |
3389 | else | 3389 | else |
3390 | return 2; | 3390 | return 2; |
3391 | break; | 3391 | break; |
3392 | case SYNC_PREF_ASK: | 3392 | case SYNC_PREF_ASK: |
3393 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 3393 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
3394 | if ( lastSync > remoteMod ) | 3394 | if ( lastSync > remoteMod ) |
3395 | return 1; | 3395 | return 1; |
3396 | if ( lastSync > localMod ) | 3396 | if ( lastSync > localMod ) |
3397 | return 2; | 3397 | return 2; |
3398 | localIsNew = localMod >= remoteMod; | 3398 | localIsNew = localMod >= remoteMod; |
3399 | //qDebug("conflict! ************************************** "); | 3399 | //qDebug("conflict! ************************************** "); |
3400 | { | 3400 | { |
3401 | PwMDataItemChooser acd ( *local,*remote, localIsNew , 0/*this*/ ); | 3401 | PwMDataItemChooser acd ( *local,*remote, localIsNew , 0/*this*/ ); |
3402 | result = acd.executeD(localIsNew); | 3402 | result = acd.executeD(localIsNew); |
3403 | return result; | 3403 | return result; |
3404 | } | 3404 | } |
3405 | break; | 3405 | break; |
3406 | case SYNC_PREF_FORCE_LOCAL: | 3406 | case SYNC_PREF_FORCE_LOCAL: |
3407 | return 1; | 3407 | return 1; |
3408 | break; | 3408 | break; |
3409 | case SYNC_PREF_FORCE_REMOTE: | 3409 | case SYNC_PREF_FORCE_REMOTE: |
3410 | return 2; | 3410 | return 2; |
3411 | break; | 3411 | break; |
3412 | 3412 | ||
3413 | default: | 3413 | default: |
3414 | // SYNC_PREF_TAKE_BOTH not implemented | 3414 | // SYNC_PREF_TAKE_BOTH not implemented |
3415 | break; | 3415 | break; |
3416 | } | 3416 | } |
3417 | return 0; | 3417 | return 0; |
3418 | } | 3418 | } |
3419 | 3419 | ||
3420 | void PwMDoc::removeSyncInfo( QString syncProfile) | 3420 | void PwMDoc::removeSyncInfo( QString syncProfile) |
3421 | { | 3421 | { |
3422 | bool res, found; | 3422 | bool res, found; |
3423 | unsigned int count, i; | 3423 | unsigned int count, i; |
3424 | if ( syncProfile.isEmpty() ) { | 3424 | if ( syncProfile.isEmpty() ) { |
3425 | count = numSyncDataEntries(); | 3425 | count = numSyncDataEntries(); |
3426 | for (i = count; count > 0; count-- ) { | 3426 | for (i = count; count > 0; count-- ) { |
3427 | res = delSyncDataEntry(i-1, false); | 3427 | res = delSyncDataEntry(i-1, false); |
3428 | if (res == false) { | 3428 | if (res == false) { |
3429 | qDebug("PwMDoc::removeSyncInfo: could not remove syncprofile"); | 3429 | qDebug("PwMDoc::removeSyncInfo: could not remove syncprofile"); |
3430 | } | 3430 | } |
3431 | } | 3431 | } |
3432 | } else { | 3432 | } else { |
3433 | found = findSyncData(syncProfile, &count); | 3433 | found = findSyncData(syncProfile, &count); |
3434 | if (found == true) | 3434 | if (found == true) |
3435 | { | 3435 | { |
3436 | res = delSyncDataEntry(count, false); | 3436 | res = delSyncDataEntry(count, false); |
3437 | if (res == false) { | 3437 | if (res == false) { |
3438 | qDebug("PwMDoc::removeSyncInfo: could not remove %s", syncProfile.latin1()); | 3438 | qDebug("PwMDoc::removeSyncInfo: could not remove %s", syncProfile.latin1()); |
3439 | 3439 | ||
3440 | } | 3440 | } |
3441 | } | 3441 | } |
3442 | } | 3442 | } |
3443 | } | 3443 | } |
3444 | 3444 | ||
3445 | 3445 | ||
3446 | //this are the overwritten callbackmethods from the syncinterface | 3446 | //this are the overwritten callbackmethods from the syncinterface |
3447 | bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode) | 3447 | bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode, QString resource) |
3448 | { | 3448 | { |
3449 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3449 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3450 | 3450 | ||
3451 | //1) unlock local file first if necessary (ask for password) | 3451 | //1) unlock local file first if necessary (ask for password) |
3452 | if (this->isDeepLocked()) { | 3452 | if (this->isDeepLocked()) { |
3453 | PwMerror ret = this->deepLock(false); | 3453 | PwMerror ret = this->deepLock(false); |
3454 | if (ret != e_success) | 3454 | if (ret != e_success) |
3455 | return false; | 3455 | return false; |
3456 | } | 3456 | } |
3457 | 3457 | ||
3458 | //2) construct and open a new doc on the stack(automatic cleanup of remote file). | 3458 | //2) construct and open a new doc on the stack(automatic cleanup of remote file). |
3459 | PwMDoc syncTarget(this, "synctarget"); | 3459 | PwMDoc syncTarget(this, "synctarget"); |
3460 | PwMDoc* pSyncTarget = &syncTarget; | 3460 | PwMDoc* pSyncTarget = &syncTarget; |
3461 | 3461 | ||
3462 | 3462 | ||
3463 | PwMerror err = pSyncTarget->openDoc(&filename, 1 /*== open with all entries locked*/); | 3463 | PwMerror err = pSyncTarget->openDoc(&filename, 1 /*== open with all entries locked*/); |
3464 | 3464 | ||
3465 | if (err == e_alreadyOpen) { | 3465 | if (err == e_alreadyOpen) { |
3466 | PwMDocList::listItem li; | 3466 | PwMDocList::listItem li; |
3467 | if (getOpenDocList()->find(filename.latin1(), &li)) | 3467 | if (getOpenDocList()->find(filename.latin1(), &li)) |
3468 | pSyncTarget = li.doc; | 3468 | pSyncTarget = li.doc; |
3469 | else { | 3469 | else { |
3470 | qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); | 3470 | qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); |
3471 | return false; | 3471 | return false; |
3472 | } | 3472 | } |
3473 | } | 3473 | } |
3474 | else if (err != e_success) { | 3474 | else if (err != e_success) { |
3475 | qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); | 3475 | qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); |
3476 | return false; | 3476 | return false; |
3477 | } | 3477 | } |
3478 | 3478 | ||
3479 | qDebug("PWM file loaded %s,sync mode %d",filename.latin1(), mode ); | 3479 | qDebug("PWM file loaded %s,sync mode %d",filename.latin1(), mode ); |
3480 | 3480 | ||
3481 | 3481 | ||
3482 | //3) unlock remote file first if necessary (ask for password) | 3482 | //3) unlock remote file first if necessary (ask for password) |
3483 | if (pSyncTarget->isDeepLocked()) { | 3483 | if (pSyncTarget->isDeepLocked()) { |
3484 | PwMerror ret = pSyncTarget->deepLock(false); | 3484 | PwMerror ret = pSyncTarget->deepLock(false); |
3485 | if (ret != e_success) | 3485 | if (ret != e_success) |
3486 | return false; | 3486 | return false; |
3487 | } | 3487 | } |
3488 | 3488 | ||
3489 | 3489 | ||
3490 | err = syncronize(manager, this, pSyncTarget, mode ); | 3490 | err = syncronize(manager, this, pSyncTarget, mode ); |
3491 | 3491 | ||
3492 | if (err == e_success) { | 3492 | if (err == e_success) { |
3493 | if ( manager->mWriteBackFile ){ | 3493 | if ( manager->mWriteBackFile ){ |
3494 | qDebug("Saving remote PWManager file"); | 3494 | qDebug("Saving remote PWManager file"); |
3495 | err = pSyncTarget->saveDoc(conf()->confGlobCompression()); | 3495 | err = pSyncTarget->saveDoc(conf()->confGlobCompression()); |
3496 | if (err != e_success) { | 3496 | if (err != e_success) { |
3497 | qDebug("PwmDoc::sync: Sync failed. Error %i while storing file %s",err, filename.latin1()); | 3497 | qDebug("PwmDoc::sync: Sync failed. Error %i while storing file %s",err, filename.latin1()); |
3498 | return false; | 3498 | return false; |
3499 | } | 3499 | } |
3500 | } | 3500 | } |
3501 | 3501 | ||
3502 | flagDirty(); | 3502 | flagDirty(); |
3503 | return true; | 3503 | return true; |
3504 | } | 3504 | } |
3505 | else { | 3505 | else { |
3506 | return false; | 3506 | return false; |
3507 | } | 3507 | } |
3508 | } | 3508 | } |
3509 | 3509 | ||
3510 | #endif | 3510 | #endif |
3511 | 3511 | ||
3512 | 3512 | ||
3513 | bool PwMDoc::findSyncData(const QString &syncname, unsigned int *index) | 3513 | bool PwMDoc::findSyncData(const QString &syncname, unsigned int *index) |
3514 | { | 3514 | { |
3515 | vector<PwMSyncItem>::iterator i = dti.syncDta.begin(), | 3515 | vector<PwMSyncItem>::iterator i = dti.syncDta.begin(), |
3516 | end = dti.syncDta.end(); | 3516 | end = dti.syncDta.end(); |
3517 | 3517 | ||
3518 | while (i != end) { | 3518 | while (i != end) { |
3519 | if ((*i).syncName == syncname.latin1()) { | 3519 | if ((*i).syncName == syncname.latin1()) { |
3520 | if (index) { | 3520 | if (index) { |
3521 | *index = i - dti.syncDta.begin(); | 3521 | *index = i - dti.syncDta.begin(); |
3522 | } | 3522 | } |
3523 | return true; | 3523 | return true; |
3524 | } | 3524 | } |
3525 | ++i; | 3525 | ++i; |
3526 | } | 3526 | } |
3527 | return false; | 3527 | return false; |
3528 | }; | 3528 | }; |
3529 | 3529 | ||
3530 | /** add new syncdataentry */ | 3530 | /** add new syncdataentry */ |
3531 | PwMerror PwMDoc::addSyncDataEntry(PwMSyncItem *d, bool dontFlagDirty) | 3531 | PwMerror PwMDoc::addSyncDataEntry(PwMSyncItem *d, bool dontFlagDirty) |
3532 | { | 3532 | { |
3533 | PWM_ASSERT(d); | 3533 | PWM_ASSERT(d); |
3534 | 3534 | ||
3535 | if (isDeepLocked()) { | 3535 | if (isDeepLocked()) { |
3536 | PwMerror ret; | 3536 | PwMerror ret; |
3537 | ret = deepLock(false); | 3537 | ret = deepLock(false); |
3538 | if (ret != e_success) | 3538 | if (ret != e_success) |
3539 | return e_lock; | 3539 | return e_lock; |
3540 | } | 3540 | } |
3541 | unsigned int index; | 3541 | unsigned int index; |
3542 | 3542 | ||
3543 | const QString tmp = d->syncName.c_str(); | 3543 | const QString tmp = d->syncName.c_str(); |
3544 | bool exists = findSyncData(d->syncName.c_str(), &index); | 3544 | bool exists = findSyncData(d->syncName.c_str(), &index); |
3545 | 3545 | ||
3546 | if (exists == true) { | 3546 | if (exists == true) { |
3547 | // DOH! We found this entry. | 3547 | // DOH! We found this entry. |
3548 | return e_entryExists; | 3548 | return e_entryExists; |
3549 | } | 3549 | } |
3550 | 3550 | ||
3551 | dti.syncDta.push_back(*d); | 3551 | dti.syncDta.push_back(*d); |
3552 | 3552 | ||
3553 | if (!dontFlagDirty) | 3553 | if (!dontFlagDirty) |
3554 | flagDirty(); | 3554 | flagDirty(); |
3555 | return e_success; | 3555 | return e_success; |
3556 | } | 3556 | } |
3557 | 3557 | ||
3558 | 3558 | ||
3559 | 3559 | ||
3560 | /** delete syncdata entry */ | 3560 | /** delete syncdata entry */ |
3561 | bool PwMDoc::delSyncDataEntry(unsigned int index, bool dontFlagDirty) | 3561 | bool PwMDoc::delSyncDataEntry(unsigned int index, bool dontFlagDirty) |
3562 | { | 3562 | { |
3563 | if (isDeepLocked()) | 3563 | if (isDeepLocked()) |
3564 | return false; | 3564 | return false; |
3565 | if (index > dti.syncDta.size() - 1) | 3565 | if (index > dti.syncDta.size() - 1) |
3566 | return false; | 3566 | return false; |
3567 | 3567 | ||
3568 | // delete entry | 3568 | // delete entry |
3569 | dti.syncDta.erase(dti.syncDta.begin() + index); | 3569 | dti.syncDta.erase(dti.syncDta.begin() + index); |
3570 | 3570 | ||
3571 | if (!dontFlagDirty) | 3571 | if (!dontFlagDirty) |
3572 | flagDirty(); | 3572 | flagDirty(); |
3573 | return true; | 3573 | return true; |
3574 | } | 3574 | } |
3575 | 3575 | ||
3576 | 3576 | ||
3577 | PwMDataItem* PwMDoc::findEntryByID(const QString &uid, unsigned int *category, unsigned int *index) | 3577 | PwMDataItem* PwMDoc::findEntryByID(const QString &uid, unsigned int *category, unsigned int *index) |
3578 | { | 3578 | { |
3579 | vector<PwMCategoryItem>::iterator catcounter = dti.dta.begin(), | 3579 | vector<PwMCategoryItem>::iterator catcounter = dti.dta.begin(), |
3580 | catend = dti.dta.end(); | 3580 | catend = dti.dta.end(); |
3581 | 3581 | ||
3582 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; | 3582 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; |
3583 | 3583 | ||
3584 | while (catcounter != catend) { | 3584 | while (catcounter != catend) { |
3585 | entrBegin = catcounter->d.begin(); | 3585 | entrBegin = catcounter->d.begin(); |
3586 | entrEnd = catcounter->d.end(); | 3586 | entrEnd = catcounter->d.end(); |
3587 | entrI = entrBegin; | 3587 | entrI = entrBegin; |
3588 | while (entrI != entrEnd) { | 3588 | while (entrI != entrEnd) { |
3589 | if ((*entrI).meta.uniqueid == uid.latin1()) { | 3589 | if ((*entrI).meta.uniqueid == uid.latin1()) { |
3590 | if (category) | 3590 | if (category) |
3591 | *category = catcounter - dti.dta.begin(); | 3591 | *category = catcounter - dti.dta.begin(); |
3592 | if (index) | 3592 | if (index) |
3593 | *index = entrI - entrBegin; | 3593 | *index = entrI - entrBegin; |
3594 | 3594 | ||
3595 | return &(*entrI); | 3595 | return &(*entrI); |
3596 | } | 3596 | } |
3597 | ++entrI; | 3597 | ++entrI; |
3598 | } | 3598 | } |
3599 | ++catcounter; | 3599 | ++catcounter; |
3600 | } | 3600 | } |
3601 | 3601 | ||
3602 | return 0; | 3602 | return 0; |
3603 | } | 3603 | } |
3604 | 3604 | ||
3605 | QStringList PwMDoc::getIDEntryList() | 3605 | QStringList PwMDoc::getIDEntryList() |
3606 | { | 3606 | { |
3607 | QStringList results; | 3607 | QStringList results; |
3608 | 3608 | ||
3609 | vector<PwMCategoryItem>::iterator catcounter = dti.dta.begin(), | 3609 | vector<PwMCategoryItem>::iterator catcounter = dti.dta.begin(), |
3610 | catend = dti.dta.end(); | 3610 | catend = dti.dta.end(); |
3611 | 3611 | ||
3612 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; | 3612 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; |
3613 | 3613 | ||
3614 | while (catcounter != catend) { | 3614 | while (catcounter != catend) { |
3615 | entrBegin = catcounter->d.begin(); | 3615 | entrBegin = catcounter->d.begin(); |
3616 | entrEnd = catcounter->d.end(); | 3616 | entrEnd = catcounter->d.end(); |
3617 | entrI = entrBegin; | 3617 | entrI = entrBegin; |
3618 | while (entrI != entrEnd) { | 3618 | while (entrI != entrEnd) { |
3619 | results.append( (*entrI).meta.uniqueid.c_str() ); | 3619 | results.append( (*entrI).meta.uniqueid.c_str() ); |
3620 | ++entrI; | 3620 | ++entrI; |
3621 | } | 3621 | } |
3622 | ++catcounter; | 3622 | ++catcounter; |
3623 | } | 3623 | } |
3624 | 3624 | ||
3625 | return results; | 3625 | return results; |
3626 | } | 3626 | } |
3627 | 3627 | ||
3628 | 3628 | ||
3629 | 3629 | ||
3630 | 3630 | ||
3631 | 3631 | ||
3632 | #ifndef PWM_EMBEDDED | 3632 | #ifndef PWM_EMBEDDED |
3633 | #include "pwmdoc.moc" | 3633 | #include "pwmdoc.moc" |
3634 | #endif | 3634 | #endif |
diff --git a/pwmanager/pwmanager/pwmdoc.h b/pwmanager/pwmanager/pwmdoc.h index 45dd729..144831f 100644 --- a/pwmanager/pwmanager/pwmdoc.h +++ b/pwmanager/pwmanager/pwmdoc.h | |||
@@ -287,547 +287,547 @@ struct PwMItem | |||
287 | vector<PwMSyncItem> syncDta; | 287 | vector<PwMSyncItem> syncDta; |
288 | 288 | ||
289 | void clear() | 289 | void clear() |
290 | { | 290 | { |
291 | dta.clear(); | 291 | dta.clear(); |
292 | syncDta.clear(); | 292 | syncDta.clear(); |
293 | } | 293 | } |
294 | }; | 294 | }; |
295 | 295 | ||
296 | 296 | ||
297 | /** "Function Object" for sort()ing PwMDataItem::listViewPos */ | 297 | /** "Function Object" for sort()ing PwMDataItem::listViewPos */ |
298 | class dta_lvp_greater | 298 | class dta_lvp_greater |
299 | { | 299 | { |
300 | public: | 300 | public: |
301 | bool operator() (const pair<unsigned int, unsigned int> &d1, | 301 | bool operator() (const pair<unsigned int, unsigned int> &d1, |
302 | const pair<unsigned int, unsigned int> &d2) | 302 | const pair<unsigned int, unsigned int> &d2) |
303 | { | 303 | { |
304 | return d1.second > d2.second; | 304 | return d1.second > d2.second; |
305 | } | 305 | } |
306 | }; | 306 | }; |
307 | 307 | ||
308 | /** list of PwMDoc documents and it's IDs */ | 308 | /** list of PwMDoc documents and it's IDs */ |
309 | class PwMDocList | 309 | class PwMDocList |
310 | { | 310 | { |
311 | public: | 311 | public: |
312 | struct listItem | 312 | struct listItem |
313 | { | 313 | { |
314 | /** document filename (known as ID, here) */ | 314 | /** document filename (known as ID, here) */ |
315 | string docId; | 315 | string docId; |
316 | /** pointer to the document class */ | 316 | /** pointer to the document class */ |
317 | PwMDoc *doc; | 317 | PwMDoc *doc; |
318 | }; | 318 | }; |
319 | 319 | ||
320 | PwMDocList() {} | 320 | PwMDocList() {} |
321 | 321 | ||
322 | /** add a new item to the list */ | 322 | /** add a new item to the list */ |
323 | void add(PwMDoc *doc, const string &id); | 323 | void add(PwMDoc *doc, const string &id); |
324 | /** changes the contents of an existing item */ | 324 | /** changes the contents of an existing item */ |
325 | void edit(PwMDoc *doc, const string &newId); | 325 | void edit(PwMDoc *doc, const string &newId); |
326 | /** remove the given item */ | 326 | /** remove the given item */ |
327 | void del(PwMDoc *doc); | 327 | void del(PwMDoc *doc); |
328 | /** get the item at index */ | 328 | /** get the item at index */ |
329 | listItem getAt(int index) | 329 | listItem getAt(int index) |
330 | { return docList[index]; } | 330 | { return docList[index]; } |
331 | /** find an entry with this id */ | 331 | /** find an entry with this id */ |
332 | bool find(const string &id, listItem *ret = 0); | 332 | bool find(const string &id, listItem *ret = 0); |
333 | /** returns a copy of the list */ | 333 | /** returns a copy of the list */ |
334 | const vector<listItem>* getList() const | 334 | const vector<listItem>* getList() const |
335 | { return &docList; } | 335 | { return &docList; } |
336 | 336 | ||
337 | 337 | ||
338 | /** returns a new unique number to extend the name of | 338 | /** returns a new unique number to extend the name of |
339 | * an unnamed document. | 339 | * an unnamed document. |
340 | */ | 340 | */ |
341 | static unsigned int getNewUnnamedNumber() | 341 | static unsigned int getNewUnnamedNumber() |
342 | { return unnamedDocCnt++; } | 342 | { return unnamedDocCnt++; } |
343 | 343 | ||
344 | protected: | 344 | protected: |
345 | /* Hm, I think we shouldn't really use a "list" here, should we? | 345 | /* Hm, I think we shouldn't really use a "list" here, should we? |
346 | * So I decided to actually use a vector. | 346 | * So I decided to actually use a vector. |
347 | */ | 347 | */ |
348 | vector<listItem> docList; | 348 | vector<listItem> docList; |
349 | /** This value is used to get a new number for yet unnamed | 349 | /** This value is used to get a new number for yet unnamed |
350 | * documents. It is incremented on every request. So it's | 350 | * documents. It is incremented on every request. So it's |
351 | * theoretically possible to overflow it, but... :) | 351 | * theoretically possible to overflow it, but... :) |
352 | */ | 352 | */ |
353 | static unsigned int unnamedDocCnt; | 353 | static unsigned int unnamedDocCnt; |
354 | }; | 354 | }; |
355 | 355 | ||
356 | /** implements timers for the document */ | 356 | /** implements timers for the document */ |
357 | class DocTimer : public QObject | 357 | class DocTimer : public QObject |
358 | { | 358 | { |
359 | Q_OBJECT | 359 | Q_OBJECT |
360 | public: | 360 | public: |
361 | enum TimerIDs | 361 | enum TimerIDs |
362 | { | 362 | { |
363 | id_mpwTimer, | 363 | id_mpwTimer, |
364 | id_autoLockTimer, | 364 | id_autoLockTimer, |
365 | id_metaCheckTimer | 365 | id_metaCheckTimer |
366 | }; | 366 | }; |
367 | 367 | ||
368 | public: | 368 | public: |
369 | DocTimer(PwMDoc *_doc); | 369 | DocTimer(PwMDoc *_doc); |
370 | ~DocTimer(); | 370 | ~DocTimer(); |
371 | 371 | ||
372 | /** start the timer */ | 372 | /** start the timer */ |
373 | void start(TimerIDs timer); | 373 | void start(TimerIDs timer); |
374 | /** stop the timer */ | 374 | /** stop the timer */ |
375 | void stop(TimerIDs timer); | 375 | void stop(TimerIDs timer); |
376 | /** get the lock for a timer. | 376 | /** get the lock for a timer. |
377 | * This lock is a recursive lock. When a lock is | 377 | * This lock is a recursive lock. When a lock is |
378 | * held, the timer will be stopped and timeout is | 378 | * held, the timer will be stopped and timeout is |
379 | * guaranteed to not happen | 379 | * guaranteed to not happen |
380 | */ | 380 | */ |
381 | void getLock(TimerIDs timer); | 381 | void getLock(TimerIDs timer); |
382 | /** put a recursive timer lock */ | 382 | /** put a recursive timer lock */ |
383 | void putLock(TimerIDs timer); | 383 | void putLock(TimerIDs timer); |
384 | 384 | ||
385 | protected slots: | 385 | protected slots: |
386 | /** timeout slot for the mpw timer */ | 386 | /** timeout slot for the mpw timer */ |
387 | void mpwTimeout(); | 387 | void mpwTimeout(); |
388 | /** timeout slot for the autoLock timer */ | 388 | /** timeout slot for the autoLock timer */ |
389 | void autoLockTimeout(); | 389 | void autoLockTimeout(); |
390 | /** timeout slot for the metaCheck timer */ | 390 | /** timeout slot for the metaCheck timer */ |
391 | void metaCheckTimeout(); | 391 | void metaCheckTimeout(); |
392 | 392 | ||
393 | protected: | 393 | protected: |
394 | /** pointer to the document associated with this timer. */ | 394 | /** pointer to the document associated with this timer. */ |
395 | PwMDoc *doc; | 395 | PwMDoc *doc; |
396 | /** timer object for mpw timer */ | 396 | /** timer object for mpw timer */ |
397 | QTimer *mpwTimer; | 397 | QTimer *mpwTimer; |
398 | /** timer object for the autoLock timer */ | 398 | /** timer object for the autoLock timer */ |
399 | QTimer *autoLockTimer; | 399 | QTimer *autoLockTimer; |
400 | /** timer object for the metaCheck timer */ | 400 | /** timer object for the metaCheck timer */ |
401 | QTimer *metaCheckTimer; | 401 | QTimer *metaCheckTimer; |
402 | /** lock counter for the mpw timer */ | 402 | /** lock counter for the mpw timer */ |
403 | unsigned int mpwLock; | 403 | unsigned int mpwLock; |
404 | /** lock counter for the autoLock timer */ | 404 | /** lock counter for the autoLock timer */ |
405 | unsigned int autoLockLock; | 405 | unsigned int autoLockLock; |
406 | /** lock counter for the metaCheck timer */ | 406 | /** lock counter for the metaCheck timer */ |
407 | unsigned int metaCheckLock; | 407 | unsigned int metaCheckLock; |
408 | }; | 408 | }; |
409 | 409 | ||
410 | /** Document class for PwM */ | 410 | /** Document class for PwM */ |
411 | //US ENH: derived from KSyncInterfaces, to get called by PwM when a sync is required. | 411 | //US ENH: derived from KSyncInterfaces, to get called by PwM when a sync is required. |
412 | // But PwMDoc is handling the sync by itself. | 412 | // But PwMDoc is handling the sync by itself. |
413 | class PwMDoc : public PwMDocUi, public KSyncInterface | 413 | class PwMDoc : public PwMDocUi, public KSyncInterface |
414 | 414 | ||
415 | { | 415 | { |
416 | Q_OBJECT | 416 | Q_OBJECT |
417 | friend class DocTimer; | 417 | friend class DocTimer; |
418 | 418 | ||
419 | public: | 419 | public: |
420 | /** construtor */ | 420 | /** construtor */ |
421 | PwMDoc(QObject* parent = 0, const char *name = 0); | 421 | PwMDoc(QObject* parent = 0, const char *name = 0); |
422 | /** destructor */ | 422 | /** destructor */ |
423 | ~PwMDoc(); | 423 | ~PwMDoc(); |
424 | 424 | ||
425 | /** returns a pointer to a list of all open documents */ | 425 | /** returns a pointer to a list of all open documents */ |
426 | static PwMDocList* getOpenDocList() | 426 | static PwMDocList* getOpenDocList() |
427 | { return &openDocList; } | 427 | { return &openDocList; } |
428 | 428 | ||
429 | /** flag document dirty. dta changed */ | 429 | /** flag document dirty. dta changed */ |
430 | void flagDirty() | 430 | void flagDirty() |
431 | { | 431 | { |
432 | setDocStatFlag(DOC_STAT_DISK_DIRTY); | 432 | setDocStatFlag(DOC_STAT_DISK_DIRTY); |
433 | emitDataChanged(this); | 433 | emitDataChanged(this); |
434 | } | 434 | } |
435 | /** modified? */ | 435 | /** modified? */ |
436 | bool isDirty() | 436 | bool isDirty() |
437 | { return getDocStatFlag(DOC_STAT_DISK_DIRTY); } | 437 | { return getDocStatFlag(DOC_STAT_DISK_DIRTY); } |
438 | /** save document to disk */ | 438 | /** save document to disk */ |
439 | PwMerror saveDoc(char compress, const QString *file = 0); | 439 | PwMerror saveDoc(char compress, const QString *file = 0); |
440 | /** read document from file. | 440 | /** read document from file. |
441 | * "openLocked is must be set to either of these values: | 441 | * "openLocked is must be set to either of these values: |
442 | * 0 == open with all entries unlocked | 442 | * 0 == open with all entries unlocked |
443 | * 1 == open with all entries locked | 443 | * 1 == open with all entries locked |
444 | * 2 == open deep-locked | 444 | * 2 == open deep-locked |
445 | */ | 445 | */ |
446 | PwMerror openDoc(const QString *file, int openLocked); | 446 | PwMerror openDoc(const QString *file, int openLocked); |
447 | /** export document to ascii-textfile */ | 447 | /** export document to ascii-textfile */ |
448 | PwMerror exportToText(const QString *file); | 448 | PwMerror exportToText(const QString *file); |
449 | /** export document to gpasman / kpasman file */ | 449 | /** export document to gpasman / kpasman file */ |
450 | PwMerror exportToGpasman(const QString *file); | 450 | PwMerror exportToGpasman(const QString *file); |
451 | /** import document from ascii-textfile */ | 451 | /** import document from ascii-textfile */ |
452 | PwMerror importFromText(const QString *file, int format = -1); | 452 | PwMerror importFromText(const QString *file, int format = -1); |
453 | /** import document from gpasman / kpasman file */ | 453 | /** import document from gpasman / kpasman file */ |
454 | PwMerror importFromGpasman(const QString *file); | 454 | PwMerror importFromGpasman(const QString *file); |
455 | /** add new entry */ | 455 | /** add new entry */ |
456 | PwMerror addEntry(const QString &category, PwMDataItem *d, | 456 | PwMerror addEntry(const QString &category, PwMDataItem *d, |
457 | bool dontFlagDirty = false, bool updateMeta = true); | 457 | bool dontFlagDirty = false, bool updateMeta = true); |
458 | /** add new category. This function doesn't flag the document dirty! */ | 458 | /** add new category. This function doesn't flag the document dirty! */ |
459 | PwMerror addCategory(const QString &category, unsigned int *categoryIndex, | 459 | PwMerror addCategory(const QString &category, unsigned int *categoryIndex, |
460 | bool checkIfExist = true); | 460 | bool checkIfExist = true); |
461 | /** rename an existing category */ | 461 | /** rename an existing category */ |
462 | bool renameCategory(const QString &category, const QString &newName); | 462 | bool renameCategory(const QString &category, const QString &newName); |
463 | /** rename an existing category */ | 463 | /** rename an existing category */ |
464 | bool renameCategory(unsigned int category, const QString &newName, | 464 | bool renameCategory(unsigned int category, const QString &newName, |
465 | bool dontFlagDirty = false); | 465 | bool dontFlagDirty = false); |
466 | /** delete an existing category */ | 466 | /** delete an existing category */ |
467 | bool delCategory(const QString &category); | 467 | bool delCategory(const QString &category); |
468 | /** delete an existing category */ | 468 | /** delete an existing category */ |
469 | bool delCategory(unsigned int category, bool dontFlagDirty = false); | 469 | bool delCategory(unsigned int category, bool dontFlagDirty = false); |
470 | /** returns a list of all category-names */ | 470 | /** returns a list of all category-names */ |
471 | void getCategoryList(vector<string> *list); | 471 | void getCategoryList(vector<string> *list); |
472 | /** returns a list of all category-names */ | 472 | /** returns a list of all category-names */ |
473 | void getCategoryList(QStringList *list); | 473 | void getCategoryList(QStringList *list); |
474 | /** returns a list of all entry-descs in the given category */ | 474 | /** returns a list of all entry-descs in the given category */ |
475 | void getEntryList(const QString &category, QStringList *list); | 475 | void getEntryList(const QString &category, QStringList *list); |
476 | /** returns a list of all entry-descs in the given category */ | 476 | /** returns a list of all entry-descs in the given category */ |
477 | void getEntryList(const QString &category, vector<string> *list); | 477 | void getEntryList(const QString &category, vector<string> *list); |
478 | /** returns a list of all entry-descs in the given category */ | 478 | /** returns a list of all entry-descs in the given category */ |
479 | void getEntryList(unsigned int category, vector<string> *list); | 479 | void getEntryList(unsigned int category, vector<string> *list); |
480 | /** returns a list of all entry-descs in the given category */ | 480 | /** returns a list of all entry-descs in the given category */ |
481 | void getEntryList(unsigned int category, QStringList *list); | 481 | void getEntryList(unsigned int category, QStringList *list); |
482 | /** delete entry */ | 482 | /** delete entry */ |
483 | bool delEntry(const QString &category, unsigned int index, bool dontFlagDirty = false); | 483 | bool delEntry(const QString &category, unsigned int index, bool dontFlagDirty = false); |
484 | /** delete entry */ | 484 | /** delete entry */ |
485 | bool delEntry(unsigned int category, unsigned int index, bool dontFlagDirty = false); | 485 | bool delEntry(unsigned int category, unsigned int index, bool dontFlagDirty = false); |
486 | /** edit entry */ | 486 | /** edit entry */ |
487 | bool editEntry(const QString &oldCategory, const QString &newCategory, | 487 | bool editEntry(const QString &oldCategory, const QString &newCategory, |
488 | unsigned int index, PwMDataItem *d, bool updateMeta = true); | 488 | unsigned int index, PwMDataItem *d, bool updateMeta = true); |
489 | /** edit entry */ | 489 | /** edit entry */ |
490 | bool editEntry(unsigned int oldCategory, const QString &newCategory, | 490 | bool editEntry(unsigned int oldCategory, const QString &newCategory, |
491 | unsigned int index, PwMDataItem *d, bool updateMeta = true); | 491 | unsigned int index, PwMDataItem *d, bool updateMeta = true); |
492 | /** finds the category with the "name" and return it's index */ | 492 | /** finds the category with the "name" and return it's index */ |
493 | bool findCategory(const QString &name, unsigned int *index); | 493 | bool findCategory(const QString &name, unsigned int *index); |
494 | /** search for an entry "find" and check while searching only for | 494 | /** search for an entry "find" and check while searching only for |
495 | * the data-fields specified by "searchIn". To set the "searchIn" | 495 | * the data-fields specified by "searchIn". To set the "searchIn" |
496 | * value, we may use one or more of the SEARCH_IN_* defines at | 496 | * value, we may use one or more of the SEARCH_IN_* defines at |
497 | * the top of this header-file. It returns the positions of all | 497 | * the top of this header-file. It returns the positions of all |
498 | * matched entries in "foundPositions". If "breakAfterFound" is true, | 498 | * matched entries in "foundPositions". If "breakAfterFound" is true, |
499 | * the function terminates after the first occurence of the entry | 499 | * the function terminates after the first occurence of the entry |
500 | * and doesn't go on searching. So foundPositions->size() is never | 500 | * and doesn't go on searching. So foundPositions->size() is never |
501 | * > 1 if breakAfterFound is true. | 501 | * > 1 if breakAfterFound is true. |
502 | */ | 502 | */ |
503 | void findEntry(unsigned int category, PwMDataItem find, unsigned int searchIn, | 503 | void findEntry(unsigned int category, PwMDataItem find, unsigned int searchIn, |
504 | vector<unsigned int> *foundPositions, bool breakAfterFound = false, | 504 | vector<unsigned int> *foundPositions, bool breakAfterFound = false, |
505 | bool caseSensitive = true, bool exactWordMatch = true, | 505 | bool caseSensitive = true, bool exactWordMatch = true, |
506 | bool sortByLvp = false); | 506 | bool sortByLvp = false); |
507 | /** see the above funtion. This function allows to set the category by name. */ | 507 | /** see the above funtion. This function allows to set the category by name. */ |
508 | void findEntry(const QString &category, PwMDataItem find, unsigned int searchIn, | 508 | void findEntry(const QString &category, PwMDataItem find, unsigned int searchIn, |
509 | vector<unsigned int> *foundPositions, bool breakAfterFound = false, | 509 | vector<unsigned int> *foundPositions, bool breakAfterFound = false, |
510 | bool caseSensitive = true, bool exactWordMatch = true, | 510 | bool caseSensitive = true, bool exactWordMatch = true, |
511 | bool sortByLvp = false); | 511 | bool sortByLvp = false); |
512 | /** returns number of entries */ | 512 | /** returns number of entries */ |
513 | unsigned int numEntries(const QString &category); | 513 | unsigned int numEntries(const QString &category); |
514 | unsigned int numEntries(unsigned int category) | 514 | unsigned int numEntries(unsigned int category) |
515 | { return dti.dta[category].d.size(); } | 515 | { return dti.dta[category].d.size(); } |
516 | /** returns number of categories */ | 516 | /** returns number of categories */ |
517 | unsigned int numCategories() | 517 | unsigned int numCategories() |
518 | { return dti.dta.size(); } | 518 | { return dti.dta.size(); } |
519 | /** returns the name of the category at "index" */ | 519 | /** returns the name of the category at "index" */ |
520 | const string* getCategory(unsigned int index) | 520 | const string* getCategory(unsigned int index) |
521 | { return (&(dti.dta[index].name)); } | 521 | { return (&(dti.dta[index].name)); } |
522 | 522 | ||
523 | /** returns the data of item at "index". | 523 | /** returns the data of item at "index". |
524 | * It unlocks the entry if it's locked and unlockIfLocked is true. | 524 | * It unlocks the entry if it's locked and unlockIfLocked is true. |
525 | * If the entry is locked, but unlockIfLocked is false, it'll not return | 525 | * If the entry is locked, but unlockIfLocked is false, it'll not return |
526 | * the pw. | 526 | * the pw. |
527 | */ | 527 | */ |
528 | bool getEntry(const QString &category, unsigned int index, | 528 | bool getEntry(const QString &category, unsigned int index, |
529 | PwMDataItem *d, bool unlockIfLocked = false); | 529 | PwMDataItem *d, bool unlockIfLocked = false); |
530 | bool getEntry(unsigned int category, unsigned int index, | 530 | bool getEntry(unsigned int category, unsigned int index, |
531 | PwMDataItem *d, bool unlockIfLocked = false); | 531 | PwMDataItem *d, bool unlockIfLocked = false); |
532 | /** returns the comment-string by looking at the category | 532 | /** returns the comment-string by looking at the category |
533 | * and the listViewPos | 533 | * and the listViewPos |
534 | */ | 534 | */ |
535 | PwMerror getCommentByLvp(const QString &category, int listViewPos, | 535 | PwMerror getCommentByLvp(const QString &category, int listViewPos, |
536 | string *foundComment); | 536 | string *foundComment); |
537 | PwMerror getCommentByLvp_long(const QString &category, int listViewPos, | 537 | PwMerror getCommentByLvp_long(const QString &category, int listViewPos, |
538 | string *foundComment); | 538 | string *foundComment); |
539 | /** checks if a password is already available. (currentPw) */ | 539 | /** checks if a password is already available. (currentPw) */ |
540 | bool isPwAvailable() | 540 | bool isPwAvailable() |
541 | { return (currentPw != ""); } | 541 | { return (currentPw != ""); } |
542 | /** un/lock entry at "index". If needed, ask for password. */ | 542 | /** un/lock entry at "index". If needed, ask for password. */ |
543 | bool lockAt(const QString &category, unsigned int index, | 543 | bool lockAt(const QString &category, unsigned int index, |
544 | bool lock = true); | 544 | bool lock = true); |
545 | bool lockAt(unsigned int category, unsigned int index, | 545 | bool lockAt(unsigned int category, unsigned int index, |
546 | bool lock = true); | 546 | bool lock = true); |
547 | /** returns the lock-status at "index" */ | 547 | /** returns the lock-status at "index" */ |
548 | bool isLocked(const QString &category, unsigned int index); | 548 | bool isLocked(const QString &category, unsigned int index); |
549 | bool isLocked(unsigned int category, unsigned int index) | 549 | bool isLocked(unsigned int category, unsigned int index) |
550 | { return dti.dta[category].d[index].lockStat; } | 550 | { return dti.dta[category].d[index].lockStat; } |
551 | /** returns the deeplock status */ | 551 | /** returns the deeplock status */ |
552 | bool isDeepLocked() | 552 | bool isDeepLocked() |
553 | { return getDocStatFlag(DOC_STAT_DEEPLOCKED); } | 553 | { return getDocStatFlag(DOC_STAT_DEEPLOCKED); } |
554 | /** (un)lock all entries */ | 554 | /** (un)lock all entries */ |
555 | bool lockAll(bool lock); | 555 | bool lockAll(bool lock); |
556 | /** unlocks all entries tempoarly. | 556 | /** unlocks all entries tempoarly. |
557 | * 1st NOTE: Be very careful with this function! :) | 557 | * 1st NOTE: Be very careful with this function! :) |
558 | * 2nd NOTE: After you have called unlockAll_Tempoary(); , | 558 | * 2nd NOTE: After you have called unlockAll_Tempoary(); , |
559 | * please DON'T forget to call unlockAll_Tempoary(true); | 559 | * please DON'T forget to call unlockAll_Tempoary(true); |
560 | * _before_ the user (or someone else) is able to change | 560 | * _before_ the user (or someone else) is able to change |
561 | * the document! | 561 | * the document! |
562 | * 3rd NOTE: Please DON'T change "dta" while the data is tempoary | 562 | * 3rd NOTE: Please DON'T change "dta" while the data is tempoary |
563 | * unlocked! This will cause corruption. | 563 | * unlocked! This will cause corruption. |
564 | */ | 564 | */ |
565 | bool unlockAll_tempoary(bool revert = false); | 565 | bool unlockAll_tempoary(bool revert = false); |
566 | /** deep-(un)locks the document. | 566 | /** deep-(un)locks the document. |
567 | * deep-locking writes all data to the file, deletes all data | 567 | * deep-locking writes all data to the file, deletes all data |
568 | * in memory, but doesn't close the document. | 568 | * in memory, but doesn't close the document. |
569 | * deep-locking is only available, if the user previously saved | 569 | * deep-locking is only available, if the user previously saved |
570 | * the doc to a file (with a password). | 570 | * the doc to a file (with a password). |
571 | * If "saveToFile" is false, it does NOT write the data to the file! | 571 | * If "saveToFile" is false, it does NOT write the data to the file! |
572 | */ | 572 | */ |
573 | PwMerror deepLock(bool lock = true, bool saveToFile = true); | 573 | PwMerror deepLock(bool lock = true, bool saveToFile = true); |
574 | /** is unlockable without pw? */ | 574 | /** is unlockable without pw? */ |
575 | bool unlockWoPw() | 575 | bool unlockWoPw() |
576 | { return getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); } | 576 | { return getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); } |
577 | /** get the "currentPassword" */ | 577 | /** get the "currentPassword" */ |
578 | const QString& getCurrentPw() | 578 | const QString& getCurrentPw() |
579 | { return currentPw; } | 579 | { return currentPw; } |
580 | /** open a window and request the user to change the mpw */ | 580 | /** open a window and request the user to change the mpw */ |
581 | void changeCurrentPw(); | 581 | void changeCurrentPw(); |
582 | /** set the "listViewPos" variable of "dta" */ | 582 | /** set the "listViewPos" variable of "dta" */ |
583 | void setListViewPos(const QString &category, unsigned int index, | 583 | void setListViewPos(const QString &category, unsigned int index, |
584 | int pos); | 584 | int pos); |
585 | /** set the "listViewPos" variable of "dta" */ | 585 | /** set the "listViewPos" variable of "dta" */ |
586 | void setListViewPos(unsigned int category, unsigned int index, | 586 | void setListViewPos(unsigned int category, unsigned int index, |
587 | int pos); | 587 | int pos); |
588 | /** get the "listViewPos" variable of "dta" */ | 588 | /** get the "listViewPos" variable of "dta" */ |
589 | int getListViewPos(const QString &category, unsigned int index); | 589 | int getListViewPos(const QString &category, unsigned int index); |
590 | /** set the maximum number of entries allowed */ | 590 | /** set the maximum number of entries allowed */ |
591 | void setMaxNumEntries(unsigned int num = DEFAULT_MAX_ENTRIES) | 591 | void setMaxNumEntries(unsigned int num = DEFAULT_MAX_ENTRIES) |
592 | { maxEntries = num; } | 592 | { maxEntries = num; } |
593 | /** get the maximum number of entries allowed */ | 593 | /** get the maximum number of entries allowed */ |
594 | unsigned int getMaxNumEntries() | 594 | unsigned int getMaxNumEntries() |
595 | { return maxEntries; } | 595 | { return maxEntries; } |
596 | /** ensure all listViewPos of all dta items are set. (are ! -1). | 596 | /** ensure all listViewPos of all dta items are set. (are ! -1). |
597 | * If there are some undefined entries, add them to the end of | 597 | * If there are some undefined entries, add them to the end of |
598 | * the listViewPos(itions). */ | 598 | * the listViewPos(itions). */ |
599 | void ensureLvp(); | 599 | void ensureLvp(); |
600 | /** execute the "launcher" of this entry */ | 600 | /** execute the "launcher" of this entry */ |
601 | bool execLauncher(const QString &category, unsigned int entryIndex); | 601 | bool execLauncher(const QString &category, unsigned int entryIndex); |
602 | /** see above */ | 602 | /** see above */ |
603 | bool execLauncher(unsigned int category, unsigned int entryIndex); | 603 | bool execLauncher(unsigned int category, unsigned int entryIndex); |
604 | /** open a browser with the URL-section of the given entry */ | 604 | /** open a browser with the URL-section of the given entry */ |
605 | bool goToURL(const QString &category, unsigned int entryIndex); | 605 | bool goToURL(const QString &category, unsigned int entryIndex); |
606 | /** see above */ | 606 | /** see above */ |
607 | bool goToURL(unsigned int category, unsigned int entryIndex); | 607 | bool goToURL(unsigned int category, unsigned int entryIndex); |
608 | /** returns true if there is no entry present in the document. | 608 | /** returns true if there is no entry present in the document. |
609 | * Note: The "default" Category is present everytime, so | 609 | * Note: The "default" Category is present everytime, so |
610 | * it's checked for it's entries. | 610 | * it's checked for it's entries. |
611 | */ | 611 | */ |
612 | bool isDocEmpty() | 612 | bool isDocEmpty() |
613 | { | 613 | { |
614 | if (numCategories() > 1) | 614 | if (numCategories() > 1) |
615 | return false; | 615 | return false; |
616 | if (numEntries(0)) | 616 | if (numEntries(0)) |
617 | return false; | 617 | return false; |
618 | return true; | 618 | return true; |
619 | } | 619 | } |
620 | /** returns the filename of this doc */ | 620 | /** returns the filename of this doc */ |
621 | const QString& getFilename() | 621 | const QString& getFilename() |
622 | { return filename; } | 622 | { return filename; } |
623 | /** returns the title of the doc */ | 623 | /** returns the title of the doc */ |
624 | QString getTitle(); | 624 | QString getTitle(); |
625 | /** sets the list-view-pointer hold in the doc */ | 625 | /** sets the list-view-pointer hold in the doc */ |
626 | void setListViewPointer(PwMView *_listView) | 626 | void setListViewPointer(PwMView *_listView) |
627 | { listView = _listView; } | 627 | { listView = _listView; } |
628 | /** returns the list-view-pointer */ | 628 | /** returns the list-view-pointer */ |
629 | PwMView * getListViewPointer() | 629 | PwMView * getListViewPointer() |
630 | { return listView; } | 630 | { return listView; } |
631 | /** try to delete the doc. The user may be asked to save | 631 | /** try to delete the doc. The user may be asked to save |
632 | * the data. The user may cancel the whole operation. | 632 | * the data. The user may cancel the whole operation. |
633 | * false is returned, then. | 633 | * false is returned, then. |
634 | */ | 634 | */ |
635 | bool tryDelete(); | 635 | bool tryDelete(); |
636 | /** is the doc deleted? (with tryDelete() ) */ | 636 | /** is the doc deleted? (with tryDelete() ) */ |
637 | bool isDeleted() | 637 | bool isDeleted() |
638 | { return deleted; } | 638 | { return deleted; } |
639 | /** returns the document timer object */ | 639 | /** returns the document timer object */ |
640 | DocTimer * timer() | 640 | DocTimer * timer() |
641 | { return _timer; } | 641 | { return _timer; } |
642 | /** get a lock on the dataChanged signal. | 642 | /** get a lock on the dataChanged signal. |
643 | * If someone is holding a lock, the signal is not emitted. | 643 | * If someone is holding a lock, the signal is not emitted. |
644 | */ | 644 | */ |
645 | void getDataChangedLock() | 645 | void getDataChangedLock() |
646 | { ++dataChangedLock; } | 646 | { ++dataChangedLock; } |
647 | /** put the dataChanged lock */ | 647 | /** put the dataChanged lock */ |
648 | void putDataChangedLock() | 648 | void putDataChangedLock() |
649 | { --dataChangedLock; } | 649 | { --dataChangedLock; } |
650 | /** returns the revision count of the item at cat/index */ | 650 | /** returns the revision count of the item at cat/index */ |
651 | unsigned int getEntryRevCnt(unsigned int category, unsigned int index) | 651 | unsigned int getEntryRevCnt(unsigned int category, unsigned int index) |
652 | { return dti.dta[category].d[index].rev; } | 652 | { return dti.dta[category].d[index].rev; } |
653 | /** returns a const pointer to the entries meta */ | 653 | /** returns a const pointer to the entries meta */ |
654 | const PwMMetaData * getEntryMeta(unsigned int category, unsigned int index) | 654 | const PwMMetaData * getEntryMeta(unsigned int category, unsigned int index) |
655 | { return &(dti.dta[category].d[index].meta); } | 655 | { return &(dti.dta[category].d[index].meta); } |
656 | /** is the entry at "category" "index" a binary entry? */ | 656 | /** is the entry at "category" "index" a binary entry? */ |
657 | bool isBinEntry(unsigned int category, unsigned int index) | 657 | bool isBinEntry(unsigned int category, unsigned int index) |
658 | { return dti.dta[category].d[index].binary; } | 658 | { return dti.dta[category].d[index].binary; } |
659 | 659 | ||
660 | public slots: | 660 | public slots: |
661 | /** wrapper for PwMTray */ | 661 | /** wrapper for PwMTray */ |
662 | void _deepUnlock(); | 662 | void _deepUnlock(); |
663 | 663 | ||
664 | signals: | 664 | signals: |
665 | /** the data of the document has changed and must be updated | 665 | /** the data of the document has changed and must be updated |
666 | * in all views. | 666 | * in all views. |
667 | * NOTE: use emitDataChanged(PwMDoc *document) to emit this signal! | 667 | * NOTE: use emitDataChanged(PwMDoc *document) to emit this signal! |
668 | */ | 668 | */ |
669 | void dataChanged(PwMDoc *document); | 669 | void dataChanged(PwMDoc *document); |
670 | /** the document class is going to close. This signal may be | 670 | /** the document class is going to close. This signal may be |
671 | * used to nofify all views, that the user closed the document, | 671 | * used to nofify all views, that the user closed the document, |
672 | * so the views can go down, too. | 672 | * so the views can go down, too. |
673 | */ | 673 | */ |
674 | void docClosed(PwMDoc *document); | 674 | void docClosed(PwMDoc *document); |
675 | /** somebody just opened the document */ | 675 | /** somebody just opened the document */ |
676 | void docOpened(PwMDoc *document); | 676 | void docOpened(PwMDoc *document); |
677 | /** this document object just got created */ | 677 | /** this document object just got created */ |
678 | void docCreated(PwMDoc *document); | 678 | void docCreated(PwMDoc *document); |
679 | 679 | ||
680 | public: | 680 | public: |
681 | /** emit the dataChanged signal after checking for a lock */ | 681 | /** emit the dataChanged signal after checking for a lock */ |
682 | void emitDataChanged(PwMDoc *document) | 682 | void emitDataChanged(PwMDoc *document) |
683 | { | 683 | { |
684 | if (!dataChangedLock) | 684 | if (!dataChangedLock) |
685 | emit dataChanged(document); | 685 | emit dataChanged(document); |
686 | } | 686 | } |
687 | 687 | ||
688 | protected: | 688 | protected: |
689 | /** current file for this doc */ | 689 | /** current file for this doc */ |
690 | QString filename; | 690 | QString filename; |
691 | //US ENH: we need a place where we keep the syncentries. So I invented | 691 | //US ENH: we need a place where we keep the syncentries. So I invented |
692 | // struct PwMItem, that has a vector of PwMCategoryItem and vector of PwMSyncItem | 692 | // struct PwMItem, that has a vector of PwMCategoryItem and vector of PwMSyncItem |
693 | /** holds all data */ | 693 | /** holds all data */ |
694 | PwMItem dti; | 694 | PwMItem dti; |
695 | /** maximum number of entries */ | 695 | /** maximum number of entries */ |
696 | unsigned int maxEntries; | 696 | unsigned int maxEntries; |
697 | /** currently used password to encrypt data */ | 697 | /** currently used password to encrypt data */ |
698 | QString currentPw; | 698 | QString currentPw; |
699 | /** current global document status flags */ | 699 | /** current global document status flags */ |
700 | unsigned int curDocStat; | 700 | unsigned int curDocStat; |
701 | /** browser process for goToURL() */ | 701 | /** browser process for goToURL() */ |
702 | KProcess browserProc; | 702 | KProcess browserProc; |
703 | /** pointer to the list-view, using this document. | 703 | /** pointer to the list-view, using this document. |
704 | * As there can only be one list-view per doc, we | 704 | * As there can only be one list-view per doc, we |
705 | * don't need a list here. | 705 | * don't need a list here. |
706 | */ | 706 | */ |
707 | PwMView *listView; | 707 | PwMView *listView; |
708 | /** unnamedNum is used to store the "unnamed counter" | 708 | /** unnamedNum is used to store the "unnamed counter" |
709 | * for this document, while it's unnamed. If it's 0, | 709 | * for this document, while it's unnamed. If it's 0, |
710 | * we have to get a new unique one. | 710 | * we have to get a new unique one. |
711 | */ | 711 | */ |
712 | unsigned int unnamedNum; | 712 | unsigned int unnamedNum; |
713 | /** is this doc going to be deleted (executing in destructor context) */ | 713 | /** is this doc going to be deleted (executing in destructor context) */ |
714 | bool deleted; | 714 | bool deleted; |
715 | /** document timer */ | 715 | /** document timer */ |
716 | DocTimer *_timer; | 716 | DocTimer *_timer; |
717 | /** lock counter for the "dataChanged" signal */ | 717 | /** lock counter for the "dataChanged" signal */ |
718 | unsigned int dataChangedLock; | 718 | unsigned int dataChangedLock; |
719 | 719 | ||
720 | /** list of all open documents */ | 720 | /** list of all open documents */ |
721 | static PwMDocList openDocList; | 721 | static PwMDocList openDocList; |
722 | 722 | ||
723 | protected: | 723 | protected: |
724 | /** serialize "dta" and return it in "d". */ | 724 | /** serialize "dta" and return it in "d". */ |
725 | bool serializeDta(string *d); | 725 | bool serializeDta(string *d); |
726 | /** de-serialize "d" and overwrite "dta" */ | 726 | /** de-serialize "d" and overwrite "dta" */ |
727 | bool deSerializeDta(const string *d, bool entriesLocked); | 727 | bool deSerializeDta(const string *d, bool entriesLocked); |
728 | /** write header to file */ | 728 | /** write header to file */ |
729 | PwMerror writeFileHeader(char keyHash, char dataHash, char crypt, char compress, | 729 | PwMerror writeFileHeader(char keyHash, char dataHash, char crypt, char compress, |
730 | QString *pw, QFile *f); | 730 | QString *pw, QFile *f); |
731 | /** write data-hash to file */ | 731 | /** write data-hash to file */ |
732 | PwMerror writeDataHash(char dataHash, string *d, QFile *f); | 732 | PwMerror writeDataHash(char dataHash, string *d, QFile *f); |
733 | /** check header. Read header info and verify key-hash and filever. | 733 | /** check header. Read header info and verify key-hash and filever. |
734 | * returns length of header in "headerLength" */ | 734 | * returns length of header in "headerLength" */ |
735 | PwMerror checkHeader(char *cryptAlgo, QString *pw, char *compress, | 735 | PwMerror checkHeader(char *cryptAlgo, QString *pw, char *compress, |
736 | unsigned int *headerLength, char *dataHashType, | 736 | unsigned int *headerLength, char *dataHashType, |
737 | string *dataHash, QFile *f); | 737 | string *dataHash, QFile *f); |
738 | /** check the data-hash */ | 738 | /** check the data-hash */ |
739 | PwMerror checkDataHash(char dataHashType, const string *dataHash, const string *dataStream); | 739 | PwMerror checkDataHash(char dataHashType, const string *dataHash, const string *dataStream); |
740 | /** encrypt data "d" and write to "filename" */ | 740 | /** encrypt data "d" and write to "filename" */ |
741 | PwMerror encrypt(string *d, const QString *pw, QFile *f, char algo, | 741 | PwMerror encrypt(string *d, const QString *pw, QFile *f, char algo, |
742 | char _hashalgo //US BUG: pass _hashalgo because we need it in hashPassphrase | 742 | char _hashalgo //US BUG: pass _hashalgo because we need it in hashPassphrase |
743 | ); | 743 | ); |
744 | /** read data from file beginning at "pos", decrypt and return it */ | 744 | /** read data from file beginning at "pos", decrypt and return it */ |
745 | PwMerror decrypt(string *d, unsigned int pos, const QString *pw, char algo, | 745 | PwMerror decrypt(string *d, unsigned int pos, const QString *pw, char algo, |
746 | char _hashalgo, //US BUG: pass _hashalgo because we need it in hashPassphrase | 746 | char _hashalgo, //US BUG: pass _hashalgo because we need it in hashPassphrase |
747 | QFile *f); | 747 | QFile *f); |
748 | /** compress the data */ | 748 | /** compress the data */ |
749 | bool compressDta(string *d, char algo); | 749 | bool compressDta(string *d, char algo); |
750 | /** uncompress the data */ | 750 | /** uncompress the data */ |
751 | bool decompressDta(string *d, char algo); | 751 | bool decompressDta(string *d, char algo); |
752 | /** internal import function for a text-file generated by PwM. | 752 | /** internal import function for a text-file generated by PwM. |
753 | * If this is not a valid PwM-exported file, it returns e_fileFormat */ | 753 | * If this is not a valid PwM-exported file, it returns e_fileFormat */ |
754 | PwMerror importText_PwM(const QString *file); | 754 | PwMerror importText_PwM(const QString *file); |
755 | /** PwM-text-import helper function to extract the name/pw/comment out | 755 | /** PwM-text-import helper function to extract the name/pw/comment out |
756 | * of one entry-line */ | 756 | * of one entry-line */ |
757 | bool textExtractEntry_PwM(const char *in, ssize_t in_size, string *out); | 757 | bool textExtractEntry_PwM(const char *in, ssize_t in_size, string *out); |
758 | /** compare two strings */ | 758 | /** compare two strings */ |
759 | bool compareString(const string &s1, const string &s2, bool caseSensitive, | 759 | bool compareString(const string &s1, const string &s2, bool caseSensitive, |
760 | bool exactWordMatch); | 760 | bool exactWordMatch); |
761 | /** clears all document-data */ | 761 | /** clears all document-data */ |
762 | void clearDoc(); | 762 | void clearDoc(); |
763 | /** delete all empty categories */ | 763 | /** delete all empty categories */ |
764 | void delAllEmptyCat(bool dontFlagDirty); | 764 | void delAllEmptyCat(bool dontFlagDirty); |
765 | /** set a document status flag */ | 765 | /** set a document status flag */ |
766 | void setDocStatFlag(unsigned int statFlag) | 766 | void setDocStatFlag(unsigned int statFlag) |
767 | { curDocStat |= statFlag; } | 767 | { curDocStat |= statFlag; } |
768 | /** unset a document status flag */ | 768 | /** unset a document status flag */ |
769 | void unsetDocStatFlag(unsigned int statFlag) | 769 | void unsetDocStatFlag(unsigned int statFlag) |
770 | { curDocStat &= ~statFlag; } | 770 | { curDocStat &= ~statFlag; } |
771 | /** get a document status flag */ | 771 | /** get a document status flag */ |
772 | bool getDocStatFlag(unsigned int statFlag) const | 772 | bool getDocStatFlag(unsigned int statFlag) const |
773 | { return (curDocStat & statFlag); } | 773 | { return (curDocStat & statFlag); } |
774 | /** set the "currentPassword" */ | 774 | /** set the "currentPassword" */ |
775 | void setCurrentPw(const QString &pw) | 775 | void setCurrentPw(const QString &pw) |
776 | { | 776 | { |
777 | currentPw = pw; | 777 | currentPw = pw; |
778 | setDocStatFlag(DOC_STAT_DISK_DIRTY); | 778 | setDocStatFlag(DOC_STAT_DISK_DIRTY); |
779 | } | 779 | } |
780 | /** make a backup-copy of the given file */ | 780 | /** make a backup-copy of the given file */ |
781 | bool backupFile(const QString &filePath); | 781 | bool backupFile(const QString &filePath); |
782 | /** copy a file from src to dst */ | 782 | /** copy a file from src to dst */ |
783 | bool copyFile(const QString &src, const QString &dst); | 783 | bool copyFile(const QString &src, const QString &dst); |
784 | 784 | ||
785 | 785 | ||
786 | public: | 786 | public: |
787 | #ifdef PWM_EMBEDDED | 787 | #ifdef PWM_EMBEDDED |
788 | //US ENH: this is the magic function that syncronizes the local doc with the remote doc. | 788 | //US ENH: this is the magic function that syncronizes the local doc with the remote doc. |
789 | PwMerror syncronize(KSyncManager* manager, PwMDoc* syncLocal, PwMDoc* syncRemote, int mode ); | 789 | PwMerror syncronize(KSyncManager* manager, PwMDoc* syncLocal, PwMDoc* syncRemote, int mode ); |
790 | 790 | ||
791 | //takePwMDataItem returns the following values | 791 | //takePwMDataItem returns the following values |
792 | // 0 equal | 792 | // 0 equal |
793 | // 1 take local | 793 | // 1 take local |
794 | // 2 take remote | 794 | // 2 take remote |
795 | // 3 cancel | 795 | // 3 cancel |
796 | int takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full ); | 796 | int takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full ); |
797 | 797 | ||
798 | //the following methods are the overwritten callbackmethods from the syncinterface | 798 | //the following methods are the overwritten callbackmethods from the syncinterface |
799 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 799 | virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource); |
800 | virtual void removeSyncInfo( QString syncProfile); | 800 | virtual void removeSyncInfo( QString syncProfile); |
801 | 801 | ||
802 | #endif | 802 | #endif |
803 | //US ENH: helpermethods to return a whole category entry | 803 | //US ENH: helpermethods to return a whole category entry |
804 | /** returns a pointer to the categoryitem */ | 804 | /** returns a pointer to the categoryitem */ |
805 | PwMCategoryItem* getCategoryEntry(unsigned int index) | 805 | PwMCategoryItem* getCategoryEntry(unsigned int index) |
806 | { return &(dti.dta[index]); } | 806 | { return &(dti.dta[index]); } |
807 | 807 | ||
808 | private: | 808 | private: |
809 | //US ENH: helpermethods to access the sync data for a certain syncname. | 809 | //US ENH: helpermethods to access the sync data for a certain syncname. |
810 | // It returns the syncdatas index | 810 | // It returns the syncdatas index |
811 | bool findSyncData(const QString &syncname, unsigned int *index); | 811 | bool findSyncData(const QString &syncname, unsigned int *index); |
812 | 812 | ||
813 | /** add new syncdataentry */ | 813 | /** add new syncdataentry */ |
814 | PwMerror addSyncDataEntry(PwMSyncItem *d, bool dontFlagDirty = false); | 814 | PwMerror addSyncDataEntry(PwMSyncItem *d, bool dontFlagDirty = false); |
815 | 815 | ||
816 | /** returns a pointer to the syncdata */ | 816 | /** returns a pointer to the syncdata */ |
817 | PwMSyncItem* getSyncDataEntry(unsigned int index) | 817 | PwMSyncItem* getSyncDataEntry(unsigned int index) |
818 | { return &(dti.syncDta[index]); } | 818 | { return &(dti.syncDta[index]); } |
819 | 819 | ||
820 | /** delete entry */ | 820 | /** delete entry */ |
821 | bool delSyncDataEntry(unsigned int index, bool dontFlagDirty = false); | 821 | bool delSyncDataEntry(unsigned int index, bool dontFlagDirty = false); |
822 | 822 | ||
823 | /** returns number of categories */ | 823 | /** returns number of categories */ |
824 | unsigned int numSyncDataEntries() | 824 | unsigned int numSyncDataEntries() |
825 | { return dti.syncDta.size(); } | 825 | { return dti.syncDta.size(); } |
826 | 826 | ||
827 | PwMDataItem* findEntryByID(const QString &uid, unsigned int *category, unsigned int *index); | 827 | PwMDataItem* findEntryByID(const QString &uid, unsigned int *category, unsigned int *index); |
828 | 828 | ||
829 | QStringList getIDEntryList(); | 829 | QStringList getIDEntryList(); |
830 | 830 | ||
831 | }; | 831 | }; |
832 | 832 | ||
833 | #endif | 833 | #endif |