author | zautrix <zautrix> | 2004-10-26 20:55:30 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-26 20:55:30 (UTC) |
commit | 13e996beddabc5e88f4f2fe49b2ce6cb8408eb30 (patch) (unidiff) | |
tree | 77395039348f3af1b5d1e1673f5638a7f34c0e99 | |
parent | 8b111ae30fc51a4a580b8d485bef8ad28b0dde84 (diff) | |
download | kdepimpi-13e996beddabc5e88f4f2fe49b2ce6cb8408eb30.zip kdepimpi-13e996beddabc5e88f4f2fe49b2ce6cb8408eb30.tar.gz kdepimpi-13e996beddabc5e88f4f2fe49b2ce6cb8408eb30.tar.bz2 |
added removeSyncInfo to KSyncInterface class
-rw-r--r-- | kaddressbook/kabcore.cpp | 5 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 1 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 6 | ||||
-rw-r--r-- | korganizer/calendarview.h | 1 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.h | 1 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwm.cpp | 6 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwm.h | 3 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.cpp | 5 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.h | 1 |
9 files changed, 27 insertions, 2 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 2a3334e..efae874 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1277,1635 +1277,1640 @@ void KABCore::setJumpButtonBarVisible( bool visible ) | |||
1277 | else | 1277 | else |
1278 | { | 1278 | { |
1279 | mJumpButtonBar->hide(); | 1279 | mJumpButtonBar->hide(); |
1280 | } | 1280 | } |
1281 | } | 1281 | } |
1282 | } | 1282 | } |
1283 | 1283 | ||
1284 | 1284 | ||
1285 | void KABCore::setDetailsToState() | 1285 | void KABCore::setDetailsToState() |
1286 | { | 1286 | { |
1287 | setDetailsVisible( mActionDetails->isChecked() ); | 1287 | setDetailsVisible( mActionDetails->isChecked() ); |
1288 | } | 1288 | } |
1289 | 1289 | ||
1290 | 1290 | ||
1291 | 1291 | ||
1292 | void KABCore::setDetailsVisible( bool visible ) | 1292 | void KABCore::setDetailsVisible( bool visible ) |
1293 | { | 1293 | { |
1294 | if (visible && mDetails->isHidden()) | 1294 | if (visible && mDetails->isHidden()) |
1295 | { | 1295 | { |
1296 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1296 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1297 | if ( addrList.count() > 0 ) | 1297 | if ( addrList.count() > 0 ) |
1298 | mDetails->setAddressee( addrList[ 0 ] ); | 1298 | mDetails->setAddressee( addrList[ 0 ] ); |
1299 | } | 1299 | } |
1300 | 1300 | ||
1301 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1301 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1302 | // the listview and the detailview. We do that by changing the splitbar size. | 1302 | // the listview and the detailview. We do that by changing the splitbar size. |
1303 | if (mMultipleViewsAtOnce) | 1303 | if (mMultipleViewsAtOnce) |
1304 | { | 1304 | { |
1305 | if ( visible ) | 1305 | if ( visible ) |
1306 | mDetails->show(); | 1306 | mDetails->show(); |
1307 | else | 1307 | else |
1308 | mDetails->hide(); | 1308 | mDetails->hide(); |
1309 | } | 1309 | } |
1310 | else | 1310 | else |
1311 | { | 1311 | { |
1312 | if ( visible ) { | 1312 | if ( visible ) { |
1313 | mViewManager->hide(); | 1313 | mViewManager->hide(); |
1314 | mDetails->show(); | 1314 | mDetails->show(); |
1315 | } | 1315 | } |
1316 | else { | 1316 | else { |
1317 | mViewManager->show(); | 1317 | mViewManager->show(); |
1318 | mDetails->hide(); | 1318 | mDetails->hide(); |
1319 | } | 1319 | } |
1320 | setJumpButtonBarVisible( !visible ); | 1320 | setJumpButtonBarVisible( !visible ); |
1321 | } | 1321 | } |
1322 | 1322 | ||
1323 | } | 1323 | } |
1324 | 1324 | ||
1325 | void KABCore::extensionChanged( int id ) | 1325 | void KABCore::extensionChanged( int id ) |
1326 | { | 1326 | { |
1327 | //change the details view only for non desktop systems | 1327 | //change the details view only for non desktop systems |
1328 | #ifndef DESKTOP_VERSION | 1328 | #ifndef DESKTOP_VERSION |
1329 | 1329 | ||
1330 | if (id == 0) | 1330 | if (id == 0) |
1331 | { | 1331 | { |
1332 | //the user disabled the extension. | 1332 | //the user disabled the extension. |
1333 | 1333 | ||
1334 | if (mMultipleViewsAtOnce) | 1334 | if (mMultipleViewsAtOnce) |
1335 | { // enable detailsview again | 1335 | { // enable detailsview again |
1336 | setDetailsVisible( true ); | 1336 | setDetailsVisible( true ); |
1337 | mActionDetails->setChecked( true ); | 1337 | mActionDetails->setChecked( true ); |
1338 | } | 1338 | } |
1339 | else | 1339 | else |
1340 | { //go back to the listview | 1340 | { //go back to the listview |
1341 | setDetailsVisible( false ); | 1341 | setDetailsVisible( false ); |
1342 | mActionDetails->setChecked( false ); | 1342 | mActionDetails->setChecked( false ); |
1343 | mActionDetails->setEnabled(true); | 1343 | mActionDetails->setEnabled(true); |
1344 | } | 1344 | } |
1345 | 1345 | ||
1346 | } | 1346 | } |
1347 | else | 1347 | else |
1348 | { | 1348 | { |
1349 | //the user enabled the extension. | 1349 | //the user enabled the extension. |
1350 | setDetailsVisible( false ); | 1350 | setDetailsVisible( false ); |
1351 | mActionDetails->setChecked( false ); | 1351 | mActionDetails->setChecked( false ); |
1352 | 1352 | ||
1353 | if (!mMultipleViewsAtOnce) | 1353 | if (!mMultipleViewsAtOnce) |
1354 | { | 1354 | { |
1355 | mActionDetails->setEnabled(false); | 1355 | mActionDetails->setEnabled(false); |
1356 | } | 1356 | } |
1357 | 1357 | ||
1358 | mExtensionManager->setSelectionChanged(); | 1358 | mExtensionManager->setSelectionChanged(); |
1359 | 1359 | ||
1360 | } | 1360 | } |
1361 | 1361 | ||
1362 | #endif// DESKTOP_VERSION | 1362 | #endif// DESKTOP_VERSION |
1363 | 1363 | ||
1364 | } | 1364 | } |
1365 | 1365 | ||
1366 | 1366 | ||
1367 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1367 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1368 | { | 1368 | { |
1369 | 1369 | ||
1370 | if ( list.count() != 0 ) { | 1370 | if ( list.count() != 0 ) { |
1371 | KABC::Addressee::List::ConstIterator it; | 1371 | KABC::Addressee::List::ConstIterator it; |
1372 | for ( it = list.begin(); it != list.end(); ++it ) | 1372 | for ( it = list.begin(); it != list.end(); ++it ) |
1373 | mAddressBook->insertAddressee( *it ); | 1373 | mAddressBook->insertAddressee( *it ); |
1374 | if ( list.count() > 1 ) | 1374 | if ( list.count() > 1 ) |
1375 | setModified(); | 1375 | setModified(); |
1376 | else | 1376 | else |
1377 | setModifiedWOrefresh(); | 1377 | setModifiedWOrefresh(); |
1378 | } | 1378 | } |
1379 | if ( list.count() == 0 ) | 1379 | if ( list.count() == 0 ) |
1380 | mViewManager->refreshView(); | 1380 | mViewManager->refreshView(); |
1381 | else | 1381 | else |
1382 | mViewManager->refreshView( list[ 0 ].uid() ); | 1382 | mViewManager->refreshView( list[ 0 ].uid() ); |
1383 | 1383 | ||
1384 | 1384 | ||
1385 | 1385 | ||
1386 | } | 1386 | } |
1387 | 1387 | ||
1388 | QString KABCore::getNameByPhone( const QString &phone ) | 1388 | QString KABCore::getNameByPhone( const QString &phone ) |
1389 | { | 1389 | { |
1390 | #ifndef KAB_EMBEDDED | 1390 | #ifndef KAB_EMBEDDED |
1391 | QRegExp r( "[/*/-/ ]" ); | 1391 | QRegExp r( "[/*/-/ ]" ); |
1392 | QString localPhone( phone ); | 1392 | QString localPhone( phone ); |
1393 | 1393 | ||
1394 | bool found = false; | 1394 | bool found = false; |
1395 | QString ownerName = ""; | 1395 | QString ownerName = ""; |
1396 | KABC::AddressBook::Iterator iter; | 1396 | KABC::AddressBook::Iterator iter; |
1397 | KABC::PhoneNumber::List::Iterator phoneIter; | 1397 | KABC::PhoneNumber::List::Iterator phoneIter; |
1398 | KABC::PhoneNumber::List phoneList; | 1398 | KABC::PhoneNumber::List phoneList; |
1399 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1399 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1400 | phoneList = (*iter).phoneNumbers(); | 1400 | phoneList = (*iter).phoneNumbers(); |
1401 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1401 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1402 | ++phoneIter) { | 1402 | ++phoneIter) { |
1403 | // Get rid of separator chars so just the numbers are compared. | 1403 | // Get rid of separator chars so just the numbers are compared. |
1404 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1404 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1405 | ownerName = (*iter).formattedName(); | 1405 | ownerName = (*iter).formattedName(); |
1406 | found = true; | 1406 | found = true; |
1407 | } | 1407 | } |
1408 | } | 1408 | } |
1409 | } | 1409 | } |
1410 | 1410 | ||
1411 | return ownerName; | 1411 | return ownerName; |
1412 | #else //KAB_EMBEDDED | 1412 | #else //KAB_EMBEDDED |
1413 | qDebug("KABCore::getNameByPhone finsih method"); | 1413 | qDebug("KABCore::getNameByPhone finsih method"); |
1414 | return ""; | 1414 | return ""; |
1415 | #endif //KAB_EMBEDDED | 1415 | #endif //KAB_EMBEDDED |
1416 | 1416 | ||
1417 | } | 1417 | } |
1418 | 1418 | ||
1419 | void KABCore::openConfigDialog() | 1419 | void KABCore::openConfigDialog() |
1420 | { | 1420 | { |
1421 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1421 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1422 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1422 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1423 | ConfigureDialog->addModule(kabcfg ); | 1423 | ConfigureDialog->addModule(kabcfg ); |
1424 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1424 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1425 | ConfigureDialog->addModule(kdelibcfg ); | 1425 | ConfigureDialog->addModule(kdelibcfg ); |
1426 | 1426 | ||
1427 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1427 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1428 | this, SLOT( configurationChanged() ) ); | 1428 | this, SLOT( configurationChanged() ) ); |
1429 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1429 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1430 | this, SLOT( configurationChanged() ) ); | 1430 | this, SLOT( configurationChanged() ) ); |
1431 | saveSettings(); | 1431 | saveSettings(); |
1432 | #ifndef DESKTOP_VERSION | 1432 | #ifndef DESKTOP_VERSION |
1433 | ConfigureDialog->showMaximized(); | 1433 | ConfigureDialog->showMaximized(); |
1434 | #endif | 1434 | #endif |
1435 | if ( ConfigureDialog->exec() ) | 1435 | if ( ConfigureDialog->exec() ) |
1436 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1436 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1437 | delete ConfigureDialog; | 1437 | delete ConfigureDialog; |
1438 | } | 1438 | } |
1439 | 1439 | ||
1440 | void KABCore::openLDAPDialog() | 1440 | void KABCore::openLDAPDialog() |
1441 | { | 1441 | { |
1442 | #ifndef KAB_EMBEDDED | 1442 | #ifndef KAB_EMBEDDED |
1443 | if ( !mLdapSearchDialog ) { | 1443 | if ( !mLdapSearchDialog ) { |
1444 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1444 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1445 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1445 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1446 | SLOT( refreshView() ) ); | 1446 | SLOT( refreshView() ) ); |
1447 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1447 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1448 | SLOT( setModified() ) ); | 1448 | SLOT( setModified() ) ); |
1449 | } else | 1449 | } else |
1450 | mLdapSearchDialog->restoreSettings(); | 1450 | mLdapSearchDialog->restoreSettings(); |
1451 | 1451 | ||
1452 | if ( mLdapSearchDialog->isOK() ) | 1452 | if ( mLdapSearchDialog->isOK() ) |
1453 | mLdapSearchDialog->exec(); | 1453 | mLdapSearchDialog->exec(); |
1454 | #else //KAB_EMBEDDED | 1454 | #else //KAB_EMBEDDED |
1455 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1455 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1456 | #endif //KAB_EMBEDDED | 1456 | #endif //KAB_EMBEDDED |
1457 | } | 1457 | } |
1458 | 1458 | ||
1459 | void KABCore::print() | 1459 | void KABCore::print() |
1460 | { | 1460 | { |
1461 | #ifndef KAB_EMBEDDED | 1461 | #ifndef KAB_EMBEDDED |
1462 | KPrinter printer; | 1462 | KPrinter printer; |
1463 | if ( !printer.setup( this ) ) | 1463 | if ( !printer.setup( this ) ) |
1464 | return; | 1464 | return; |
1465 | 1465 | ||
1466 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1466 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1467 | mViewManager->selectedUids(), this ); | 1467 | mViewManager->selectedUids(), this ); |
1468 | 1468 | ||
1469 | wizard.exec(); | 1469 | wizard.exec(); |
1470 | #else //KAB_EMBEDDED | 1470 | #else //KAB_EMBEDDED |
1471 | qDebug("KABCore::print() finsih method"); | 1471 | qDebug("KABCore::print() finsih method"); |
1472 | #endif //KAB_EMBEDDED | 1472 | #endif //KAB_EMBEDDED |
1473 | 1473 | ||
1474 | } | 1474 | } |
1475 | 1475 | ||
1476 | 1476 | ||
1477 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1477 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1478 | { | 1478 | { |
1479 | if ( mGUIClient ) | 1479 | if ( mGUIClient ) |
1480 | mGUIClient->insertChildClient( client ); | 1480 | mGUIClient->insertChildClient( client ); |
1481 | else | 1481 | else |
1482 | KMessageBox::error( this, "no KXMLGUICLient"); | 1482 | KMessageBox::error( this, "no KXMLGUICLient"); |
1483 | } | 1483 | } |
1484 | 1484 | ||
1485 | 1485 | ||
1486 | void KABCore::configurationChanged() | 1486 | void KABCore::configurationChanged() |
1487 | { | 1487 | { |
1488 | mExtensionManager->reconfigure(); | 1488 | mExtensionManager->reconfigure(); |
1489 | } | 1489 | } |
1490 | 1490 | ||
1491 | void KABCore::addressBookChanged() | 1491 | void KABCore::addressBookChanged() |
1492 | { | 1492 | { |
1493 | /*US | 1493 | /*US |
1494 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1494 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1495 | while ( it.current() ) { | 1495 | while ( it.current() ) { |
1496 | if ( it.current()->dirty() ) { | 1496 | if ( it.current()->dirty() ) { |
1497 | QString text = i18n( "Data has been changed externally. Unsaved " | 1497 | QString text = i18n( "Data has been changed externally. Unsaved " |
1498 | "changes will be lost." ); | 1498 | "changes will be lost." ); |
1499 | KMessageBox::information( this, text ); | 1499 | KMessageBox::information( this, text ); |
1500 | } | 1500 | } |
1501 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1501 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1502 | ++it; | 1502 | ++it; |
1503 | } | 1503 | } |
1504 | */ | 1504 | */ |
1505 | if (mEditorDialog) | 1505 | if (mEditorDialog) |
1506 | { | 1506 | { |
1507 | if (mEditorDialog->dirty()) | 1507 | if (mEditorDialog->dirty()) |
1508 | { | 1508 | { |
1509 | QString text = i18n( "Data has been changed externally. Unsaved " | 1509 | QString text = i18n( "Data has been changed externally. Unsaved " |
1510 | "changes will be lost." ); | 1510 | "changes will be lost." ); |
1511 | KMessageBox::information( this, text ); | 1511 | KMessageBox::information( this, text ); |
1512 | } | 1512 | } |
1513 | QString currentuid = mEditorDialog->addressee().uid(); | 1513 | QString currentuid = mEditorDialog->addressee().uid(); |
1514 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1514 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1515 | } | 1515 | } |
1516 | mViewManager->refreshView(); | 1516 | mViewManager->refreshView(); |
1517 | // mDetails->refreshView(); | 1517 | // mDetails->refreshView(); |
1518 | 1518 | ||
1519 | 1519 | ||
1520 | } | 1520 | } |
1521 | 1521 | ||
1522 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1522 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1523 | const char *name ) | 1523 | const char *name ) |
1524 | { | 1524 | { |
1525 | 1525 | ||
1526 | if ( mEditorDialog == 0 ) { | 1526 | if ( mEditorDialog == 0 ) { |
1527 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1527 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1528 | name ? name : "editorDialog" ); | 1528 | name ? name : "editorDialog" ); |
1529 | 1529 | ||
1530 | 1530 | ||
1531 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1531 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1532 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1532 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1533 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1533 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1534 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1534 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1535 | } | 1535 | } |
1536 | 1536 | ||
1537 | return mEditorDialog; | 1537 | return mEditorDialog; |
1538 | } | 1538 | } |
1539 | 1539 | ||
1540 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1540 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1541 | { | 1541 | { |
1542 | //mEditorDict.remove( uid ); | 1542 | //mEditorDict.remove( uid ); |
1543 | } | 1543 | } |
1544 | 1544 | ||
1545 | void KABCore::initGUI() | 1545 | void KABCore::initGUI() |
1546 | { | 1546 | { |
1547 | #ifndef KAB_EMBEDDED | 1547 | #ifndef KAB_EMBEDDED |
1548 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1548 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1549 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1549 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1550 | 1550 | ||
1551 | mExtensionBarSplitter = new QSplitter( this ); | 1551 | mExtensionBarSplitter = new QSplitter( this ); |
1552 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1552 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1553 | 1553 | ||
1554 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1554 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1555 | 1555 | ||
1556 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1556 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1557 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1557 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1558 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1558 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1559 | SLOT( incrementalSearch( const QString& ) ) ); | 1559 | SLOT( incrementalSearch( const QString& ) ) ); |
1560 | 1560 | ||
1561 | mViewManager = new ViewManager( this, viewSpace ); | 1561 | mViewManager = new ViewManager( this, viewSpace ); |
1562 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1562 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1563 | 1563 | ||
1564 | mDetails = new ViewContainer( mDetailsSplitter ); | 1564 | mDetails = new ViewContainer( mDetailsSplitter ); |
1565 | 1565 | ||
1566 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1566 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1567 | 1567 | ||
1568 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1568 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1569 | 1569 | ||
1570 | topLayout->addWidget( mExtensionBarSplitter ); | 1570 | topLayout->addWidget( mExtensionBarSplitter ); |
1571 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1571 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1572 | topLayout->addWidget( mJumpButtonBar ); | 1572 | topLayout->addWidget( mJumpButtonBar ); |
1573 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1573 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1574 | 1574 | ||
1575 | mXXPortManager = new XXPortManager( this, this ); | 1575 | mXXPortManager = new XXPortManager( this, this ); |
1576 | 1576 | ||
1577 | #else //KAB_EMBEDDED | 1577 | #else //KAB_EMBEDDED |
1578 | //US initialize viewMenu before settingup viewmanager. | 1578 | //US initialize viewMenu before settingup viewmanager. |
1579 | // Viewmanager needs this menu to plugin submenues. | 1579 | // Viewmanager needs this menu to plugin submenues. |
1580 | viewMenu = new QPopupMenu( this ); | 1580 | viewMenu = new QPopupMenu( this ); |
1581 | settingsMenu = new QPopupMenu( this ); | 1581 | settingsMenu = new QPopupMenu( this ); |
1582 | //filterMenu = new QPopupMenu( this ); | 1582 | //filterMenu = new QPopupMenu( this ); |
1583 | ImportMenu = new QPopupMenu( this ); | 1583 | ImportMenu = new QPopupMenu( this ); |
1584 | ExportMenu = new QPopupMenu( this ); | 1584 | ExportMenu = new QPopupMenu( this ); |
1585 | syncMenu = new QPopupMenu( this ); | 1585 | syncMenu = new QPopupMenu( this ); |
1586 | changeMenu= new QPopupMenu( this ); | 1586 | changeMenu= new QPopupMenu( this ); |
1587 | 1587 | ||
1588 | //US since we have no splitter for the embedded system, setup | 1588 | //US since we have no splitter for the embedded system, setup |
1589 | // a layout with two frames. One left and one right. | 1589 | // a layout with two frames. One left and one right. |
1590 | 1590 | ||
1591 | QBoxLayout *topLayout; | 1591 | QBoxLayout *topLayout; |
1592 | 1592 | ||
1593 | // = new QHBoxLayout( this ); | 1593 | // = new QHBoxLayout( this ); |
1594 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1594 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1595 | 1595 | ||
1596 | // QWidget *mainBox = new QWidget( this ); | 1596 | // QWidget *mainBox = new QWidget( this ); |
1597 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1597 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1598 | 1598 | ||
1599 | #ifdef DESKTOP_VERSION | 1599 | #ifdef DESKTOP_VERSION |
1600 | topLayout = new QHBoxLayout( this ); | 1600 | topLayout = new QHBoxLayout( this ); |
1601 | 1601 | ||
1602 | 1602 | ||
1603 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1603 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1604 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1604 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1605 | 1605 | ||
1606 | topLayout->addWidget(mMiniSplitter ); | 1606 | topLayout->addWidget(mMiniSplitter ); |
1607 | 1607 | ||
1608 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1608 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1609 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1609 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1610 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1610 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1611 | mDetails = new ViewContainer( mMiniSplitter ); | 1611 | mDetails = new ViewContainer( mMiniSplitter ); |
1612 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1612 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1613 | #else | 1613 | #else |
1614 | if ( QApplication::desktop()->width() > 480 ) { | 1614 | if ( QApplication::desktop()->width() > 480 ) { |
1615 | topLayout = new QHBoxLayout( this ); | 1615 | topLayout = new QHBoxLayout( this ); |
1616 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1616 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1617 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1617 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1618 | } else { | 1618 | } else { |
1619 | 1619 | ||
1620 | topLayout = new QHBoxLayout( this ); | 1620 | topLayout = new QHBoxLayout( this ); |
1621 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1621 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1622 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1622 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1623 | } | 1623 | } |
1624 | 1624 | ||
1625 | topLayout->addWidget(mMiniSplitter ); | 1625 | topLayout->addWidget(mMiniSplitter ); |
1626 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1626 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1627 | mDetails = new ViewContainer( mMiniSplitter ); | 1627 | mDetails = new ViewContainer( mMiniSplitter ); |
1628 | 1628 | ||
1629 | 1629 | ||
1630 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1630 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1631 | #endif | 1631 | #endif |
1632 | //eh->hide(); | 1632 | //eh->hide(); |
1633 | // topLayout->addWidget(mExtensionManager ); | 1633 | // topLayout->addWidget(mExtensionManager ); |
1634 | 1634 | ||
1635 | 1635 | ||
1636 | /*US | 1636 | /*US |
1637 | #ifndef KAB_NOSPLITTER | 1637 | #ifndef KAB_NOSPLITTER |
1638 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1638 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1639 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1639 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1640 | topLayout->setSpacing( 10 ); | 1640 | topLayout->setSpacing( 10 ); |
1641 | 1641 | ||
1642 | mDetailsSplitter = new QSplitter( this ); | 1642 | mDetailsSplitter = new QSplitter( this ); |
1643 | 1643 | ||
1644 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1644 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1645 | 1645 | ||
1646 | mViewManager = new ViewManager( this, viewSpace ); | 1646 | mViewManager = new ViewManager( this, viewSpace ); |
1647 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1647 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1648 | 1648 | ||
1649 | mDetails = new ViewContainer( mDetailsSplitter ); | 1649 | mDetails = new ViewContainer( mDetailsSplitter ); |
1650 | 1650 | ||
1651 | topLayout->addWidget( mDetailsSplitter ); | 1651 | topLayout->addWidget( mDetailsSplitter ); |
1652 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1652 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1653 | #else //KAB_NOSPLITTER | 1653 | #else //KAB_NOSPLITTER |
1654 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1654 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1655 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1655 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1656 | topLayout->setSpacing( 10 ); | 1656 | topLayout->setSpacing( 10 ); |
1657 | 1657 | ||
1658 | // mDetailsSplitter = new QSplitter( this ); | 1658 | // mDetailsSplitter = new QSplitter( this ); |
1659 | 1659 | ||
1660 | QVBox *viewSpace = new QVBox( this ); | 1660 | QVBox *viewSpace = new QVBox( this ); |
1661 | 1661 | ||
1662 | mViewManager = new ViewManager( this, viewSpace ); | 1662 | mViewManager = new ViewManager( this, viewSpace ); |
1663 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1663 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1664 | 1664 | ||
1665 | mDetails = new ViewContainer( this ); | 1665 | mDetails = new ViewContainer( this ); |
1666 | 1666 | ||
1667 | topLayout->addWidget( viewSpace ); | 1667 | topLayout->addWidget( viewSpace ); |
1668 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1668 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1669 | topLayout->addWidget( mDetails ); | 1669 | topLayout->addWidget( mDetails ); |
1670 | #endif //KAB_NOSPLITTER | 1670 | #endif //KAB_NOSPLITTER |
1671 | */ | 1671 | */ |
1672 | 1672 | ||
1673 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1673 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1674 | syncManager->setBlockSave(false); | 1674 | syncManager->setBlockSave(false); |
1675 | 1675 | ||
1676 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 1676 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
1677 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 1677 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
1678 | syncManager->setDefaultFileName( sentSyncFile()); | 1678 | syncManager->setDefaultFileName( sentSyncFile()); |
1679 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); | 1679 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); |
1680 | 1680 | ||
1681 | #endif //KAB_EMBEDDED | 1681 | #endif //KAB_EMBEDDED |
1682 | initActions(); | 1682 | initActions(); |
1683 | 1683 | ||
1684 | #ifdef KAB_EMBEDDED | 1684 | #ifdef KAB_EMBEDDED |
1685 | addActionsManually(); | 1685 | addActionsManually(); |
1686 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1686 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1687 | mXXPortManager = new XXPortManager( this, this ); | 1687 | mXXPortManager = new XXPortManager( this, this ); |
1688 | 1688 | ||
1689 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1689 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1690 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1690 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1691 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1691 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1692 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1692 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1693 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1693 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1694 | // mIncSearchWidget->hide(); | 1694 | // mIncSearchWidget->hide(); |
1695 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1695 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1696 | SLOT( incrementalSearch( const QString& ) ) ); | 1696 | SLOT( incrementalSearch( const QString& ) ) ); |
1697 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); | 1697 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); |
1698 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); | 1698 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); |
1699 | 1699 | ||
1700 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1700 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1701 | 1701 | ||
1702 | topLayout->addWidget( mJumpButtonBar ); | 1702 | topLayout->addWidget( mJumpButtonBar ); |
1703 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1703 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1704 | 1704 | ||
1705 | // mMainWindow->getIconToolBar()->raise(); | 1705 | // mMainWindow->getIconToolBar()->raise(); |
1706 | 1706 | ||
1707 | #endif //KAB_EMBEDDED | 1707 | #endif //KAB_EMBEDDED |
1708 | 1708 | ||
1709 | } | 1709 | } |
1710 | void KABCore::initActions() | 1710 | void KABCore::initActions() |
1711 | { | 1711 | { |
1712 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1712 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1713 | 1713 | ||
1714 | #ifndef KAB_EMBEDDED | 1714 | #ifndef KAB_EMBEDDED |
1715 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1715 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1716 | SLOT( clipboardDataChanged() ) ); | 1716 | SLOT( clipboardDataChanged() ) ); |
1717 | #endif //KAB_EMBEDDED | 1717 | #endif //KAB_EMBEDDED |
1718 | 1718 | ||
1719 | // file menu | 1719 | // file menu |
1720 | if ( mIsPart ) { | 1720 | if ( mIsPart ) { |
1721 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1721 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1722 | SLOT( sendMail() ), actionCollection(), | 1722 | SLOT( sendMail() ), actionCollection(), |
1723 | "kaddressbook_mail" ); | 1723 | "kaddressbook_mail" ); |
1724 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1724 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1725 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1725 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1726 | 1726 | ||
1727 | } else { | 1727 | } else { |
1728 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1728 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1729 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1729 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1730 | } | 1730 | } |
1731 | 1731 | ||
1732 | 1732 | ||
1733 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1733 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1734 | SLOT( save() ), actionCollection(), "file_sync" ); | 1734 | SLOT( save() ), actionCollection(), "file_sync" ); |
1735 | 1735 | ||
1736 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1736 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1737 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1737 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1738 | 1738 | ||
1739 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1739 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1740 | this, SLOT( mailVCard() ), | 1740 | this, SLOT( mailVCard() ), |
1741 | actionCollection(), "file_mail_vcard"); | 1741 | actionCollection(), "file_mail_vcard"); |
1742 | 1742 | ||
1743 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, | 1743 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, |
1744 | SLOT( export2phone() ), actionCollection(), | 1744 | SLOT( export2phone() ), actionCollection(), |
1745 | "kaddressbook_ex2phone" ); | 1745 | "kaddressbook_ex2phone" ); |
1746 | 1746 | ||
1747 | mActionBeamVCard = 0; | 1747 | mActionBeamVCard = 0; |
1748 | mActionBeam = 0; | 1748 | mActionBeam = 0; |
1749 | 1749 | ||
1750 | #ifndef DESKTOP_VERSION | 1750 | #ifndef DESKTOP_VERSION |
1751 | if ( Ir::supported() ) { | 1751 | if ( Ir::supported() ) { |
1752 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, | 1752 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, |
1753 | SLOT( beamVCard() ), actionCollection(), | 1753 | SLOT( beamVCard() ), actionCollection(), |
1754 | "kaddressbook_beam_vcard" ); | 1754 | "kaddressbook_beam_vcard" ); |
1755 | 1755 | ||
1756 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1756 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1757 | SLOT( beamMySelf() ), actionCollection(), | 1757 | SLOT( beamMySelf() ), actionCollection(), |
1758 | "kaddressbook_beam_myself" ); | 1758 | "kaddressbook_beam_myself" ); |
1759 | } | 1759 | } |
1760 | #endif | 1760 | #endif |
1761 | 1761 | ||
1762 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1762 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1763 | this, SLOT( editContact2() ), | 1763 | this, SLOT( editContact2() ), |
1764 | actionCollection(), "file_properties" ); | 1764 | actionCollection(), "file_properties" ); |
1765 | 1765 | ||
1766 | #ifdef KAB_EMBEDDED | 1766 | #ifdef KAB_EMBEDDED |
1767 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1767 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1768 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1768 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1769 | mMainWindow, SLOT( exit() ), | 1769 | mMainWindow, SLOT( exit() ), |
1770 | actionCollection(), "quit" ); | 1770 | actionCollection(), "quit" ); |
1771 | #endif //KAB_EMBEDDED | 1771 | #endif //KAB_EMBEDDED |
1772 | 1772 | ||
1773 | // edit menu | 1773 | // edit menu |
1774 | if ( mIsPart ) { | 1774 | if ( mIsPart ) { |
1775 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1775 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1776 | SLOT( copyContacts() ), actionCollection(), | 1776 | SLOT( copyContacts() ), actionCollection(), |
1777 | "kaddressbook_copy" ); | 1777 | "kaddressbook_copy" ); |
1778 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1778 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1779 | SLOT( cutContacts() ), actionCollection(), | 1779 | SLOT( cutContacts() ), actionCollection(), |
1780 | "kaddressbook_cut" ); | 1780 | "kaddressbook_cut" ); |
1781 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1781 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1782 | SLOT( pasteContacts() ), actionCollection(), | 1782 | SLOT( pasteContacts() ), actionCollection(), |
1783 | "kaddressbook_paste" ); | 1783 | "kaddressbook_paste" ); |
1784 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1784 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1785 | SLOT( selectAllContacts() ), actionCollection(), | 1785 | SLOT( selectAllContacts() ), actionCollection(), |
1786 | "kaddressbook_select_all" ); | 1786 | "kaddressbook_select_all" ); |
1787 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1787 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1788 | SLOT( undo() ), actionCollection(), | 1788 | SLOT( undo() ), actionCollection(), |
1789 | "kaddressbook_undo" ); | 1789 | "kaddressbook_undo" ); |
1790 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1790 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1791 | this, SLOT( redo() ), actionCollection(), | 1791 | this, SLOT( redo() ), actionCollection(), |
1792 | "kaddressbook_redo" ); | 1792 | "kaddressbook_redo" ); |
1793 | } else { | 1793 | } else { |
1794 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1794 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1795 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1795 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1796 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1796 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1797 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1797 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1798 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1798 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1799 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1799 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1800 | } | 1800 | } |
1801 | 1801 | ||
1802 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1802 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1803 | Key_Delete, this, SLOT( deleteContacts() ), | 1803 | Key_Delete, this, SLOT( deleteContacts() ), |
1804 | actionCollection(), "edit_delete" ); | 1804 | actionCollection(), "edit_delete" ); |
1805 | 1805 | ||
1806 | mActionUndo->setEnabled( false ); | 1806 | mActionUndo->setEnabled( false ); |
1807 | mActionRedo->setEnabled( false ); | 1807 | mActionRedo->setEnabled( false ); |
1808 | 1808 | ||
1809 | // settings menu | 1809 | // settings menu |
1810 | #ifdef KAB_EMBEDDED | 1810 | #ifdef KAB_EMBEDDED |
1811 | //US special menuentry to configure the addressbook resources. On KDE | 1811 | //US special menuentry to configure the addressbook resources. On KDE |
1812 | // you do that through the control center !!! | 1812 | // you do that through the control center !!! |
1813 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1813 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1814 | SLOT( configureResources() ), actionCollection(), | 1814 | SLOT( configureResources() ), actionCollection(), |
1815 | "kaddressbook_configure_resources" ); | 1815 | "kaddressbook_configure_resources" ); |
1816 | #endif //KAB_EMBEDDED | 1816 | #endif //KAB_EMBEDDED |
1817 | 1817 | ||
1818 | if ( mIsPart ) { | 1818 | if ( mIsPart ) { |
1819 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1819 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1820 | SLOT( openConfigDialog() ), actionCollection(), | 1820 | SLOT( openConfigDialog() ), actionCollection(), |
1821 | "kaddressbook_configure" ); | 1821 | "kaddressbook_configure" ); |
1822 | 1822 | ||
1823 | //US not implemented yet | 1823 | //US not implemented yet |
1824 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1824 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1825 | // this, SLOT( configureKeyBindings() ), actionCollection(), | 1825 | // this, SLOT( configureKeyBindings() ), actionCollection(), |
1826 | // "kaddressbook_configure_shortcuts" ); | 1826 | // "kaddressbook_configure_shortcuts" ); |
1827 | #ifdef KAB_EMBEDDED | 1827 | #ifdef KAB_EMBEDDED |
1828 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1828 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1829 | mActionConfigureToolbars->setEnabled( false ); | 1829 | mActionConfigureToolbars->setEnabled( false ); |
1830 | #endif //KAB_EMBEDDED | 1830 | #endif //KAB_EMBEDDED |
1831 | 1831 | ||
1832 | } else { | 1832 | } else { |
1833 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1833 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1834 | 1834 | ||
1835 | //US not implemented yet | 1835 | //US not implemented yet |
1836 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1836 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1837 | } | 1837 | } |
1838 | 1838 | ||
1839 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1839 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1840 | actionCollection(), "options_show_jump_bar" ); | 1840 | actionCollection(), "options_show_jump_bar" ); |
1841 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1841 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1842 | 1842 | ||
1843 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 1843 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1844 | actionCollection(), "options_show_details" ); | 1844 | actionCollection(), "options_show_details" ); |
1845 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1845 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1846 | 1846 | ||
1847 | 1847 | ||
1848 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, | 1848 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, |
1849 | SLOT( toggleBeamReceive() ), actionCollection(), | 1849 | SLOT( toggleBeamReceive() ), actionCollection(), |
1850 | "kaddressbook_beam_rec" ); | 1850 | "kaddressbook_beam_rec" ); |
1851 | 1851 | ||
1852 | 1852 | ||
1853 | // misc | 1853 | // misc |
1854 | // only enable LDAP lookup if we can handle the protocol | 1854 | // only enable LDAP lookup if we can handle the protocol |
1855 | #ifndef KAB_EMBEDDED | 1855 | #ifndef KAB_EMBEDDED |
1856 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1856 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1857 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1857 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1858 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1858 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1859 | "ldap_lookup" ); | 1859 | "ldap_lookup" ); |
1860 | } | 1860 | } |
1861 | #else //KAB_EMBEDDED | 1861 | #else //KAB_EMBEDDED |
1862 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1862 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1863 | #endif //KAB_EMBEDDED | 1863 | #endif //KAB_EMBEDDED |
1864 | 1864 | ||
1865 | 1865 | ||
1866 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1866 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1867 | SLOT( setWhoAmI() ), actionCollection(), | 1867 | SLOT( setWhoAmI() ), actionCollection(), |
1868 | "set_personal" ); | 1868 | "set_personal" ); |
1869 | 1869 | ||
1870 | 1870 | ||
1871 | 1871 | ||
1872 | 1872 | ||
1873 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1873 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1874 | SLOT( setCategories() ), actionCollection(), | 1874 | SLOT( setCategories() ), actionCollection(), |
1875 | "edit_set_categories" ); | 1875 | "edit_set_categories" ); |
1876 | 1876 | ||
1877 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1877 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1878 | SLOT( removeVoice() ), actionCollection(), | 1878 | SLOT( removeVoice() ), actionCollection(), |
1879 | "remove_voice" ); | 1879 | "remove_voice" ); |
1880 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 1880 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
1881 | SLOT( importFromOL() ), actionCollection(), | 1881 | SLOT( importFromOL() ), actionCollection(), |
1882 | "import_OL" ); | 1882 | "import_OL" ); |
1883 | #ifdef KAB_EMBEDDED | 1883 | #ifdef KAB_EMBEDDED |
1884 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 1884 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
1885 | this, SLOT( showLicence() ), actionCollection(), | 1885 | this, SLOT( showLicence() ), actionCollection(), |
1886 | "licence_about_data" ); | 1886 | "licence_about_data" ); |
1887 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 1887 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
1888 | this, SLOT( faq() ), actionCollection(), | 1888 | this, SLOT( faq() ), actionCollection(), |
1889 | "faq_about_data" ); | 1889 | "faq_about_data" ); |
1890 | mActionWN = new KAction( i18n( "What's New?" ), 0, | 1890 | mActionWN = new KAction( i18n( "What's New?" ), 0, |
1891 | this, SLOT( whatsnew() ), actionCollection(), | 1891 | this, SLOT( whatsnew() ), actionCollection(), |
1892 | "wn" ); | 1892 | "wn" ); |
1893 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, | 1893 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, |
1894 | this, SLOT( synchowto() ), actionCollection(), | 1894 | this, SLOT( synchowto() ), actionCollection(), |
1895 | "sync" ); | 1895 | "sync" ); |
1896 | 1896 | ||
1897 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1897 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1898 | this, SLOT( createAboutData() ), actionCollection(), | 1898 | this, SLOT( createAboutData() ), actionCollection(), |
1899 | "kaddressbook_about_data" ); | 1899 | "kaddressbook_about_data" ); |
1900 | #endif //KAB_EMBEDDED | 1900 | #endif //KAB_EMBEDDED |
1901 | 1901 | ||
1902 | clipboardDataChanged(); | 1902 | clipboardDataChanged(); |
1903 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1903 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1904 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1904 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1905 | } | 1905 | } |
1906 | 1906 | ||
1907 | //US we need this function, to plug all actions into the correct menues. | 1907 | //US we need this function, to plug all actions into the correct menues. |
1908 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1908 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1909 | void KABCore::addActionsManually() | 1909 | void KABCore::addActionsManually() |
1910 | { | 1910 | { |
1911 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1911 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1912 | 1912 | ||
1913 | #ifdef KAB_EMBEDDED | 1913 | #ifdef KAB_EMBEDDED |
1914 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1914 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1915 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1915 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1916 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1916 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1917 | 1917 | ||
1918 | KToolBar* tb = mMainWindow->toolBar(); | 1918 | KToolBar* tb = mMainWindow->toolBar(); |
1919 | 1919 | ||
1920 | #ifdef DESKTOP_VERSION | 1920 | #ifdef DESKTOP_VERSION |
1921 | QMenuBar* mb = mMainWindow->menuBar(); | 1921 | QMenuBar* mb = mMainWindow->menuBar(); |
1922 | 1922 | ||
1923 | //US setup menubar. | 1923 | //US setup menubar. |
1924 | //Disable the following block if you do not want to have a menubar. | 1924 | //Disable the following block if you do not want to have a menubar. |
1925 | mb->insertItem( "&File", fileMenu ); | 1925 | mb->insertItem( "&File", fileMenu ); |
1926 | mb->insertItem( "&Edit", editMenu ); | 1926 | mb->insertItem( "&Edit", editMenu ); |
1927 | mb->insertItem( "&View", viewMenu ); | 1927 | mb->insertItem( "&View", viewMenu ); |
1928 | mb->insertItem( "&Settings", settingsMenu ); | 1928 | mb->insertItem( "&Settings", settingsMenu ); |
1929 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 1929 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
1930 | mb->insertItem( "&Change selected", changeMenu ); | 1930 | mb->insertItem( "&Change selected", changeMenu ); |
1931 | mb->insertItem( "&Help", helpMenu ); | 1931 | mb->insertItem( "&Help", helpMenu ); |
1932 | mIncSearchWidget = new IncSearchWidget( tb ); | 1932 | mIncSearchWidget = new IncSearchWidget( tb ); |
1933 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 1933 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
1934 | 1934 | ||
1935 | #else | 1935 | #else |
1936 | //US setup toolbar | 1936 | //US setup toolbar |
1937 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 1937 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
1938 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 1938 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
1939 | menuBarTB->insertItem( "ME", popupBarTB); | 1939 | menuBarTB->insertItem( "ME", popupBarTB); |
1940 | tb->insertWidget(-1, 0, menuBarTB); | 1940 | tb->insertWidget(-1, 0, menuBarTB); |
1941 | mIncSearchWidget = new IncSearchWidget( tb ); | 1941 | mIncSearchWidget = new IncSearchWidget( tb ); |
1942 | 1942 | ||
1943 | tb->enableMoving(false); | 1943 | tb->enableMoving(false); |
1944 | popupBarTB->insertItem( "&File", fileMenu ); | 1944 | popupBarTB->insertItem( "&File", fileMenu ); |
1945 | popupBarTB->insertItem( "&Edit", editMenu ); | 1945 | popupBarTB->insertItem( "&Edit", editMenu ); |
1946 | popupBarTB->insertItem( "&View", viewMenu ); | 1946 | popupBarTB->insertItem( "&View", viewMenu ); |
1947 | popupBarTB->insertItem( "&Settings", settingsMenu ); | 1947 | popupBarTB->insertItem( "&Settings", settingsMenu ); |
1948 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 1948 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
1949 | mViewManager->getFilterAction()->plug ( popupBarTB); | 1949 | mViewManager->getFilterAction()->plug ( popupBarTB); |
1950 | popupBarTB->insertItem( "&Change selected", changeMenu ); | 1950 | popupBarTB->insertItem( "&Change selected", changeMenu ); |
1951 | popupBarTB->insertItem( "&Help", helpMenu ); | 1951 | popupBarTB->insertItem( "&Help", helpMenu ); |
1952 | if (QApplication::desktop()->width() > 320 ) { | 1952 | if (QApplication::desktop()->width() > 320 ) { |
1953 | // mViewManager->getFilterAction()->plug ( tb); | 1953 | // mViewManager->getFilterAction()->plug ( tb); |
1954 | } | 1954 | } |
1955 | #endif | 1955 | #endif |
1956 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1956 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1957 | 1957 | ||
1958 | 1958 | ||
1959 | 1959 | ||
1960 | //US Now connect the actions with the menue entries. | 1960 | //US Now connect the actions with the menue entries. |
1961 | mActionPrint->plug( fileMenu ); | 1961 | mActionPrint->plug( fileMenu ); |
1962 | mActionMail->plug( fileMenu ); | 1962 | mActionMail->plug( fileMenu ); |
1963 | fileMenu->insertSeparator(); | 1963 | fileMenu->insertSeparator(); |
1964 | 1964 | ||
1965 | mActionNewContact->plug( fileMenu ); | 1965 | mActionNewContact->plug( fileMenu ); |
1966 | mActionNewContact->plug( tb ); | 1966 | mActionNewContact->plug( tb ); |
1967 | 1967 | ||
1968 | mActionEditAddressee->plug( fileMenu ); | 1968 | mActionEditAddressee->plug( fileMenu ); |
1969 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 1969 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
1970 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 1970 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
1971 | mActionEditAddressee->plug( tb ); | 1971 | mActionEditAddressee->plug( tb ); |
1972 | 1972 | ||
1973 | fileMenu->insertSeparator(); | 1973 | fileMenu->insertSeparator(); |
1974 | mActionSave->plug( fileMenu ); | 1974 | mActionSave->plug( fileMenu ); |
1975 | fileMenu->insertItem( "&Import", ImportMenu ); | 1975 | fileMenu->insertItem( "&Import", ImportMenu ); |
1976 | fileMenu->insertItem( "&Export", ExportMenu ); | 1976 | fileMenu->insertItem( "&Export", ExportMenu ); |
1977 | fileMenu->insertSeparator(); | 1977 | fileMenu->insertSeparator(); |
1978 | mActionMailVCard->plug( fileMenu ); | 1978 | mActionMailVCard->plug( fileMenu ); |
1979 | #ifndef DESKTOP_VERSION | 1979 | #ifndef DESKTOP_VERSION |
1980 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); | 1980 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); |
1981 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); | 1981 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); |
1982 | #endif | 1982 | #endif |
1983 | fileMenu->insertSeparator(); | 1983 | fileMenu->insertSeparator(); |
1984 | mActionQuit->plug( fileMenu ); | 1984 | mActionQuit->plug( fileMenu ); |
1985 | #ifdef _WIN32_ | 1985 | #ifdef _WIN32_ |
1986 | mActionImportOL->plug( ImportMenu ); | 1986 | mActionImportOL->plug( ImportMenu ); |
1987 | #endif | 1987 | #endif |
1988 | // edit menu | 1988 | // edit menu |
1989 | mActionUndo->plug( editMenu ); | 1989 | mActionUndo->plug( editMenu ); |
1990 | mActionRedo->plug( editMenu ); | 1990 | mActionRedo->plug( editMenu ); |
1991 | editMenu->insertSeparator(); | 1991 | editMenu->insertSeparator(); |
1992 | mActionCut->plug( editMenu ); | 1992 | mActionCut->plug( editMenu ); |
1993 | mActionCopy->plug( editMenu ); | 1993 | mActionCopy->plug( editMenu ); |
1994 | mActionPaste->plug( editMenu ); | 1994 | mActionPaste->plug( editMenu ); |
1995 | mActionDelete->plug( editMenu ); | 1995 | mActionDelete->plug( editMenu ); |
1996 | editMenu->insertSeparator(); | 1996 | editMenu->insertSeparator(); |
1997 | mActionSelectAll->plug( editMenu ); | 1997 | mActionSelectAll->plug( editMenu ); |
1998 | 1998 | ||
1999 | mActionRemoveVoice->plug( changeMenu ); | 1999 | mActionRemoveVoice->plug( changeMenu ); |
2000 | // settings menu | 2000 | // settings menu |
2001 | //US special menuentry to configure the addressbook resources. On KDE | 2001 | //US special menuentry to configure the addressbook resources. On KDE |
2002 | // you do that through the control center !!! | 2002 | // you do that through the control center !!! |
2003 | mActionConfigResources->plug( settingsMenu ); | 2003 | mActionConfigResources->plug( settingsMenu ); |
2004 | settingsMenu->insertSeparator(); | 2004 | settingsMenu->insertSeparator(); |
2005 | 2005 | ||
2006 | mActionConfigKAddressbook->plug( settingsMenu ); | 2006 | mActionConfigKAddressbook->plug( settingsMenu ); |
2007 | 2007 | ||
2008 | if ( mIsPart ) { | 2008 | if ( mIsPart ) { |
2009 | //US not implemented yet | 2009 | //US not implemented yet |
2010 | //mActionConfigShortcuts->plug( settingsMenu ); | 2010 | //mActionConfigShortcuts->plug( settingsMenu ); |
2011 | //mActionConfigureToolbars->plug( settingsMenu ); | 2011 | //mActionConfigureToolbars->plug( settingsMenu ); |
2012 | 2012 | ||
2013 | } else { | 2013 | } else { |
2014 | //US not implemented yet | 2014 | //US not implemented yet |
2015 | //mActionKeyBindings->plug( settingsMenu ); | 2015 | //mActionKeyBindings->plug( settingsMenu ); |
2016 | } | 2016 | } |
2017 | 2017 | ||
2018 | settingsMenu->insertSeparator(); | 2018 | settingsMenu->insertSeparator(); |
2019 | 2019 | ||
2020 | mActionJumpBar->plug( settingsMenu ); | 2020 | mActionJumpBar->plug( settingsMenu ); |
2021 | mActionDetails->plug( settingsMenu ); | 2021 | mActionDetails->plug( settingsMenu ); |
2022 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2022 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2023 | mActionDetails->plug( tb ); | 2023 | mActionDetails->plug( tb ); |
2024 | settingsMenu->insertSeparator(); | 2024 | settingsMenu->insertSeparator(); |
2025 | mActionBR->plug(settingsMenu ); | 2025 | mActionBR->plug(settingsMenu ); |
2026 | settingsMenu->insertSeparator(); | 2026 | settingsMenu->insertSeparator(); |
2027 | 2027 | ||
2028 | mActionWhoAmI->plug( settingsMenu ); | 2028 | mActionWhoAmI->plug( settingsMenu ); |
2029 | mActionCategories->plug( settingsMenu ); | 2029 | mActionCategories->plug( settingsMenu ); |
2030 | 2030 | ||
2031 | 2031 | ||
2032 | mActionWN->plug( helpMenu ); | 2032 | mActionWN->plug( helpMenu ); |
2033 | mActionSyncHowto->plug( helpMenu ); | 2033 | mActionSyncHowto->plug( helpMenu ); |
2034 | mActionLicence->plug( helpMenu ); | 2034 | mActionLicence->plug( helpMenu ); |
2035 | mActionFaq->plug( helpMenu ); | 2035 | mActionFaq->plug( helpMenu ); |
2036 | mActionAboutKAddressbook->plug( helpMenu ); | 2036 | mActionAboutKAddressbook->plug( helpMenu ); |
2037 | 2037 | ||
2038 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2038 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2039 | 2039 | ||
2040 | mActionSave->plug( tb ); | 2040 | mActionSave->plug( tb ); |
2041 | mViewManager->getFilterAction()->plug ( tb); | 2041 | mViewManager->getFilterAction()->plug ( tb); |
2042 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 2042 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
2043 | mActionUndo->plug( tb ); | 2043 | mActionUndo->plug( tb ); |
2044 | mActionDelete->plug( tb ); | 2044 | mActionDelete->plug( tb ); |
2045 | mActionRedo->plug( tb ); | 2045 | mActionRedo->plug( tb ); |
2046 | } | 2046 | } |
2047 | } | 2047 | } |
2048 | //mActionQuit->plug ( tb ); | 2048 | //mActionQuit->plug ( tb ); |
2049 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2049 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2050 | 2050 | ||
2051 | //US link the searchwidget first to this. | 2051 | //US link the searchwidget first to this. |
2052 | // The real linkage to the toolbar happens later. | 2052 | // The real linkage to the toolbar happens later. |
2053 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2053 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2054 | //US tb->insertItem( mIncSearchWidget ); | 2054 | //US tb->insertItem( mIncSearchWidget ); |
2055 | /*US | 2055 | /*US |
2056 | mIncSearchWidget = new IncSearchWidget( tb ); | 2056 | mIncSearchWidget = new IncSearchWidget( tb ); |
2057 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2057 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2058 | SLOT( incrementalSearch( const QString& ) ) ); | 2058 | SLOT( incrementalSearch( const QString& ) ) ); |
2059 | 2059 | ||
2060 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2060 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2061 | 2061 | ||
2062 | //US topLayout->addWidget( mJumpButtonBar ); | 2062 | //US topLayout->addWidget( mJumpButtonBar ); |
2063 | this->layout()->add( mJumpButtonBar ); | 2063 | this->layout()->add( mJumpButtonBar ); |
2064 | */ | 2064 | */ |
2065 | 2065 | ||
2066 | #endif //KAB_EMBEDDED | 2066 | #endif //KAB_EMBEDDED |
2067 | 2067 | ||
2068 | mActionExport2phone->plug( ExportMenu ); | 2068 | mActionExport2phone->plug( ExportMenu ); |
2069 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2069 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2070 | syncManager->fillSyncMenu(); | 2070 | syncManager->fillSyncMenu(); |
2071 | 2071 | ||
2072 | } | 2072 | } |
2073 | void KABCore::showLicence() | 2073 | void KABCore::showLicence() |
2074 | { | 2074 | { |
2075 | KApplication::showLicence(); | 2075 | KApplication::showLicence(); |
2076 | } | 2076 | } |
2077 | void KABCore::removeVoice() | 2077 | void KABCore::removeVoice() |
2078 | { | 2078 | { |
2079 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) | 2079 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) |
2080 | return; | 2080 | return; |
2081 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 2081 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
2082 | KABC::Addressee::List::Iterator it; | 2082 | KABC::Addressee::List::Iterator it; |
2083 | for ( it = list.begin(); it != list.end(); ++it ) { | 2083 | for ( it = list.begin(); it != list.end(); ++it ) { |
2084 | 2084 | ||
2085 | if ( (*it).removeVoice() ) | 2085 | if ( (*it).removeVoice() ) |
2086 | contactModified((*it) ); | 2086 | contactModified((*it) ); |
2087 | } | 2087 | } |
2088 | } | 2088 | } |
2089 | 2089 | ||
2090 | 2090 | ||
2091 | 2091 | ||
2092 | void KABCore::clipboardDataChanged() | 2092 | void KABCore::clipboardDataChanged() |
2093 | { | 2093 | { |
2094 | 2094 | ||
2095 | if ( mReadWrite ) | 2095 | if ( mReadWrite ) |
2096 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2096 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2097 | 2097 | ||
2098 | } | 2098 | } |
2099 | 2099 | ||
2100 | void KABCore::updateActionMenu() | 2100 | void KABCore::updateActionMenu() |
2101 | { | 2101 | { |
2102 | UndoStack *undo = UndoStack::instance(); | 2102 | UndoStack *undo = UndoStack::instance(); |
2103 | RedoStack *redo = RedoStack::instance(); | 2103 | RedoStack *redo = RedoStack::instance(); |
2104 | 2104 | ||
2105 | if ( undo->isEmpty() ) | 2105 | if ( undo->isEmpty() ) |
2106 | mActionUndo->setText( i18n( "Undo" ) ); | 2106 | mActionUndo->setText( i18n( "Undo" ) ); |
2107 | else | 2107 | else |
2108 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2108 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2109 | 2109 | ||
2110 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2110 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2111 | 2111 | ||
2112 | if ( !redo->top() ) | 2112 | if ( !redo->top() ) |
2113 | mActionRedo->setText( i18n( "Redo" ) ); | 2113 | mActionRedo->setText( i18n( "Redo" ) ); |
2114 | else | 2114 | else |
2115 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2115 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2116 | 2116 | ||
2117 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2117 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2118 | } | 2118 | } |
2119 | 2119 | ||
2120 | void KABCore::configureKeyBindings() | 2120 | void KABCore::configureKeyBindings() |
2121 | { | 2121 | { |
2122 | #ifndef KAB_EMBEDDED | 2122 | #ifndef KAB_EMBEDDED |
2123 | KKeyDialog::configure( actionCollection(), true ); | 2123 | KKeyDialog::configure( actionCollection(), true ); |
2124 | #else //KAB_EMBEDDED | 2124 | #else //KAB_EMBEDDED |
2125 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2125 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2126 | #endif //KAB_EMBEDDED | 2126 | #endif //KAB_EMBEDDED |
2127 | } | 2127 | } |
2128 | 2128 | ||
2129 | #ifdef KAB_EMBEDDED | 2129 | #ifdef KAB_EMBEDDED |
2130 | void KABCore::configureResources() | 2130 | void KABCore::configureResources() |
2131 | { | 2131 | { |
2132 | KRES::KCMKResources dlg( this, "" , 0 ); | 2132 | KRES::KCMKResources dlg( this, "" , 0 ); |
2133 | 2133 | ||
2134 | if ( !dlg.exec() ) | 2134 | if ( !dlg.exec() ) |
2135 | return; | 2135 | return; |
2136 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2136 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2137 | } | 2137 | } |
2138 | #endif //KAB_EMBEDDED | 2138 | #endif //KAB_EMBEDDED |
2139 | 2139 | ||
2140 | 2140 | ||
2141 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2141 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2142 | * for the attendees list of an event. | 2142 | * for the attendees list of an event. |
2143 | */ | 2143 | */ |
2144 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2144 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2145 | { | 2145 | { |
2146 | QStringList nameList; | 2146 | QStringList nameList; |
2147 | QStringList emailList; | 2147 | QStringList emailList; |
2148 | QStringList uidList; | 2148 | QStringList uidList; |
2149 | 2149 | ||
2150 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2150 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2151 | uint i=0; | 2151 | uint i=0; |
2152 | for (i=0; i < list.count(); i++) | 2152 | for (i=0; i < list.count(); i++) |
2153 | { | 2153 | { |
2154 | nameList.append(list[i].realName()); | 2154 | nameList.append(list[i].realName()); |
2155 | emailList.append(list[i].preferredEmail()); | 2155 | emailList.append(list[i].preferredEmail()); |
2156 | uidList.append(list[i].uid()); | 2156 | uidList.append(list[i].uid()); |
2157 | } | 2157 | } |
2158 | 2158 | ||
2159 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2159 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2160 | 2160 | ||
2161 | } | 2161 | } |
2162 | 2162 | ||
2163 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2163 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2164 | * to put them into the calendar. | 2164 | * to put them into the calendar. |
2165 | */ | 2165 | */ |
2166 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2166 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2167 | { | 2167 | { |
2168 | // qDebug("KABCore::requestForBirthdayList"); | 2168 | // qDebug("KABCore::requestForBirthdayList"); |
2169 | QStringList birthdayList; | 2169 | QStringList birthdayList; |
2170 | QStringList anniversaryList; | 2170 | QStringList anniversaryList; |
2171 | QStringList realNameList; | 2171 | QStringList realNameList; |
2172 | QStringList preferredEmailList; | 2172 | QStringList preferredEmailList; |
2173 | QStringList assembledNameList; | 2173 | QStringList assembledNameList; |
2174 | QStringList uidList; | 2174 | QStringList uidList; |
2175 | 2175 | ||
2176 | KABC::AddressBook::Iterator it; | 2176 | KABC::AddressBook::Iterator it; |
2177 | 2177 | ||
2178 | int count = 0; | 2178 | int count = 0; |
2179 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2179 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2180 | ++count; | 2180 | ++count; |
2181 | } | 2181 | } |
2182 | QProgressBar bar(count,0 ); | 2182 | QProgressBar bar(count,0 ); |
2183 | int w = 300; | 2183 | int w = 300; |
2184 | if ( QApplication::desktop()->width() < 320 ) | 2184 | if ( QApplication::desktop()->width() < 320 ) |
2185 | w = 220; | 2185 | w = 220; |
2186 | int h = bar.sizeHint().height() ; | 2186 | int h = bar.sizeHint().height() ; |
2187 | int dw = QApplication::desktop()->width(); | 2187 | int dw = QApplication::desktop()->width(); |
2188 | int dh = QApplication::desktop()->height(); | 2188 | int dh = QApplication::desktop()->height(); |
2189 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2189 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2190 | bar.show(); | 2190 | bar.show(); |
2191 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); | 2191 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); |
2192 | qApp->processEvents(); | 2192 | qApp->processEvents(); |
2193 | 2193 | ||
2194 | QDate bday; | 2194 | QDate bday; |
2195 | QString anni; | 2195 | QString anni; |
2196 | QString formattedbday; | 2196 | QString formattedbday; |
2197 | 2197 | ||
2198 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2198 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2199 | { | 2199 | { |
2200 | if ( ! bar.isVisible() ) | 2200 | if ( ! bar.isVisible() ) |
2201 | return; | 2201 | return; |
2202 | bar.setProgress( count++ ); | 2202 | bar.setProgress( count++ ); |
2203 | qApp->processEvents(); | 2203 | qApp->processEvents(); |
2204 | bday = (*it).birthday().date(); | 2204 | bday = (*it).birthday().date(); |
2205 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2205 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2206 | 2206 | ||
2207 | if ( bday.isValid() || !anni.isEmpty()) | 2207 | if ( bday.isValid() || !anni.isEmpty()) |
2208 | { | 2208 | { |
2209 | if (bday.isValid()) | 2209 | if (bday.isValid()) |
2210 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2210 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2211 | else | 2211 | else |
2212 | formattedbday = "NOTVALID"; | 2212 | formattedbday = "NOTVALID"; |
2213 | if (anni.isEmpty()) | 2213 | if (anni.isEmpty()) |
2214 | anni = "INVALID"; | 2214 | anni = "INVALID"; |
2215 | 2215 | ||
2216 | birthdayList.append(formattedbday); | 2216 | birthdayList.append(formattedbday); |
2217 | anniversaryList.append(anni); //should be ISODate | 2217 | anniversaryList.append(anni); //should be ISODate |
2218 | realNameList.append((*it).realName()); | 2218 | realNameList.append((*it).realName()); |
2219 | preferredEmailList.append((*it).preferredEmail()); | 2219 | preferredEmailList.append((*it).preferredEmail()); |
2220 | assembledNameList.append((*it).assembledName()); | 2220 | assembledNameList.append((*it).assembledName()); |
2221 | uidList.append((*it).uid()); | 2221 | uidList.append((*it).uid()); |
2222 | 2222 | ||
2223 | qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); | 2223 | qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); |
2224 | } | 2224 | } |
2225 | } | 2225 | } |
2226 | 2226 | ||
2227 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2227 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2228 | 2228 | ||
2229 | } | 2229 | } |
2230 | 2230 | ||
2231 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2231 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2232 | */ | 2232 | */ |
2233 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2233 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2234 | { | 2234 | { |
2235 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2235 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2236 | 2236 | ||
2237 | QString foundUid = QString::null; | 2237 | QString foundUid = QString::null; |
2238 | if ( ! uid.isEmpty() ) { | 2238 | if ( ! uid.isEmpty() ) { |
2239 | Addressee adrr = mAddressBook->findByUid( uid ); | 2239 | Addressee adrr = mAddressBook->findByUid( uid ); |
2240 | if ( !adrr.isEmpty() ) { | 2240 | if ( !adrr.isEmpty() ) { |
2241 | foundUid = uid; | 2241 | foundUid = uid; |
2242 | } | 2242 | } |
2243 | if ( email == "sendbacklist" ) { | 2243 | if ( email == "sendbacklist" ) { |
2244 | //qDebug("ssssssssssssssssssssssend "); | 2244 | //qDebug("ssssssssssssssssssssssend "); |
2245 | QStringList nameList; | 2245 | QStringList nameList; |
2246 | QStringList emailList; | 2246 | QStringList emailList; |
2247 | QStringList uidList; | 2247 | QStringList uidList; |
2248 | nameList.append(adrr.realName()); | 2248 | nameList.append(adrr.realName()); |
2249 | emailList = adrr.emails(); | 2249 | emailList = adrr.emails(); |
2250 | uidList.append( adrr.preferredEmail()); | 2250 | uidList.append( adrr.preferredEmail()); |
2251 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2251 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2252 | return; | 2252 | return; |
2253 | } | 2253 | } |
2254 | 2254 | ||
2255 | } | 2255 | } |
2256 | 2256 | ||
2257 | if ( email == "sendbacklist" ) | 2257 | if ( email == "sendbacklist" ) |
2258 | return; | 2258 | return; |
2259 | if (foundUid.isEmpty()) | 2259 | if (foundUid.isEmpty()) |
2260 | { | 2260 | { |
2261 | //find the uid of the person first | 2261 | //find the uid of the person first |
2262 | Addressee::List namelist; | 2262 | Addressee::List namelist; |
2263 | Addressee::List emaillist; | 2263 | Addressee::List emaillist; |
2264 | 2264 | ||
2265 | if (!name.isEmpty()) | 2265 | if (!name.isEmpty()) |
2266 | namelist = mAddressBook->findByName( name ); | 2266 | namelist = mAddressBook->findByName( name ); |
2267 | 2267 | ||
2268 | if (!email.isEmpty()) | 2268 | if (!email.isEmpty()) |
2269 | emaillist = mAddressBook->findByEmail( email ); | 2269 | emaillist = mAddressBook->findByEmail( email ); |
2270 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2270 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2271 | //check if we have a match in Namelist and Emaillist | 2271 | //check if we have a match in Namelist and Emaillist |
2272 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2272 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2273 | foundUid = emaillist[0].uid(); | 2273 | foundUid = emaillist[0].uid(); |
2274 | } | 2274 | } |
2275 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2275 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2276 | foundUid = namelist[0].uid(); | 2276 | foundUid = namelist[0].uid(); |
2277 | else | 2277 | else |
2278 | { | 2278 | { |
2279 | for (int i = 0; i < namelist.count(); i++) | 2279 | for (int i = 0; i < namelist.count(); i++) |
2280 | { | 2280 | { |
2281 | for (int j = 0; j < emaillist.count(); j++) | 2281 | for (int j = 0; j < emaillist.count(); j++) |
2282 | { | 2282 | { |
2283 | if (namelist[i] == emaillist[j]) | 2283 | if (namelist[i] == emaillist[j]) |
2284 | { | 2284 | { |
2285 | foundUid = namelist[i].uid(); | 2285 | foundUid = namelist[i].uid(); |
2286 | } | 2286 | } |
2287 | } | 2287 | } |
2288 | } | 2288 | } |
2289 | } | 2289 | } |
2290 | } | 2290 | } |
2291 | else | 2291 | else |
2292 | { | 2292 | { |
2293 | foundUid = uid; | 2293 | foundUid = uid; |
2294 | } | 2294 | } |
2295 | 2295 | ||
2296 | if (!foundUid.isEmpty()) | 2296 | if (!foundUid.isEmpty()) |
2297 | { | 2297 | { |
2298 | 2298 | ||
2299 | // raise Ka/Pi if it is in the background | 2299 | // raise Ka/Pi if it is in the background |
2300 | #ifndef DESKTOP_VERSION | 2300 | #ifndef DESKTOP_VERSION |
2301 | #ifndef KORG_NODCOP | 2301 | #ifndef KORG_NODCOP |
2302 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2302 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2303 | #endif | 2303 | #endif |
2304 | #endif | 2304 | #endif |
2305 | 2305 | ||
2306 | mMainWindow->showMaximized(); | 2306 | mMainWindow->showMaximized(); |
2307 | mMainWindow-> raise(); | 2307 | mMainWindow-> raise(); |
2308 | 2308 | ||
2309 | mViewManager->setSelected( "", false); | 2309 | mViewManager->setSelected( "", false); |
2310 | mViewManager->refreshView( "" ); | 2310 | mViewManager->refreshView( "" ); |
2311 | mViewManager->setSelected( foundUid, true ); | 2311 | mViewManager->setSelected( foundUid, true ); |
2312 | mViewManager->refreshView( foundUid ); | 2312 | mViewManager->refreshView( foundUid ); |
2313 | 2313 | ||
2314 | if ( !mMultipleViewsAtOnce ) | 2314 | if ( !mMultipleViewsAtOnce ) |
2315 | { | 2315 | { |
2316 | setDetailsVisible( true ); | 2316 | setDetailsVisible( true ); |
2317 | mActionDetails->setChecked(true); | 2317 | mActionDetails->setChecked(true); |
2318 | } | 2318 | } |
2319 | } | 2319 | } |
2320 | } | 2320 | } |
2321 | 2321 | ||
2322 | void KABCore::whatsnew() | 2322 | void KABCore::whatsnew() |
2323 | { | 2323 | { |
2324 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 2324 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
2325 | } | 2325 | } |
2326 | void KABCore::synchowto() | 2326 | void KABCore::synchowto() |
2327 | { | 2327 | { |
2328 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 2328 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
2329 | } | 2329 | } |
2330 | 2330 | ||
2331 | void KABCore::faq() | 2331 | void KABCore::faq() |
2332 | { | 2332 | { |
2333 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2333 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2334 | } | 2334 | } |
2335 | 2335 | ||
2336 | #include <libkcal/syncdefines.h> | 2336 | #include <libkcal/syncdefines.h> |
2337 | 2337 | ||
2338 | KABC::Addressee KABCore::getLastSyncAddressee() | 2338 | KABC::Addressee KABCore::getLastSyncAddressee() |
2339 | { | 2339 | { |
2340 | Addressee lse; | 2340 | Addressee lse; |
2341 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2341 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2342 | 2342 | ||
2343 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2343 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2344 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2344 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2345 | if (lse.isEmpty()) { | 2345 | if (lse.isEmpty()) { |
2346 | qDebug("Creating new last-syncAddressee "); | 2346 | qDebug("Creating new last-syncAddressee "); |
2347 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2347 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2348 | QString sum = ""; | 2348 | QString sum = ""; |
2349 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2349 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2350 | sum = "E: "; | 2350 | sum = "E: "; |
2351 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2351 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2352 | lse.setRevision( mLastAddressbookSync ); | 2352 | lse.setRevision( mLastAddressbookSync ); |
2353 | lse.setCategories( i18n("SyncEvent") ); | 2353 | lse.setCategories( i18n("SyncEvent") ); |
2354 | mAddressBook->insertAddressee( lse ); | 2354 | mAddressBook->insertAddressee( lse ); |
2355 | } | 2355 | } |
2356 | return lse; | 2356 | return lse; |
2357 | } | 2357 | } |
2358 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2358 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2359 | { | 2359 | { |
2360 | 2360 | ||
2361 | //void setZaurusId(int id); | 2361 | //void setZaurusId(int id); |
2362 | // int zaurusId() const; | 2362 | // int zaurusId() const; |
2363 | // void setZaurusUid(int id); | 2363 | // void setZaurusUid(int id); |
2364 | // int zaurusUid() const; | 2364 | // int zaurusUid() const; |
2365 | // void setZaurusStat(int id); | 2365 | // void setZaurusStat(int id); |
2366 | // int zaurusStat() const; | 2366 | // int zaurusStat() const; |
2367 | // 0 equal | 2367 | // 0 equal |
2368 | // 1 take local | 2368 | // 1 take local |
2369 | // 2 take remote | 2369 | // 2 take remote |
2370 | // 3 cancel | 2370 | // 3 cancel |
2371 | QDateTime lastSync = mLastAddressbookSync; | 2371 | QDateTime lastSync = mLastAddressbookSync; |
2372 | QDateTime localMod = local->revision(); | 2372 | QDateTime localMod = local->revision(); |
2373 | QDateTime remoteMod = remote->revision(); | 2373 | QDateTime remoteMod = remote->revision(); |
2374 | 2374 | ||
2375 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2375 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2376 | 2376 | ||
2377 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2377 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2378 | bool remCh, locCh; | 2378 | bool remCh, locCh; |
2379 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2379 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2380 | 2380 | ||
2381 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2381 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2382 | locCh = ( localMod > mLastAddressbookSync ); | 2382 | locCh = ( localMod > mLastAddressbookSync ); |
2383 | if ( !remCh && ! locCh ) { | 2383 | if ( !remCh && ! locCh ) { |
2384 | //qDebug("both not changed "); | 2384 | //qDebug("both not changed "); |
2385 | lastSync = localMod.addDays(1); | 2385 | lastSync = localMod.addDays(1); |
2386 | if ( mode <= SYNC_PREF_ASK ) | 2386 | if ( mode <= SYNC_PREF_ASK ) |
2387 | return 0; | 2387 | return 0; |
2388 | } else { | 2388 | } else { |
2389 | if ( locCh ) { | 2389 | if ( locCh ) { |
2390 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2390 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2391 | lastSync = localMod.addDays( -1 ); | 2391 | lastSync = localMod.addDays( -1 ); |
2392 | if ( !remCh ) | 2392 | if ( !remCh ) |
2393 | remoteMod =( lastSync.addDays( -1 ) ); | 2393 | remoteMod =( lastSync.addDays( -1 ) ); |
2394 | } else { | 2394 | } else { |
2395 | //qDebug(" not loc changed "); | 2395 | //qDebug(" not loc changed "); |
2396 | lastSync = localMod.addDays( 1 ); | 2396 | lastSync = localMod.addDays( 1 ); |
2397 | if ( remCh ) | 2397 | if ( remCh ) |
2398 | remoteMod =( lastSync.addDays( 1 ) ); | 2398 | remoteMod =( lastSync.addDays( 1 ) ); |
2399 | 2399 | ||
2400 | } | 2400 | } |
2401 | } | 2401 | } |
2402 | full = true; | 2402 | full = true; |
2403 | if ( mode < SYNC_PREF_ASK ) | 2403 | if ( mode < SYNC_PREF_ASK ) |
2404 | mode = SYNC_PREF_ASK; | 2404 | mode = SYNC_PREF_ASK; |
2405 | } else { | 2405 | } else { |
2406 | if ( localMod == remoteMod ) | 2406 | if ( localMod == remoteMod ) |
2407 | return 0; | 2407 | return 0; |
2408 | 2408 | ||
2409 | } | 2409 | } |
2410 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 2410 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
2411 | 2411 | ||
2412 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); | 2412 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); |
2413 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 2413 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
2414 | //full = true; //debug only | 2414 | //full = true; //debug only |
2415 | if ( full ) { | 2415 | if ( full ) { |
2416 | bool equ = ( (*local) == (*remote) ); | 2416 | bool equ = ( (*local) == (*remote) ); |
2417 | if ( equ ) { | 2417 | if ( equ ) { |
2418 | //qDebug("equal "); | 2418 | //qDebug("equal "); |
2419 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2419 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2420 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2420 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2421 | } | 2421 | } |
2422 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2422 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2423 | return 0; | 2423 | return 0; |
2424 | 2424 | ||
2425 | }//else //debug only | 2425 | }//else //debug only |
2426 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2426 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2427 | } | 2427 | } |
2428 | int result; | 2428 | int result; |
2429 | bool localIsNew; | 2429 | bool localIsNew; |
2430 | //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() ); | 2430 | //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() ); |
2431 | 2431 | ||
2432 | if ( full && mode < SYNC_PREF_NEWEST ) | 2432 | if ( full && mode < SYNC_PREF_NEWEST ) |
2433 | mode = SYNC_PREF_ASK; | 2433 | mode = SYNC_PREF_ASK; |
2434 | 2434 | ||
2435 | switch( mode ) { | 2435 | switch( mode ) { |
2436 | case SYNC_PREF_LOCAL: | 2436 | case SYNC_PREF_LOCAL: |
2437 | if ( lastSync > remoteMod ) | 2437 | if ( lastSync > remoteMod ) |
2438 | return 1; | 2438 | return 1; |
2439 | if ( lastSync > localMod ) | 2439 | if ( lastSync > localMod ) |
2440 | return 2; | 2440 | return 2; |
2441 | return 1; | 2441 | return 1; |
2442 | break; | 2442 | break; |
2443 | case SYNC_PREF_REMOTE: | 2443 | case SYNC_PREF_REMOTE: |
2444 | if ( lastSync > remoteMod ) | 2444 | if ( lastSync > remoteMod ) |
2445 | return 1; | 2445 | return 1; |
2446 | if ( lastSync > localMod ) | 2446 | if ( lastSync > localMod ) |
2447 | return 2; | 2447 | return 2; |
2448 | return 2; | 2448 | return 2; |
2449 | break; | 2449 | break; |
2450 | case SYNC_PREF_NEWEST: | 2450 | case SYNC_PREF_NEWEST: |
2451 | if ( localMod > remoteMod ) | 2451 | if ( localMod > remoteMod ) |
2452 | return 1; | 2452 | return 1; |
2453 | else | 2453 | else |
2454 | return 2; | 2454 | return 2; |
2455 | break; | 2455 | break; |
2456 | case SYNC_PREF_ASK: | 2456 | case SYNC_PREF_ASK: |
2457 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2457 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2458 | if ( lastSync > remoteMod ) | 2458 | if ( lastSync > remoteMod ) |
2459 | return 1; | 2459 | return 1; |
2460 | if ( lastSync > localMod ) | 2460 | if ( lastSync > localMod ) |
2461 | return 2; | 2461 | return 2; |
2462 | localIsNew = localMod >= remoteMod; | 2462 | localIsNew = localMod >= remoteMod; |
2463 | //qDebug("conflict! ************************************** "); | 2463 | //qDebug("conflict! ************************************** "); |
2464 | { | 2464 | { |
2465 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2465 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2466 | result = acd.executeD(localIsNew); | 2466 | result = acd.executeD(localIsNew); |
2467 | return result; | 2467 | return result; |
2468 | } | 2468 | } |
2469 | break; | 2469 | break; |
2470 | case SYNC_PREF_FORCE_LOCAL: | 2470 | case SYNC_PREF_FORCE_LOCAL: |
2471 | return 1; | 2471 | return 1; |
2472 | break; | 2472 | break; |
2473 | case SYNC_PREF_FORCE_REMOTE: | 2473 | case SYNC_PREF_FORCE_REMOTE: |
2474 | return 2; | 2474 | return 2; |
2475 | break; | 2475 | break; |
2476 | 2476 | ||
2477 | default: | 2477 | default: |
2478 | // SYNC_PREF_TAKE_BOTH not implemented | 2478 | // SYNC_PREF_TAKE_BOTH not implemented |
2479 | break; | 2479 | break; |
2480 | } | 2480 | } |
2481 | return 0; | 2481 | return 0; |
2482 | } | 2482 | } |
2483 | 2483 | ||
2484 | 2484 | ||
2485 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2485 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2486 | { | 2486 | { |
2487 | bool syncOK = true; | 2487 | bool syncOK = true; |
2488 | int addedAddressee = 0; | 2488 | int addedAddressee = 0; |
2489 | int addedAddresseeR = 0; | 2489 | int addedAddresseeR = 0; |
2490 | int deletedAddresseeR = 0; | 2490 | int deletedAddresseeR = 0; |
2491 | int deletedAddresseeL = 0; | 2491 | int deletedAddresseeL = 0; |
2492 | int changedLocal = 0; | 2492 | int changedLocal = 0; |
2493 | int changedRemote = 0; | 2493 | int changedRemote = 0; |
2494 | 2494 | ||
2495 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2495 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2496 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2496 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2497 | 2497 | ||
2498 | //QPtrList<Addressee> el = local->rawAddressees(); | 2498 | //QPtrList<Addressee> el = local->rawAddressees(); |
2499 | Addressee addresseeR; | 2499 | Addressee addresseeR; |
2500 | QString uid; | 2500 | QString uid; |
2501 | int take; | 2501 | int take; |
2502 | Addressee addresseeL; | 2502 | Addressee addresseeL; |
2503 | Addressee addresseeRSync; | 2503 | Addressee addresseeRSync; |
2504 | Addressee addresseeLSync; | 2504 | Addressee addresseeLSync; |
2505 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2505 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2506 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2506 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2507 | bool fullDateRange = false; | 2507 | bool fullDateRange = false; |
2508 | local->resetTempSyncStat(); | 2508 | local->resetTempSyncStat(); |
2509 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2509 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2510 | QDateTime modifiedCalendar = mLastAddressbookSync;; | 2510 | QDateTime modifiedCalendar = mLastAddressbookSync;; |
2511 | addresseeLSync = getLastSyncAddressee(); | 2511 | addresseeLSync = getLastSyncAddressee(); |
2512 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2512 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2513 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2513 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2514 | if ( !addresseeR.isEmpty() ) { | 2514 | if ( !addresseeR.isEmpty() ) { |
2515 | addresseeRSync = addresseeR; | 2515 | addresseeRSync = addresseeR; |
2516 | remote->removeAddressee(addresseeR ); | 2516 | remote->removeAddressee(addresseeR ); |
2517 | 2517 | ||
2518 | } else { | 2518 | } else { |
2519 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2519 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2520 | addresseeRSync = addresseeLSync ; | 2520 | addresseeRSync = addresseeLSync ; |
2521 | } else { | 2521 | } else { |
2522 | qDebug("FULLDATE 1"); | 2522 | qDebug("FULLDATE 1"); |
2523 | fullDateRange = true; | 2523 | fullDateRange = true; |
2524 | Addressee newAdd; | 2524 | Addressee newAdd; |
2525 | addresseeRSync = newAdd; | 2525 | addresseeRSync = newAdd; |
2526 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2526 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2527 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2527 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2528 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2528 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2529 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2529 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2530 | } | 2530 | } |
2531 | } | 2531 | } |
2532 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2532 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2533 | qDebug("FULLDATE 2"); | 2533 | qDebug("FULLDATE 2"); |
2534 | fullDateRange = true; | 2534 | fullDateRange = true; |
2535 | } | 2535 | } |
2536 | if ( ! fullDateRange ) { | 2536 | if ( ! fullDateRange ) { |
2537 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2537 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2538 | 2538 | ||
2539 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2539 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2540 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2540 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2541 | fullDateRange = true; | 2541 | fullDateRange = true; |
2542 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2542 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2543 | } | 2543 | } |
2544 | } | 2544 | } |
2545 | // fullDateRange = true; // debug only! | 2545 | // fullDateRange = true; // debug only! |
2546 | if ( fullDateRange ) | 2546 | if ( fullDateRange ) |
2547 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2547 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2548 | else | 2548 | else |
2549 | mLastAddressbookSync = addresseeLSync.revision(); | 2549 | mLastAddressbookSync = addresseeLSync.revision(); |
2550 | // for resyncing if own file has changed | 2550 | // for resyncing if own file has changed |
2551 | // PENDING fixme later when implemented | 2551 | // PENDING fixme later when implemented |
2552 | #if 0 | 2552 | #if 0 |
2553 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2553 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2554 | mLastAddressbookSync = loadedFileVersion; | 2554 | mLastAddressbookSync = loadedFileVersion; |
2555 | qDebug("setting mLastAddressbookSync "); | 2555 | qDebug("setting mLastAddressbookSync "); |
2556 | } | 2556 | } |
2557 | #endif | 2557 | #endif |
2558 | 2558 | ||
2559 | //qDebug("*************************** "); | 2559 | //qDebug("*************************** "); |
2560 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2560 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2561 | QStringList er = remote->uidList(); | 2561 | QStringList er = remote->uidList(); |
2562 | Addressee inR ;//= er.first(); | 2562 | Addressee inR ;//= er.first(); |
2563 | Addressee inL; | 2563 | Addressee inL; |
2564 | 2564 | ||
2565 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2565 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2566 | 2566 | ||
2567 | int modulo = (er.count()/10)+1; | 2567 | int modulo = (er.count()/10)+1; |
2568 | int incCounter = 0; | 2568 | int incCounter = 0; |
2569 | while ( incCounter < er.count()) { | 2569 | while ( incCounter < er.count()) { |
2570 | if (syncManager->isProgressBarCanceled()) | 2570 | if (syncManager->isProgressBarCanceled()) |
2571 | return false; | 2571 | return false; |
2572 | if ( incCounter % modulo == 0 ) | 2572 | if ( incCounter % modulo == 0 ) |
2573 | syncManager->showProgressBar(incCounter); | 2573 | syncManager->showProgressBar(incCounter); |
2574 | 2574 | ||
2575 | uid = er[ incCounter ]; | 2575 | uid = er[ incCounter ]; |
2576 | bool skipIncidence = false; | 2576 | bool skipIncidence = false; |
2577 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2577 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2578 | skipIncidence = true; | 2578 | skipIncidence = true; |
2579 | QString idS,OidS; | 2579 | QString idS,OidS; |
2580 | qApp->processEvents(); | 2580 | qApp->processEvents(); |
2581 | if ( !skipIncidence ) { | 2581 | if ( !skipIncidence ) { |
2582 | inL = local->findByUid( uid ); | 2582 | inL = local->findByUid( uid ); |
2583 | inR = remote->findByUid( uid ); | 2583 | inR = remote->findByUid( uid ); |
2584 | //inL.setResource( 0 ); | 2584 | //inL.setResource( 0 ); |
2585 | //inR.setResource( 0 ); | 2585 | //inR.setResource( 0 ); |
2586 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2586 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2587 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2587 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2588 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2588 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2589 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2589 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2590 | if ( take == 3 ) | 2590 | if ( take == 3 ) |
2591 | return false; | 2591 | return false; |
2592 | if ( take == 1 ) {// take local | 2592 | if ( take == 1 ) {// take local |
2593 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2593 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2594 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2594 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2595 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2595 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2596 | local->insertAddressee( inL, false ); | 2596 | local->insertAddressee( inL, false ); |
2597 | idS = inR.externalUID(); | 2597 | idS = inR.externalUID(); |
2598 | OidS = inR.originalExternalUID(); | 2598 | OidS = inR.originalExternalUID(); |
2599 | } | 2599 | } |
2600 | else | 2600 | else |
2601 | idS = inR.IDStr(); | 2601 | idS = inR.IDStr(); |
2602 | remote->removeAddressee( inR ); | 2602 | remote->removeAddressee( inR ); |
2603 | inR = inL; | 2603 | inR = inL; |
2604 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2604 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2605 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2605 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2606 | inR.setOriginalExternalUID( OidS ); | 2606 | inR.setOriginalExternalUID( OidS ); |
2607 | inR.setExternalUID( idS ); | 2607 | inR.setExternalUID( idS ); |
2608 | } else { | 2608 | } else { |
2609 | inR.setIDStr( idS ); | 2609 | inR.setIDStr( idS ); |
2610 | } | 2610 | } |
2611 | inR.setResource( 0 ); | 2611 | inR.setResource( 0 ); |
2612 | remote->insertAddressee( inR , false); | 2612 | remote->insertAddressee( inR , false); |
2613 | ++changedRemote; | 2613 | ++changedRemote; |
2614 | } else { // take == 2 take remote | 2614 | } else { // take == 2 take remote |
2615 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2615 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2616 | if ( inR.revision().date().year() < 2004 ) | 2616 | if ( inR.revision().date().year() < 2004 ) |
2617 | inR.setRevision( modifiedCalendar ); | 2617 | inR.setRevision( modifiedCalendar ); |
2618 | } | 2618 | } |
2619 | idS = inL.IDStr(); | 2619 | idS = inL.IDStr(); |
2620 | local->removeAddressee( inL ); | 2620 | local->removeAddressee( inL ); |
2621 | inL = inR; | 2621 | inL = inR; |
2622 | inL.setIDStr( idS ); | 2622 | inL.setIDStr( idS ); |
2623 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2623 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2624 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2624 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2625 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2625 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2626 | } | 2626 | } |
2627 | inL.setResource( 0 ); | 2627 | inL.setResource( 0 ); |
2628 | local->insertAddressee( inL , false ); | 2628 | local->insertAddressee( inL , false ); |
2629 | ++changedLocal; | 2629 | ++changedLocal; |
2630 | } | 2630 | } |
2631 | } | 2631 | } |
2632 | } | 2632 | } |
2633 | } else { // no conflict | 2633 | } else { // no conflict |
2634 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2634 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2635 | QString des = addresseeLSync.note(); | 2635 | QString des = addresseeLSync.note(); |
2636 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2636 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2637 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2637 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2638 | remote->insertAddressee( inR, false ); | 2638 | remote->insertAddressee( inR, false ); |
2639 | ++deletedAddresseeR; | 2639 | ++deletedAddresseeR; |
2640 | } else { | 2640 | } else { |
2641 | inR.setRevision( modifiedCalendar ); | 2641 | inR.setRevision( modifiedCalendar ); |
2642 | remote->insertAddressee( inR, false ); | 2642 | remote->insertAddressee( inR, false ); |
2643 | inL = inR; | 2643 | inL = inR; |
2644 | inL.setResource( 0 ); | 2644 | inL.setResource( 0 ); |
2645 | local->insertAddressee( inL , false); | 2645 | local->insertAddressee( inL , false); |
2646 | ++addedAddressee; | 2646 | ++addedAddressee; |
2647 | } | 2647 | } |
2648 | } else { | 2648 | } else { |
2649 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2649 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2650 | inR.setRevision( modifiedCalendar ); | 2650 | inR.setRevision( modifiedCalendar ); |
2651 | remote->insertAddressee( inR, false ); | 2651 | remote->insertAddressee( inR, false ); |
2652 | inR.setResource( 0 ); | 2652 | inR.setResource( 0 ); |
2653 | local->insertAddressee( inR, false ); | 2653 | local->insertAddressee( inR, false ); |
2654 | ++addedAddressee; | 2654 | ++addedAddressee; |
2655 | } else { | 2655 | } else { |
2656 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2656 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2657 | remote->removeAddressee( inR ); | 2657 | remote->removeAddressee( inR ); |
2658 | ++deletedAddresseeR; | 2658 | ++deletedAddresseeR; |
2659 | } | 2659 | } |
2660 | } | 2660 | } |
2661 | } | 2661 | } |
2662 | } | 2662 | } |
2663 | ++incCounter; | 2663 | ++incCounter; |
2664 | } | 2664 | } |
2665 | er.clear(); | 2665 | er.clear(); |
2666 | QStringList el = local->uidList(); | 2666 | QStringList el = local->uidList(); |
2667 | modulo = (el.count()/10)+1; | 2667 | modulo = (el.count()/10)+1; |
2668 | 2668 | ||
2669 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 2669 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
2670 | incCounter = 0; | 2670 | incCounter = 0; |
2671 | while ( incCounter < el.count()) { | 2671 | while ( incCounter < el.count()) { |
2672 | qApp->processEvents(); | 2672 | qApp->processEvents(); |
2673 | if (syncManager->isProgressBarCanceled()) | 2673 | if (syncManager->isProgressBarCanceled()) |
2674 | return false; | 2674 | return false; |
2675 | if ( incCounter % modulo == 0 ) | 2675 | if ( incCounter % modulo == 0 ) |
2676 | syncManager->showProgressBar(incCounter); | 2676 | syncManager->showProgressBar(incCounter); |
2677 | uid = el[ incCounter ]; | 2677 | uid = el[ incCounter ]; |
2678 | bool skipIncidence = false; | 2678 | bool skipIncidence = false; |
2679 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2679 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2680 | skipIncidence = true; | 2680 | skipIncidence = true; |
2681 | if ( !skipIncidence ) { | 2681 | if ( !skipIncidence ) { |
2682 | inL = local->findByUid( uid ); | 2682 | inL = local->findByUid( uid ); |
2683 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2683 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2684 | inR = remote->findByUid( uid ); | 2684 | inR = remote->findByUid( uid ); |
2685 | if ( inR.isEmpty() ) { | 2685 | if ( inR.isEmpty() ) { |
2686 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2686 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2687 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2687 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2688 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2688 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2689 | local->removeAddressee( inL ); | 2689 | local->removeAddressee( inL ); |
2690 | ++deletedAddresseeL; | 2690 | ++deletedAddresseeL; |
2691 | } else { | 2691 | } else { |
2692 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2692 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2693 | inL.removeID(mCurrentSyncDevice ); | 2693 | inL.removeID(mCurrentSyncDevice ); |
2694 | ++addedAddresseeR; | 2694 | ++addedAddresseeR; |
2695 | inL.setRevision( modifiedCalendar ); | 2695 | inL.setRevision( modifiedCalendar ); |
2696 | local->insertAddressee( inL, false ); | 2696 | local->insertAddressee( inL, false ); |
2697 | inR = inL; | 2697 | inR = inL; |
2698 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 2698 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
2699 | inR.setResource( 0 ); | 2699 | inR.setResource( 0 ); |
2700 | remote->insertAddressee( inR, false ); | 2700 | remote->insertAddressee( inR, false ); |
2701 | } | 2701 | } |
2702 | } | 2702 | } |
2703 | } else { | 2703 | } else { |
2704 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2704 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2705 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2705 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2706 | local->removeAddressee( inL ); | 2706 | local->removeAddressee( inL ); |
2707 | ++deletedAddresseeL; | 2707 | ++deletedAddresseeL; |
2708 | } else { | 2708 | } else { |
2709 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2709 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2710 | ++addedAddresseeR; | 2710 | ++addedAddresseeR; |
2711 | inL.setRevision( modifiedCalendar ); | 2711 | inL.setRevision( modifiedCalendar ); |
2712 | local->insertAddressee( inL, false ); | 2712 | local->insertAddressee( inL, false ); |
2713 | inR = inL; | 2713 | inR = inL; |
2714 | inR.setResource( 0 ); | 2714 | inR.setResource( 0 ); |
2715 | remote->insertAddressee( inR, false ); | 2715 | remote->insertAddressee( inR, false ); |
2716 | } | 2716 | } |
2717 | } | 2717 | } |
2718 | } | 2718 | } |
2719 | } | 2719 | } |
2720 | } | 2720 | } |
2721 | } | 2721 | } |
2722 | ++incCounter; | 2722 | ++incCounter; |
2723 | } | 2723 | } |
2724 | el.clear(); | 2724 | el.clear(); |
2725 | syncManager->hideProgressBar(); | 2725 | syncManager->hideProgressBar(); |
2726 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2726 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2727 | // get rid of micro seconds | 2727 | // get rid of micro seconds |
2728 | QTime t = mLastAddressbookSync.time(); | 2728 | QTime t = mLastAddressbookSync.time(); |
2729 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2729 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2730 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2730 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2731 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2731 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2732 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2732 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2733 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2733 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2734 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2734 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2735 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2735 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2736 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2736 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2737 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2737 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2738 | addresseeRSync.setNote( "" ) ; | 2738 | addresseeRSync.setNote( "" ) ; |
2739 | addresseeLSync.setNote( "" ); | 2739 | addresseeLSync.setNote( "" ); |
2740 | 2740 | ||
2741 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2741 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2742 | remote->insertAddressee( addresseeRSync, false ); | 2742 | remote->insertAddressee( addresseeRSync, false ); |
2743 | local->insertAddressee( addresseeLSync, false ); | 2743 | local->insertAddressee( addresseeLSync, false ); |
2744 | QString mes; | 2744 | QString mes; |
2745 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); | 2745 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); |
2746 | if ( syncManager->mShowSyncSummary ) { | 2746 | if ( syncManager->mShowSyncSummary ) { |
2747 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | 2747 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); |
2748 | } | 2748 | } |
2749 | qDebug( mes ); | 2749 | qDebug( mes ); |
2750 | return syncOK; | 2750 | return syncOK; |
2751 | } | 2751 | } |
2752 | 2752 | ||
2753 | 2753 | ||
2754 | //this is a overwritten callbackmethods from the syncinterface | 2754 | //this is a overwritten callbackmethods from the syncinterface |
2755 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 2755 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
2756 | { | 2756 | { |
2757 | 2757 | ||
2758 | //pending prepare addresseeview for output | 2758 | //pending prepare addresseeview for output |
2759 | //pending detect, if remote file has REV field. if not switch to external sync | 2759 | //pending detect, if remote file has REV field. if not switch to external sync |
2760 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2760 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2761 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2761 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2762 | 2762 | ||
2763 | AddressBook abLocal(filename,"syncContact"); | 2763 | AddressBook abLocal(filename,"syncContact"); |
2764 | bool syncOK = false; | 2764 | bool syncOK = false; |
2765 | if ( abLocal.load() ) { | 2765 | if ( abLocal.load() ) { |
2766 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 2766 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2767 | bool external = false; | 2767 | bool external = false; |
2768 | bool isXML = false; | 2768 | bool isXML = false; |
2769 | if ( filename.right(4) == ".xml") { | 2769 | if ( filename.right(4) == ".xml") { |
2770 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2770 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2771 | isXML = true; | 2771 | isXML = true; |
2772 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 2772 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
2773 | } else { | 2773 | } else { |
2774 | external = !manager->mIsKapiFile; | 2774 | external = !manager->mIsKapiFile; |
2775 | if ( external ) { | 2775 | if ( external ) { |
2776 | qDebug("Setting vcf mode to external "); | 2776 | qDebug("Setting vcf mode to external "); |
2777 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2777 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2778 | AddressBook::Iterator it; | 2778 | AddressBook::Iterator it; |
2779 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2779 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2780 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2780 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2781 | (*it).computeCsum( mCurrentSyncDevice ); | 2781 | (*it).computeCsum( mCurrentSyncDevice ); |
2782 | } | 2782 | } |
2783 | } | 2783 | } |
2784 | } | 2784 | } |
2785 | //AddressBook::Iterator it; | 2785 | //AddressBook::Iterator it; |
2786 | //QStringList vcards; | 2786 | //QStringList vcards; |
2787 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2787 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2788 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2788 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2789 | //} | 2789 | //} |
2790 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2790 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2791 | if ( syncOK ) { | 2791 | if ( syncOK ) { |
2792 | if ( syncManager->mWriteBackFile ) | 2792 | if ( syncManager->mWriteBackFile ) |
2793 | { | 2793 | { |
2794 | if ( external ) | 2794 | if ( external ) |
2795 | abLocal.removeSyncAddressees( !isXML); | 2795 | abLocal.removeSyncAddressees( !isXML); |
2796 | qDebug("Saving remote AB "); | 2796 | qDebug("Saving remote AB "); |
2797 | if ( ! abLocal.saveAB()) | 2797 | if ( ! abLocal.saveAB()) |
2798 | qDebug("Error writing back AB to file "); | 2798 | qDebug("Error writing back AB to file "); |
2799 | if ( isXML ) { | 2799 | if ( isXML ) { |
2800 | // afterwrite processing | 2800 | // afterwrite processing |
2801 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2801 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2802 | } | 2802 | } |
2803 | } | 2803 | } |
2804 | } | 2804 | } |
2805 | setModified(); | 2805 | setModified(); |
2806 | 2806 | ||
2807 | } | 2807 | } |
2808 | if ( syncOK ) | 2808 | if ( syncOK ) |
2809 | mViewManager->refreshView(); | 2809 | mViewManager->refreshView(); |
2810 | return syncOK; | 2810 | return syncOK; |
2811 | 2811 | ||
2812 | } | 2812 | } |
2813 | void KABCore::removeSyncInfo( QString syncProfile) | ||
2814 | { | ||
2815 | qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); | ||
2816 | |||
2817 | } | ||
2813 | 2818 | ||
2814 | 2819 | ||
2815 | //this is a overwritten callbackmethods from the syncinterface | 2820 | //this is a overwritten callbackmethods from the syncinterface |
2816 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 2821 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
2817 | { | 2822 | { |
2818 | if ( resource == "phone" ) | 2823 | if ( resource == "phone" ) |
2819 | return syncPhone(); | 2824 | return syncPhone(); |
2820 | disableBR( true ); | 2825 | disableBR( true ); |
2821 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2826 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2822 | 2827 | ||
2823 | AddressBook abLocal( resource,"syncContact"); | 2828 | AddressBook abLocal( resource,"syncContact"); |
2824 | bool syncOK = false; | 2829 | bool syncOK = false; |
2825 | if ( abLocal.load() ) { | 2830 | if ( abLocal.load() ) { |
2826 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2831 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2827 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2832 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2828 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 2833 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
2829 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2834 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2830 | if ( syncOK ) { | 2835 | if ( syncOK ) { |
2831 | if ( syncManager->mWriteBackFile ) { | 2836 | if ( syncManager->mWriteBackFile ) { |
2832 | abLocal.removeSyncAddressees( false ); | 2837 | abLocal.removeSyncAddressees( false ); |
2833 | abLocal.saveAB(); | 2838 | abLocal.saveAB(); |
2834 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2839 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2835 | } | 2840 | } |
2836 | } | 2841 | } |
2837 | setModified(); | 2842 | setModified(); |
2838 | } | 2843 | } |
2839 | if ( syncOK ) | 2844 | if ( syncOK ) |
2840 | mViewManager->refreshView(); | 2845 | mViewManager->refreshView(); |
2841 | disableBR( false ); | 2846 | disableBR( false ); |
2842 | return syncOK; | 2847 | return syncOK; |
2843 | 2848 | ||
2844 | } | 2849 | } |
2845 | void KABCore::message( QString m ) | 2850 | void KABCore::message( QString m ) |
2846 | { | 2851 | { |
2847 | topLevelWidget()->setCaption( m ); | 2852 | topLevelWidget()->setCaption( m ); |
2848 | mMessageTimer->start( 15000, true ); | 2853 | mMessageTimer->start( 15000, true ); |
2849 | } | 2854 | } |
2850 | bool KABCore::syncPhone() | 2855 | bool KABCore::syncPhone() |
2851 | { | 2856 | { |
2852 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2857 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2853 | QString fileName = getPhoneFile(); | 2858 | QString fileName = getPhoneFile(); |
2854 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 2859 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
2855 | message(i18n("Phone access failed!")); | 2860 | message(i18n("Phone access failed!")); |
2856 | return false; | 2861 | return false; |
2857 | } | 2862 | } |
2858 | AddressBook abLocal( fileName,"syncContact"); | 2863 | AddressBook abLocal( fileName,"syncContact"); |
2859 | bool syncOK = false; | 2864 | bool syncOK = false; |
2860 | { | 2865 | { |
2861 | abLocal.importFromFile( fileName ); | 2866 | abLocal.importFromFile( fileName ); |
2862 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2867 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2863 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2868 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2864 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 2869 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
2865 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 2870 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
2866 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2871 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2867 | if ( syncOK ) { | 2872 | if ( syncOK ) { |
2868 | if ( syncManager->mWriteBackFile ) { | 2873 | if ( syncManager->mWriteBackFile ) { |
2869 | abLocal.removeSyncAddressees( true ); | 2874 | abLocal.removeSyncAddressees( true ); |
2870 | abLocal.saveABphone( fileName ); | 2875 | abLocal.saveABphone( fileName ); |
2871 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 2876 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
2872 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 2877 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
2873 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2878 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2874 | } | 2879 | } |
2875 | } | 2880 | } |
2876 | setModified(); | 2881 | setModified(); |
2877 | } | 2882 | } |
2878 | if ( syncOK ) | 2883 | if ( syncOK ) |
2879 | mViewManager->refreshView(); | 2884 | mViewManager->refreshView(); |
2880 | return syncOK; | 2885 | return syncOK; |
2881 | } | 2886 | } |
2882 | void KABCore::getFile( bool success ) | 2887 | void KABCore::getFile( bool success ) |
2883 | { | 2888 | { |
2884 | if ( ! success ) { | 2889 | if ( ! success ) { |
2885 | message( i18n("Error receiving file. Nothing changed!") ); | 2890 | message( i18n("Error receiving file. Nothing changed!") ); |
2886 | return; | 2891 | return; |
2887 | } | 2892 | } |
2888 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); | 2893 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); |
2889 | if ( count ) | 2894 | if ( count ) |
2890 | setModified( true ); | 2895 | setModified( true ); |
2891 | message( i18n("Pi-Sync successful!") ); | 2896 | message( i18n("Pi-Sync successful!") ); |
2892 | mViewManager->refreshView(); | 2897 | mViewManager->refreshView(); |
2893 | } | 2898 | } |
2894 | void KABCore::syncFileRequest() | 2899 | void KABCore::syncFileRequest() |
2895 | { | 2900 | { |
2896 | mAddressBook->export2File( sentSyncFile() ); | 2901 | mAddressBook->export2File( sentSyncFile() ); |
2897 | } | 2902 | } |
2898 | QString KABCore::sentSyncFile() | 2903 | QString KABCore::sentSyncFile() |
2899 | { | 2904 | { |
2900 | #ifdef DESKTOP_VERSION | 2905 | #ifdef DESKTOP_VERSION |
2901 | return locateLocal( "tmp", "copysyncab.vcf" ); | 2906 | return locateLocal( "tmp", "copysyncab.vcf" ); |
2902 | #else | 2907 | #else |
2903 | return QString( "/tmp/copysyncab.vcf" ); | 2908 | return QString( "/tmp/copysyncab.vcf" ); |
2904 | #endif | 2909 | #endif |
2905 | } | 2910 | } |
2906 | 2911 | ||
2907 | void KABCore::setCaptionBack() | 2912 | void KABCore::setCaptionBack() |
2908 | { | 2913 | { |
2909 | mMessageTimer->stop(); | 2914 | mMessageTimer->stop(); |
2910 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); | 2915 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); |
2911 | } | 2916 | } |
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index fcbe1e8..a288505 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h | |||
@@ -1,502 +1,503 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook. | 2 | This file is part of KAddressbook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #ifndef KABCORE_H | 24 | #ifndef KABCORE_H |
25 | #define KABCORE_H | 25 | #define KABCORE_H |
26 | 26 | ||
27 | #include <kabc/field.h> | 27 | #include <kabc/field.h> |
28 | 28 | ||
29 | #ifndef KAB_EMBEDDED | 29 | #ifndef KAB_EMBEDDED |
30 | #endif //KAB_EMBEDDED | 30 | #endif //KAB_EMBEDDED |
31 | #include <qdict.h> | 31 | #include <qdict.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | 33 | ||
34 | #include <qwidget.h> | 34 | #include <qwidget.h> |
35 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
36 | #include <ksyncmanager.h> | 36 | #include <ksyncmanager.h> |
37 | #ifndef DESKTOP_VERSION | 37 | #ifndef DESKTOP_VERSION |
38 | #include <qcopchannel_qws.h> | 38 | #include <qcopchannel_qws.h> |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | namespace KABC { | 41 | namespace KABC { |
42 | class AddressBook; | 42 | class AddressBook; |
43 | } | 43 | } |
44 | 44 | ||
45 | #ifndef KAB_EMBEDDED | 45 | #ifndef KAB_EMBEDDED |
46 | class KAboutData; | 46 | class KAboutData; |
47 | class KConfig; | 47 | class KConfig; |
48 | 48 | ||
49 | class KAddressBookService; | 49 | class KAddressBookService; |
50 | class LDAPSearchDialog; | 50 | class LDAPSearchDialog; |
51 | #else //KAB_EMBEDDED | 51 | #else //KAB_EMBEDDED |
52 | class KAddressBookMain; | 52 | class KAddressBookMain; |
53 | //US class QAction; | 53 | //US class QAction; |
54 | #endif //KAB_EMBEDDED | 54 | #endif //KAB_EMBEDDED |
55 | class KCMultiDialog; | 55 | class KCMultiDialog; |
56 | class KXMLGUIClient; | 56 | class KXMLGUIClient; |
57 | class ExtensionManager; | 57 | class ExtensionManager; |
58 | class XXPortManager; | 58 | class XXPortManager; |
59 | class JumpButtonBar; | 59 | class JumpButtonBar; |
60 | class IncSearchWidget; | 60 | class IncSearchWidget; |
61 | class KDGanttMinimizeSplitter; | 61 | class KDGanttMinimizeSplitter; |
62 | class KAction; | 62 | class KAction; |
63 | class KActionCollection; | 63 | class KActionCollection; |
64 | class KToggleAction; | 64 | class KToggleAction; |
65 | class KSyncProfile; | 65 | class KSyncProfile; |
66 | 66 | ||
67 | class QAction; | 67 | class QAction; |
68 | class QMenuBar; | 68 | class QMenuBar; |
69 | class QSplitter; | 69 | class QSplitter; |
70 | class ViewContainer; | 70 | class ViewContainer; |
71 | class ViewManager; | 71 | class ViewManager; |
72 | class AddresseeEditorDialog; | 72 | class AddresseeEditorDialog; |
73 | class Ir; | 73 | class Ir; |
74 | 74 | ||
75 | class KABCore : public QWidget, public KSyncInterface | 75 | class KABCore : public QWidget, public KSyncInterface |
76 | { | 76 | { |
77 | Q_OBJECT | 77 | Q_OBJECT |
78 | 78 | ||
79 | public: | 79 | public: |
80 | KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); | 80 | KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); |
81 | 81 | ||
82 | 82 | ||
83 | ~KABCore(); | 83 | ~KABCore(); |
84 | 84 | ||
85 | 85 | ||
86 | #ifdef KAB_EMBEDDED | 86 | #ifdef KAB_EMBEDDED |
87 | //US added functionality | 87 | //US added functionality |
88 | QPopupMenu* getViewMenu() {return viewMenu;} | 88 | QPopupMenu* getViewMenu() {return viewMenu;} |
89 | QPopupMenu* getFilterMenu() {return filterMenu;} | 89 | QPopupMenu* getFilterMenu() {return filterMenu;} |
90 | QPopupMenu* getSettingsMenu() {return settingsMenu;} | 90 | QPopupMenu* getSettingsMenu() {return settingsMenu;} |
91 | void addActionsManually(); | 91 | void addActionsManually(); |
92 | #endif //KAB_EMBEDDED | 92 | #endif //KAB_EMBEDDED |
93 | /** | 93 | /** |
94 | Restores the global settings. | 94 | Restores the global settings. |
95 | */ | 95 | */ |
96 | void restoreSettings(); | 96 | void restoreSettings(); |
97 | 97 | ||
98 | /** | 98 | /** |
99 | Saves the global settings. | 99 | Saves the global settings. |
100 | */ | 100 | */ |
101 | void saveSettings(); | 101 | void saveSettings(); |
102 | 102 | ||
103 | /** | 103 | /** |
104 | Returns a pointer to the StdAddressBook of the application. | 104 | Returns a pointer to the StdAddressBook of the application. |
105 | */ | 105 | */ |
106 | KABC::AddressBook *addressBook() const; | 106 | KABC::AddressBook *addressBook() const; |
107 | 107 | ||
108 | /** | 108 | /** |
109 | Returns a pointer to the KConfig object of the application. | 109 | Returns a pointer to the KConfig object of the application. |
110 | */ | 110 | */ |
111 | static KConfig *config(); | 111 | static KConfig *config(); |
112 | 112 | ||
113 | /** | 113 | /** |
114 | Returns a pointer to the global KActionCollection object. So | 114 | Returns a pointer to the global KActionCollection object. So |
115 | other classes can register their actions easily. | 115 | other classes can register their actions easily. |
116 | */ | 116 | */ |
117 | KActionCollection *actionCollection() const; | 117 | KActionCollection *actionCollection() const; |
118 | 118 | ||
119 | /** | 119 | /** |
120 | Returns the current search field of the Incremental Search Widget. | 120 | Returns the current search field of the Incremental Search Widget. |
121 | */ | 121 | */ |
122 | KABC::Field *currentSearchField() const; | 122 | KABC::Field *currentSearchField() const; |
123 | 123 | ||
124 | /** | 124 | /** |
125 | Returns the uid list of the currently selected contacts. | 125 | Returns the uid list of the currently selected contacts. |
126 | */ | 126 | */ |
127 | QStringList selectedUIDs() const; | 127 | QStringList selectedUIDs() const; |
128 | 128 | ||
129 | /** | 129 | /** |
130 | Displays the ResourceSelectDialog and returns the selected | 130 | Displays the ResourceSelectDialog and returns the selected |
131 | resource or a null pointer if no resource was selected by | 131 | resource or a null pointer if no resource was selected by |
132 | the user. | 132 | the user. |
133 | */ | 133 | */ |
134 | KABC::Resource *requestResource( QWidget *parent ); | 134 | KABC::Resource *requestResource( QWidget *parent ); |
135 | 135 | ||
136 | #ifndef KAB_EMBEDDED | 136 | #ifndef KAB_EMBEDDED |
137 | static KAboutData *createAboutData(); | 137 | static KAboutData *createAboutData(); |
138 | #endif //KAB_EMBEDDED | 138 | #endif //KAB_EMBEDDED |
139 | 139 | ||
140 | #ifdef KAB_EMBEDDED | 140 | #ifdef KAB_EMBEDDED |
141 | inline QPopupMenu* getImportMenu() { return ImportMenu;} | 141 | inline QPopupMenu* getImportMenu() { return ImportMenu;} |
142 | inline QPopupMenu* getExportMenu() { return ExportMenu;} | 142 | inline QPopupMenu* getExportMenu() { return ExportMenu;} |
143 | #endif //KAB_EMBEDDED | 143 | #endif //KAB_EMBEDDED |
144 | 144 | ||
145 | public slots: | 145 | public slots: |
146 | #ifdef KAB_EMBEDDED | 146 | #ifdef KAB_EMBEDDED |
147 | void createAboutData(); | 147 | void createAboutData(); |
148 | #endif //KAB_EMBEDDED | 148 | #endif //KAB_EMBEDDED |
149 | 149 | ||
150 | void showLicence(); | 150 | void showLicence(); |
151 | void faq(); | 151 | void faq(); |
152 | void whatsnew() ; | 152 | void whatsnew() ; |
153 | void synchowto() ; | 153 | void synchowto() ; |
154 | void writeToPhone(); | 154 | void writeToPhone(); |
155 | 155 | ||
156 | /** | 156 | /** |
157 | Is called whenever a contact is selected in the view. | 157 | Is called whenever a contact is selected in the view. |
158 | */ | 158 | */ |
159 | void setContactSelected( const QString &uid ); | 159 | void setContactSelected( const QString &uid ); |
160 | 160 | ||
161 | /** | 161 | /** |
162 | Opens the preferred mail composer with all selected contacts as | 162 | Opens the preferred mail composer with all selected contacts as |
163 | arguments. | 163 | arguments. |
164 | */ | 164 | */ |
165 | void sendMail(); | 165 | void sendMail(); |
166 | 166 | ||
167 | /** | 167 | /** |
168 | Opens the preferred mail composer with the given contacts as | 168 | Opens the preferred mail composer with the given contacts as |
169 | arguments. | 169 | arguments. |
170 | */ | 170 | */ |
171 | void sendMail( const QString& email ); | 171 | void sendMail( const QString& email ); |
172 | 172 | ||
173 | 173 | ||
174 | void mailVCard(); | 174 | void mailVCard(); |
175 | void mailVCard(const QStringList& uids); | 175 | void mailVCard(const QStringList& uids); |
176 | 176 | ||
177 | /** | 177 | /** |
178 | Beams the "WhoAmI contact. | 178 | Beams the "WhoAmI contact. |
179 | */ | 179 | */ |
180 | void beamMySelf(); | 180 | void beamMySelf(); |
181 | 181 | ||
182 | void beamVCard(); | 182 | void beamVCard(); |
183 | void export2phone(); | 183 | void export2phone(); |
184 | void beamVCard(const QStringList& uids); | 184 | void beamVCard(const QStringList& uids); |
185 | void beamDone( Ir *ir ); | 185 | void beamDone( Ir *ir ); |
186 | 186 | ||
187 | 187 | ||
188 | /** | 188 | /** |
189 | Starts the preferred web browser with the given URL as argument. | 189 | Starts the preferred web browser with the given URL as argument. |
190 | */ | 190 | */ |
191 | void browse( const QString& url ); | 191 | void browse( const QString& url ); |
192 | 192 | ||
193 | /** | 193 | /** |
194 | Select all contacts in the view. | 194 | Select all contacts in the view. |
195 | */ | 195 | */ |
196 | void selectAllContacts(); | 196 | void selectAllContacts(); |
197 | 197 | ||
198 | /** | 198 | /** |
199 | Deletes all selected contacts from the address book. | 199 | Deletes all selected contacts from the address book. |
200 | */ | 200 | */ |
201 | void deleteContacts(); | 201 | void deleteContacts(); |
202 | 202 | ||
203 | /** | 203 | /** |
204 | Deletes given contacts from the address book. | 204 | Deletes given contacts from the address book. |
205 | 205 | ||
206 | @param uids The uids of the contacts, which shall be deleted. | 206 | @param uids The uids of the contacts, which shall be deleted. |
207 | */ | 207 | */ |
208 | void deleteContacts( const QStringList &uids ); | 208 | void deleteContacts( const QStringList &uids ); |
209 | 209 | ||
210 | /** | 210 | /** |
211 | Copys the selected contacts into clipboard for later pasting. | 211 | Copys the selected contacts into clipboard for later pasting. |
212 | */ | 212 | */ |
213 | void copyContacts(); | 213 | void copyContacts(); |
214 | 214 | ||
215 | /** | 215 | /** |
216 | Cuts the selected contacts and stores them for later pasting. | 216 | Cuts the selected contacts and stores them for later pasting. |
217 | */ | 217 | */ |
218 | void cutContacts(); | 218 | void cutContacts(); |
219 | 219 | ||
220 | /** | 220 | /** |
221 | Paste contacts from clipboard into the address book. | 221 | Paste contacts from clipboard into the address book. |
222 | */ | 222 | */ |
223 | void pasteContacts(); | 223 | void pasteContacts(); |
224 | 224 | ||
225 | /** | 225 | /** |
226 | Paste given contacts into the address book. | 226 | Paste given contacts into the address book. |
227 | 227 | ||
228 | @param list The list of addressee, which shall be pasted. | 228 | @param list The list of addressee, which shall be pasted. |
229 | */ | 229 | */ |
230 | void pasteContacts( KABC::Addressee::List &list ); | 230 | void pasteContacts( KABC::Addressee::List &list ); |
231 | 231 | ||
232 | /** | 232 | /** |
233 | Sets the whoAmI contact, that is used by many other programs to | 233 | Sets the whoAmI contact, that is used by many other programs to |
234 | get personal information about the current user. | 234 | get personal information about the current user. |
235 | */ | 235 | */ |
236 | void setWhoAmI(); | 236 | void setWhoAmI(); |
237 | 237 | ||
238 | /** | 238 | /** |
239 | Displays the category dialog and applies the result to all | 239 | Displays the category dialog and applies the result to all |
240 | selected contacts. | 240 | selected contacts. |
241 | */ | 241 | */ |
242 | void setCategories(); | 242 | void setCategories(); |
243 | 243 | ||
244 | /** | 244 | /** |
245 | Sets the field list of the Incremental Search Widget. | 245 | Sets the field list of the Incremental Search Widget. |
246 | */ | 246 | */ |
247 | void setSearchFields( const KABC::Field::List &fields ); | 247 | void setSearchFields( const KABC::Field::List &fields ); |
248 | 248 | ||
249 | /** | 249 | /** |
250 | Search with the current search field for a contact, that matches | 250 | Search with the current search field for a contact, that matches |
251 | the given text, and selects it in the view. | 251 | the given text, and selects it in the view. |
252 | */ | 252 | */ |
253 | void incrementalSearch( const QString& text ); | 253 | void incrementalSearch( const QString& text ); |
254 | 254 | ||
255 | /** | 255 | /** |
256 | Marks the address book as modified. | 256 | Marks the address book as modified. |
257 | */ | 257 | */ |
258 | void setModified(); | 258 | void setModified(); |
259 | /** | 259 | /** |
260 | Marks the address book as modified without refreshing the view. | 260 | Marks the address book as modified without refreshing the view. |
261 | */ | 261 | */ |
262 | void setModifiedWOrefresh(); | 262 | void setModifiedWOrefresh(); |
263 | 263 | ||
264 | /** | 264 | /** |
265 | Marks the address book as modified concerning the argument. | 265 | Marks the address book as modified concerning the argument. |
266 | */ | 266 | */ |
267 | void setModified( bool modified ); | 267 | void setModified( bool modified ); |
268 | 268 | ||
269 | /** | 269 | /** |
270 | Returns whether the address book is modified. | 270 | Returns whether the address book is modified. |
271 | */ | 271 | */ |
272 | bool modified() const; | 272 | bool modified() const; |
273 | 273 | ||
274 | /** | 274 | /** |
275 | Called whenever an contact is modified in the contact editor | 275 | Called whenever an contact is modified in the contact editor |
276 | dialog or the quick edit. | 276 | dialog or the quick edit. |
277 | */ | 277 | */ |
278 | void contactModified( const KABC::Addressee &addr ); | 278 | void contactModified( const KABC::Addressee &addr ); |
279 | 279 | ||
280 | /** | 280 | /** |
281 | DCOP METHODS. | 281 | DCOP METHODS. |
282 | */ | 282 | */ |
283 | void addEmail( QString addr ); | 283 | void addEmail( QString addr ); |
284 | void importVCard( const KURL& url, bool showPreview ); | 284 | void importVCard( const KURL& url, bool showPreview ); |
285 | void importVCard( const QString& vCard, bool showPreview ); | 285 | void importVCard( const QString& vCard, bool showPreview ); |
286 | void newContact(); | 286 | void newContact(); |
287 | QString getNameByPhone( const QString& phone ); | 287 | QString getNameByPhone( const QString& phone ); |
288 | /** | 288 | /** |
289 | END DCOP METHODS | 289 | END DCOP METHODS |
290 | */ | 290 | */ |
291 | 291 | ||
292 | /** | 292 | /** |
293 | Saves the contents of the AddressBook back to disk. | 293 | Saves the contents of the AddressBook back to disk. |
294 | */ | 294 | */ |
295 | void save(); | 295 | void save(); |
296 | 296 | ||
297 | /** | 297 | /** |
298 | Undos the last command using the undo stack. | 298 | Undos the last command using the undo stack. |
299 | */ | 299 | */ |
300 | void undo(); | 300 | void undo(); |
301 | 301 | ||
302 | /** | 302 | /** |
303 | Redos the last command that was undone, using the redo stack. | 303 | Redos the last command that was undone, using the redo stack. |
304 | */ | 304 | */ |
305 | void redo(); | 305 | void redo(); |
306 | 306 | ||
307 | /** | 307 | /** |
308 | Shows the edit dialog for the given uid. If the uid is QString::null, | 308 | Shows the edit dialog for the given uid. If the uid is QString::null, |
309 | the method will try to find a selected addressee in the view. | 309 | the method will try to find a selected addressee in the view. |
310 | */ | 310 | */ |
311 | void editContact( const QString &uid /*US = QString::null*/ ); | 311 | void editContact( const QString &uid /*US = QString::null*/ ); |
312 | //US added a second method without defaultparameter | 312 | //US added a second method without defaultparameter |
313 | void editContact2(); | 313 | void editContact2(); |
314 | 314 | ||
315 | /** | 315 | /** |
316 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 316 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
317 | the method will try to find a selected addressee in the view. | 317 | the method will try to find a selected addressee in the view. |
318 | */ | 318 | */ |
319 | void executeContact( const QString &uid /*US = QString::null*/ ); | 319 | void executeContact( const QString &uid /*US = QString::null*/ ); |
320 | 320 | ||
321 | /** | 321 | /** |
322 | Launches the configuration dialog. | 322 | Launches the configuration dialog. |
323 | */ | 323 | */ |
324 | void openConfigDialog(); | 324 | void openConfigDialog(); |
325 | 325 | ||
326 | /** | 326 | /** |
327 | Launches the ldap search dialog. | 327 | Launches the ldap search dialog. |
328 | */ | 328 | */ |
329 | void openLDAPDialog(); | 329 | void openLDAPDialog(); |
330 | 330 | ||
331 | /** | 331 | /** |
332 | Creates a KAddressBookPrinter, which will display the print | 332 | Creates a KAddressBookPrinter, which will display the print |
333 | dialog and do the printing. | 333 | dialog and do the printing. |
334 | */ | 334 | */ |
335 | void print(); | 335 | void print(); |
336 | 336 | ||
337 | /** | 337 | /** |
338 | Registers a new GUI client, so plugins can register its actions. | 338 | Registers a new GUI client, so plugins can register its actions. |
339 | */ | 339 | */ |
340 | void addGUIClient( KXMLGUIClient *client ); | 340 | void addGUIClient( KXMLGUIClient *client ); |
341 | 341 | ||
342 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); | 342 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); |
343 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); | 343 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); |
344 | void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); | 344 | void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); |
345 | 345 | ||
346 | 346 | ||
347 | signals: | 347 | signals: |
348 | void contactSelected( const QString &name ); | 348 | void contactSelected( const QString &name ); |
349 | void contactSelected( const QPixmap &pixmap ); | 349 | void contactSelected( const QPixmap &pixmap ); |
350 | public slots: | 350 | public slots: |
351 | void recieve(QString cmsg ); | 351 | void recieve(QString cmsg ); |
352 | void getFile( bool success ); | 352 | void getFile( bool success ); |
353 | void syncFileRequest(); | 353 | void syncFileRequest(); |
354 | void setDetailsVisible( bool visible ); | 354 | void setDetailsVisible( bool visible ); |
355 | void setDetailsToState(); | 355 | void setDetailsToState(); |
356 | // void slotSyncMenu( int ); | 356 | // void slotSyncMenu( int ); |
357 | private slots: | 357 | private slots: |
358 | void receive( const QCString& cmsg, const QByteArray& data ); | 358 | void receive( const QCString& cmsg, const QByteArray& data ); |
359 | void toggleBeamReceive( ); | 359 | void toggleBeamReceive( ); |
360 | void disableBR(bool); | 360 | void disableBR(bool); |
361 | void setJumpButtonBarVisible( bool visible ); | 361 | void setJumpButtonBarVisible( bool visible ); |
362 | void setCaptionBack(); | 362 | void setCaptionBack(); |
363 | void importFromOL(); | 363 | void importFromOL(); |
364 | void extensionModified( const KABC::Addressee::List &list ); | 364 | void extensionModified( const KABC::Addressee::List &list ); |
365 | void extensionChanged( int id ); | 365 | void extensionChanged( int id ); |
366 | void clipboardDataChanged(); | 366 | void clipboardDataChanged(); |
367 | void updateActionMenu(); | 367 | void updateActionMenu(); |
368 | void configureKeyBindings(); | 368 | void configureKeyBindings(); |
369 | void removeVoice(); | 369 | void removeVoice(); |
370 | #ifdef KAB_EMBEDDED | 370 | #ifdef KAB_EMBEDDED |
371 | void configureResources(); | 371 | void configureResources(); |
372 | #endif //KAB_EMBEDDED | 372 | #endif //KAB_EMBEDDED |
373 | 373 | ||
374 | void slotEditorDestroyed( const QString &uid ); | 374 | void slotEditorDestroyed( const QString &uid ); |
375 | void configurationChanged(); | 375 | void configurationChanged(); |
376 | void addressBookChanged(); | 376 | void addressBookChanged(); |
377 | 377 | ||
378 | private: | 378 | private: |
379 | bool mBRdisabled; | 379 | bool mBRdisabled; |
380 | #ifndef DESKTOP_VERSION | 380 | #ifndef DESKTOP_VERSION |
381 | QCopChannel* infrared; | 381 | QCopChannel* infrared; |
382 | #endif | 382 | #endif |
383 | QTimer *mMessageTimer; | 383 | QTimer *mMessageTimer; |
384 | void initGUI(); | 384 | void initGUI(); |
385 | void initActions(); | 385 | void initActions(); |
386 | QString getPhoneFile(); | 386 | QString getPhoneFile(); |
387 | 387 | ||
388 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, | 388 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, |
389 | const char *name = 0 ); | 389 | const char *name = 0 ); |
390 | 390 | ||
391 | KXMLGUIClient *mGUIClient; | 391 | KXMLGUIClient *mGUIClient; |
392 | 392 | ||
393 | KABC::AddressBook *mAddressBook; | 393 | KABC::AddressBook *mAddressBook; |
394 | 394 | ||
395 | ViewManager *mViewManager; | 395 | ViewManager *mViewManager; |
396 | // QSplitter *mDetailsSplitter; | 396 | // QSplitter *mDetailsSplitter; |
397 | KDGanttMinimizeSplitter *mExtensionBarSplitter; | 397 | KDGanttMinimizeSplitter *mExtensionBarSplitter; |
398 | ViewContainer *mDetails; | 398 | ViewContainer *mDetails; |
399 | KDGanttMinimizeSplitter* mMiniSplitter; | 399 | KDGanttMinimizeSplitter* mMiniSplitter; |
400 | XXPortManager *mXXPortManager; | 400 | XXPortManager *mXXPortManager; |
401 | JumpButtonBar *mJumpButtonBar; | 401 | JumpButtonBar *mJumpButtonBar; |
402 | IncSearchWidget *mIncSearchWidget; | 402 | IncSearchWidget *mIncSearchWidget; |
403 | ExtensionManager *mExtensionManager; | 403 | ExtensionManager *mExtensionManager; |
404 | 404 | ||
405 | KCMultiDialog *mConfigureDialog; | 405 | KCMultiDialog *mConfigureDialog; |
406 | 406 | ||
407 | #ifndef KAB_EMBEDDED | 407 | #ifndef KAB_EMBEDDED |
408 | LDAPSearchDialog *mLdapSearchDialog; | 408 | LDAPSearchDialog *mLdapSearchDialog; |
409 | #endif //KAB_EMBEDDED | 409 | #endif //KAB_EMBEDDED |
410 | // QDict<AddresseeEditorDialog> mEditorDict; | 410 | // QDict<AddresseeEditorDialog> mEditorDict; |
411 | AddresseeEditorDialog *mEditorDialog; | 411 | AddresseeEditorDialog *mEditorDialog; |
412 | bool mReadWrite; | 412 | bool mReadWrite; |
413 | bool mModified; | 413 | bool mModified; |
414 | bool mIsPart; | 414 | bool mIsPart; |
415 | bool mMultipleViewsAtOnce; | 415 | bool mMultipleViewsAtOnce; |
416 | 416 | ||
417 | 417 | ||
418 | //US file menu | 418 | //US file menu |
419 | KAction *mActionMail; | 419 | KAction *mActionMail; |
420 | KAction *mActionBeam; | 420 | KAction *mActionBeam; |
421 | KToggleAction *mActionBR; | 421 | KToggleAction *mActionBR; |
422 | KAction *mActionExport2phone; | 422 | KAction *mActionExport2phone; |
423 | KAction* mActionPrint; | 423 | KAction* mActionPrint; |
424 | KAction* mActionNewContact; | 424 | KAction* mActionNewContact; |
425 | KAction *mActionSave; | 425 | KAction *mActionSave; |
426 | KAction *mActionEditAddressee; | 426 | KAction *mActionEditAddressee; |
427 | KAction *mActionMailVCard; | 427 | KAction *mActionMailVCard; |
428 | KAction *mActionBeamVCard; | 428 | KAction *mActionBeamVCard; |
429 | 429 | ||
430 | KAction *mActionQuit; | 430 | KAction *mActionQuit; |
431 | 431 | ||
432 | //US edit menu | 432 | //US edit menu |
433 | KAction *mActionCopy; | 433 | KAction *mActionCopy; |
434 | KAction *mActionCut; | 434 | KAction *mActionCut; |
435 | KAction *mActionPaste; | 435 | KAction *mActionPaste; |
436 | KAction *mActionSelectAll; | 436 | KAction *mActionSelectAll; |
437 | KAction *mActionUndo; | 437 | KAction *mActionUndo; |
438 | KAction *mActionRedo; | 438 | KAction *mActionRedo; |
439 | KAction *mActionDelete; | 439 | KAction *mActionDelete; |
440 | 440 | ||
441 | //US settings menu | 441 | //US settings menu |
442 | KAction *mActionConfigResources; | 442 | KAction *mActionConfigResources; |
443 | KAction *mActionConfigKAddressbook; | 443 | KAction *mActionConfigKAddressbook; |
444 | KAction *mActionConfigShortcuts; | 444 | KAction *mActionConfigShortcuts; |
445 | KAction *mActionConfigureToolbars; | 445 | KAction *mActionConfigureToolbars; |
446 | KAction *mActionKeyBindings; | 446 | KAction *mActionKeyBindings; |
447 | KToggleAction *mActionJumpBar; | 447 | KToggleAction *mActionJumpBar; |
448 | KToggleAction *mActionDetails; | 448 | KToggleAction *mActionDetails; |
449 | KAction *mActionWhoAmI; | 449 | KAction *mActionWhoAmI; |
450 | KAction *mActionCategories; | 450 | KAction *mActionCategories; |
451 | KAction *mActionAboutKAddressbook; | 451 | KAction *mActionAboutKAddressbook; |
452 | KAction *mActionLicence; | 452 | KAction *mActionLicence; |
453 | KAction *mActionFaq; | 453 | KAction *mActionFaq; |
454 | KAction *mActionWN; | 454 | KAction *mActionWN; |
455 | KAction *mActionSyncHowto; | 455 | KAction *mActionSyncHowto; |
456 | 456 | ||
457 | KAction *mActionDeleteView; | 457 | KAction *mActionDeleteView; |
458 | 458 | ||
459 | QPopupMenu *viewMenu; | 459 | QPopupMenu *viewMenu; |
460 | QPopupMenu *filterMenu; | 460 | QPopupMenu *filterMenu; |
461 | QPopupMenu *settingsMenu; | 461 | QPopupMenu *settingsMenu; |
462 | QPopupMenu *changeMenu; | 462 | QPopupMenu *changeMenu; |
463 | //US QAction *mActionSave; | 463 | //US QAction *mActionSave; |
464 | QPopupMenu *ImportMenu; | 464 | QPopupMenu *ImportMenu; |
465 | QPopupMenu *ExportMenu; | 465 | QPopupMenu *ExportMenu; |
466 | //LR additional methods | 466 | //LR additional methods |
467 | KAction *mActionRemoveVoice; | 467 | KAction *mActionRemoveVoice; |
468 | KAction * mActionImportOL; | 468 | KAction * mActionImportOL; |
469 | 469 | ||
470 | #ifndef KAB_EMBEDDED | 470 | #ifndef KAB_EMBEDDED |
471 | KAddressBookService *mAddressBookService; | 471 | KAddressBookService *mAddressBookService; |
472 | #endif //KAB_EMBEDDED | 472 | #endif //KAB_EMBEDDED |
473 | 473 | ||
474 | class KABCorePrivate; | 474 | class KABCorePrivate; |
475 | KABCorePrivate *d; | 475 | KABCorePrivate *d; |
476 | //US bool mBlockSaveFlag; | 476 | //US bool mBlockSaveFlag; |
477 | 477 | ||
478 | #ifdef KAB_EMBEDDED | 478 | #ifdef KAB_EMBEDDED |
479 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient | 479 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient |
480 | #endif //KAB_EMBEDDED | 480 | #endif //KAB_EMBEDDED |
481 | 481 | ||
482 | //this are the overwritten callbackmethods from the syncinterface | 482 | //this are the overwritten callbackmethods from the syncinterface |
483 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 483 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
484 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 484 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
485 | virtual void removeSyncInfo( QString syncProfile); | ||
485 | bool syncPhone(); | 486 | bool syncPhone(); |
486 | void message( QString m ); | 487 | void message( QString m ); |
487 | 488 | ||
488 | // LR ******************************* | 489 | // LR ******************************* |
489 | // sync stuff! | 490 | // sync stuff! |
490 | QString sentSyncFile(); | 491 | QString sentSyncFile(); |
491 | QPopupMenu *syncMenu; | 492 | QPopupMenu *syncMenu; |
492 | KSyncManager* syncManager; | 493 | KSyncManager* syncManager; |
493 | int mGlobalSyncMode; | 494 | int mGlobalSyncMode; |
494 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); | 495 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); |
495 | KABC::Addressee getLastSyncAddressee(); | 496 | KABC::Addressee getLastSyncAddressee(); |
496 | QDateTime mLastAddressbookSync; | 497 | QDateTime mLastAddressbookSync; |
497 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); | 498 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); |
498 | // ********************* | 499 | // ********************* |
499 | 500 | ||
500 | }; | 501 | }; |
501 | 502 | ||
502 | #endif | 503 | #endif |
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 2ccccfa..af01625 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -2231,1536 +2231,1542 @@ void CalendarView::removeCategories() | |||
2231 | int i; | 2231 | int i; |
2232 | int count = 0; | 2232 | int count = 0; |
2233 | while ( inc ) { | 2233 | while ( inc ) { |
2234 | newCatList.clear(); | 2234 | newCatList.clear(); |
2235 | catIncList = inc->categories() ; | 2235 | catIncList = inc->categories() ; |
2236 | for( i = 0; i< catIncList.count(); ++i ) { | 2236 | for( i = 0; i< catIncList.count(); ++i ) { |
2237 | if ( catList.contains (catIncList[i])) | 2237 | if ( catList.contains (catIncList[i])) |
2238 | newCatList.append( catIncList[i] ); | 2238 | newCatList.append( catIncList[i] ); |
2239 | } | 2239 | } |
2240 | newCatList.sort(); | 2240 | newCatList.sort(); |
2241 | inc->setCategories( newCatList.join(",") ); | 2241 | inc->setCategories( newCatList.join(",") ); |
2242 | inc = incList.next(); | 2242 | inc = incList.next(); |
2243 | } | 2243 | } |
2244 | } | 2244 | } |
2245 | 2245 | ||
2246 | int CalendarView::addCategories() | 2246 | int CalendarView::addCategories() |
2247 | { | 2247 | { |
2248 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2248 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2249 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2249 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2250 | QStringList catIncList; | 2250 | QStringList catIncList; |
2251 | Incidence* inc = incList.first(); | 2251 | Incidence* inc = incList.first(); |
2252 | int i; | 2252 | int i; |
2253 | int count = 0; | 2253 | int count = 0; |
2254 | while ( inc ) { | 2254 | while ( inc ) { |
2255 | catIncList = inc->categories() ; | 2255 | catIncList = inc->categories() ; |
2256 | for( i = 0; i< catIncList.count(); ++i ) { | 2256 | for( i = 0; i< catIncList.count(); ++i ) { |
2257 | if ( !catList.contains (catIncList[i])) { | 2257 | if ( !catList.contains (catIncList[i])) { |
2258 | catList.append( catIncList[i] ); | 2258 | catList.append( catIncList[i] ); |
2259 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2259 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2260 | ++count; | 2260 | ++count; |
2261 | } | 2261 | } |
2262 | } | 2262 | } |
2263 | inc = incList.next(); | 2263 | inc = incList.next(); |
2264 | } | 2264 | } |
2265 | catList.sort(); | 2265 | catList.sort(); |
2266 | KOPrefs::instance()->mCustomCategories = catList; | 2266 | KOPrefs::instance()->mCustomCategories = catList; |
2267 | return count; | 2267 | return count; |
2268 | } | 2268 | } |
2269 | 2269 | ||
2270 | void CalendarView::manageCategories() | 2270 | void CalendarView::manageCategories() |
2271 | { | 2271 | { |
2272 | KOCatPrefs* cp = new KOCatPrefs(); | 2272 | KOCatPrefs* cp = new KOCatPrefs(); |
2273 | cp->show(); | 2273 | cp->show(); |
2274 | int w =cp->sizeHint().width() ; | 2274 | int w =cp->sizeHint().width() ; |
2275 | int h = cp->sizeHint().height() ; | 2275 | int h = cp->sizeHint().height() ; |
2276 | int dw = QApplication::desktop()->width(); | 2276 | int dw = QApplication::desktop()->width(); |
2277 | int dh = QApplication::desktop()->height(); | 2277 | int dh = QApplication::desktop()->height(); |
2278 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2278 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2279 | if ( !cp->exec() ) { | 2279 | if ( !cp->exec() ) { |
2280 | delete cp; | 2280 | delete cp; |
2281 | return; | 2281 | return; |
2282 | } | 2282 | } |
2283 | int count = 0; | 2283 | int count = 0; |
2284 | if ( cp->addCat() ) { | 2284 | if ( cp->addCat() ) { |
2285 | count = addCategories(); | 2285 | count = addCategories(); |
2286 | if ( count ) { | 2286 | if ( count ) { |
2287 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2287 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2288 | writeSettings(); | 2288 | writeSettings(); |
2289 | } | 2289 | } |
2290 | } else { | 2290 | } else { |
2291 | removeCategories(); | 2291 | removeCategories(); |
2292 | updateView(); | 2292 | updateView(); |
2293 | } | 2293 | } |
2294 | delete cp; | 2294 | delete cp; |
2295 | } | 2295 | } |
2296 | 2296 | ||
2297 | void CalendarView::beamIncidence(Incidence * Inc) | 2297 | void CalendarView::beamIncidence(Incidence * Inc) |
2298 | { | 2298 | { |
2299 | QPtrList<Incidence> delSel ; | 2299 | QPtrList<Incidence> delSel ; |
2300 | delSel.append(Inc); | 2300 | delSel.append(Inc); |
2301 | beamIncidenceList( delSel ); | 2301 | beamIncidenceList( delSel ); |
2302 | } | 2302 | } |
2303 | void CalendarView::beamCalendar() | 2303 | void CalendarView::beamCalendar() |
2304 | { | 2304 | { |
2305 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2305 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2306 | //qDebug("beamCalendar() "); | 2306 | //qDebug("beamCalendar() "); |
2307 | beamIncidenceList( delSel ); | 2307 | beamIncidenceList( delSel ); |
2308 | } | 2308 | } |
2309 | void CalendarView::beamFilteredCalendar() | 2309 | void CalendarView::beamFilteredCalendar() |
2310 | { | 2310 | { |
2311 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2311 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2312 | //qDebug("beamFilteredCalendar() "); | 2312 | //qDebug("beamFilteredCalendar() "); |
2313 | beamIncidenceList( delSel ); | 2313 | beamIncidenceList( delSel ); |
2314 | } | 2314 | } |
2315 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2315 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2316 | { | 2316 | { |
2317 | if ( beamDialog->exec () == QDialog::Rejected ) | 2317 | if ( beamDialog->exec () == QDialog::Rejected ) |
2318 | return; | 2318 | return; |
2319 | #ifdef DESKTOP_VERSION | 2319 | #ifdef DESKTOP_VERSION |
2320 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2320 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2321 | #else | 2321 | #else |
2322 | QString fn = "/tmp/kopibeamfile"; | 2322 | QString fn = "/tmp/kopibeamfile"; |
2323 | #endif | 2323 | #endif |
2324 | QString mes; | 2324 | QString mes; |
2325 | bool createbup = true; | 2325 | bool createbup = true; |
2326 | if ( createbup ) { | 2326 | if ( createbup ) { |
2327 | QString description = "\n"; | 2327 | QString description = "\n"; |
2328 | CalendarLocal* cal = new CalendarLocal(); | 2328 | CalendarLocal* cal = new CalendarLocal(); |
2329 | if ( beamDialog->beamLocal() ) | 2329 | if ( beamDialog->beamLocal() ) |
2330 | cal->setLocalTime(); | 2330 | cal->setLocalTime(); |
2331 | else | 2331 | else |
2332 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2332 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2333 | Incidence *incidence = delSel.first(); | 2333 | Incidence *incidence = delSel.first(); |
2334 | bool addText = false; | 2334 | bool addText = false; |
2335 | if ( delSel.count() < 10 ) | 2335 | if ( delSel.count() < 10 ) |
2336 | addText = true; | 2336 | addText = true; |
2337 | else { | 2337 | else { |
2338 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2338 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2339 | } | 2339 | } |
2340 | while ( incidence ) { | 2340 | while ( incidence ) { |
2341 | Incidence *in = incidence->clone(); | 2341 | Incidence *in = incidence->clone(); |
2342 | if ( ! in->summary().isEmpty() ) { | 2342 | if ( ! in->summary().isEmpty() ) { |
2343 | in->setDescription(""); | 2343 | in->setDescription(""); |
2344 | } else { | 2344 | } else { |
2345 | in->setSummary( in->description().left(20)); | 2345 | in->setSummary( in->description().left(20)); |
2346 | in->setDescription(""); | 2346 | in->setDescription(""); |
2347 | } | 2347 | } |
2348 | if ( addText ) | 2348 | if ( addText ) |
2349 | description += in->summary() + "\n"; | 2349 | description += in->summary() + "\n"; |
2350 | cal->addIncidence( in ); | 2350 | cal->addIncidence( in ); |
2351 | incidence = delSel.next(); | 2351 | incidence = delSel.next(); |
2352 | } | 2352 | } |
2353 | if ( beamDialog->beamVcal() ) { | 2353 | if ( beamDialog->beamVcal() ) { |
2354 | fn += ".vcs"; | 2354 | fn += ".vcs"; |
2355 | FileStorage storage( cal, fn, new VCalFormat ); | 2355 | FileStorage storage( cal, fn, new VCalFormat ); |
2356 | storage.save(); | 2356 | storage.save(); |
2357 | } else { | 2357 | } else { |
2358 | fn += ".ics"; | 2358 | fn += ".ics"; |
2359 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2359 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2360 | storage.save(); | 2360 | storage.save(); |
2361 | } | 2361 | } |
2362 | delete cal; | 2362 | delete cal; |
2363 | mes = i18n("KO/Pi: Ready for beaming"); | 2363 | mes = i18n("KO/Pi: Ready for beaming"); |
2364 | topLevelWidget()->setCaption(mes); | 2364 | topLevelWidget()->setCaption(mes); |
2365 | KApplication::convert2latin1( fn ); | 2365 | KApplication::convert2latin1( fn ); |
2366 | #ifndef DESKTOP_VERSION | 2366 | #ifndef DESKTOP_VERSION |
2367 | Ir *ir = new Ir( this ); | 2367 | Ir *ir = new Ir( this ); |
2368 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2368 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2369 | ir->send( fn, description, "text/x-vCalendar" ); | 2369 | ir->send( fn, description, "text/x-vCalendar" ); |
2370 | #endif | 2370 | #endif |
2371 | } | 2371 | } |
2372 | } | 2372 | } |
2373 | void CalendarView::beamDone( Ir *ir ) | 2373 | void CalendarView::beamDone( Ir *ir ) |
2374 | { | 2374 | { |
2375 | #ifndef DESKTOP_VERSION | 2375 | #ifndef DESKTOP_VERSION |
2376 | delete ir; | 2376 | delete ir; |
2377 | #endif | 2377 | #endif |
2378 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2378 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2379 | topLevelWidget()->raise(); | 2379 | topLevelWidget()->raise(); |
2380 | } | 2380 | } |
2381 | 2381 | ||
2382 | void CalendarView::moveIncidence(Incidence * inc ) | 2382 | void CalendarView::moveIncidence(Incidence * inc ) |
2383 | { | 2383 | { |
2384 | if ( !inc ) return; | 2384 | if ( !inc ) return; |
2385 | // qDebug("showDatePickerForIncidence( ) "); | 2385 | // qDebug("showDatePickerForIncidence( ) "); |
2386 | if ( mDateFrame->isVisible() ) | 2386 | if ( mDateFrame->isVisible() ) |
2387 | mDateFrame->hide(); | 2387 | mDateFrame->hide(); |
2388 | else { | 2388 | else { |
2389 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2389 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2390 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2390 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2391 | int dw = QApplication::desktop()->width(); | 2391 | int dw = QApplication::desktop()->width(); |
2392 | int dh = QApplication::desktop()->height(); | 2392 | int dh = QApplication::desktop()->height(); |
2393 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2393 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2394 | mDateFrame->show(); | 2394 | mDateFrame->show(); |
2395 | } | 2395 | } |
2396 | mDatePickerMode = 2; | 2396 | mDatePickerMode = 2; |
2397 | mMoveIncidence = inc ; | 2397 | mMoveIncidence = inc ; |
2398 | QDate da; | 2398 | QDate da; |
2399 | if ( mMoveIncidence->type() == "Todo" ) { | 2399 | if ( mMoveIncidence->type() == "Todo" ) { |
2400 | Todo * to = (Todo *) mMoveIncidence; | 2400 | Todo * to = (Todo *) mMoveIncidence; |
2401 | if ( to->hasDueDate() ) | 2401 | if ( to->hasDueDate() ) |
2402 | da = to->dtDue().date(); | 2402 | da = to->dtDue().date(); |
2403 | else | 2403 | else |
2404 | da = QDate::currentDate(); | 2404 | da = QDate::currentDate(); |
2405 | } else { | 2405 | } else { |
2406 | da = mMoveIncidence->dtStart().date(); | 2406 | da = mMoveIncidence->dtStart().date(); |
2407 | } | 2407 | } |
2408 | mDatePicker->setDate( da ); | 2408 | mDatePicker->setDate( da ); |
2409 | } | 2409 | } |
2410 | void CalendarView::showDatePicker( ) | 2410 | void CalendarView::showDatePicker( ) |
2411 | { | 2411 | { |
2412 | //qDebug("CalendarView::showDatePicker( ) "); | 2412 | //qDebug("CalendarView::showDatePicker( ) "); |
2413 | if ( mDateFrame->isVisible() ) | 2413 | if ( mDateFrame->isVisible() ) |
2414 | mDateFrame->hide(); | 2414 | mDateFrame->hide(); |
2415 | else { | 2415 | else { |
2416 | int w =mDatePicker->sizeHint().width() ; | 2416 | int w =mDatePicker->sizeHint().width() ; |
2417 | int h = mDatePicker->sizeHint().height() ; | 2417 | int h = mDatePicker->sizeHint().height() ; |
2418 | int dw = QApplication::desktop()->width(); | 2418 | int dw = QApplication::desktop()->width(); |
2419 | int dh = QApplication::desktop()->height(); | 2419 | int dh = QApplication::desktop()->height(); |
2420 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2420 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2421 | mDateFrame->show(); | 2421 | mDateFrame->show(); |
2422 | } | 2422 | } |
2423 | mDatePickerMode = 1; | 2423 | mDatePickerMode = 1; |
2424 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2424 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2425 | } | 2425 | } |
2426 | 2426 | ||
2427 | void CalendarView::showEventEditor() | 2427 | void CalendarView::showEventEditor() |
2428 | { | 2428 | { |
2429 | #ifdef DESKTOP_VERSION | 2429 | #ifdef DESKTOP_VERSION |
2430 | mEventEditor->show(); | 2430 | mEventEditor->show(); |
2431 | #else | 2431 | #else |
2432 | mEventEditor->showMaximized(); | 2432 | mEventEditor->showMaximized(); |
2433 | #endif | 2433 | #endif |
2434 | } | 2434 | } |
2435 | void CalendarView::showTodoEditor() | 2435 | void CalendarView::showTodoEditor() |
2436 | { | 2436 | { |
2437 | #ifdef DESKTOP_VERSION | 2437 | #ifdef DESKTOP_VERSION |
2438 | mTodoEditor->show(); | 2438 | mTodoEditor->show(); |
2439 | #else | 2439 | #else |
2440 | mTodoEditor->showMaximized(); | 2440 | mTodoEditor->showMaximized(); |
2441 | #endif | 2441 | #endif |
2442 | } | 2442 | } |
2443 | 2443 | ||
2444 | void CalendarView::cloneIncidence() | 2444 | void CalendarView::cloneIncidence() |
2445 | { | 2445 | { |
2446 | Incidence *incidence = currentSelection(); | 2446 | Incidence *incidence = currentSelection(); |
2447 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2447 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2448 | if ( incidence ) { | 2448 | if ( incidence ) { |
2449 | cloneIncidence(incidence); | 2449 | cloneIncidence(incidence); |
2450 | } | 2450 | } |
2451 | } | 2451 | } |
2452 | void CalendarView::moveIncidence() | 2452 | void CalendarView::moveIncidence() |
2453 | { | 2453 | { |
2454 | Incidence *incidence = currentSelection(); | 2454 | Incidence *incidence = currentSelection(); |
2455 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2455 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2456 | if ( incidence ) { | 2456 | if ( incidence ) { |
2457 | moveIncidence(incidence); | 2457 | moveIncidence(incidence); |
2458 | } | 2458 | } |
2459 | } | 2459 | } |
2460 | void CalendarView::beamIncidence() | 2460 | void CalendarView::beamIncidence() |
2461 | { | 2461 | { |
2462 | Incidence *incidence = currentSelection(); | 2462 | Incidence *incidence = currentSelection(); |
2463 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2463 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2464 | if ( incidence ) { | 2464 | if ( incidence ) { |
2465 | beamIncidence(incidence); | 2465 | beamIncidence(incidence); |
2466 | } | 2466 | } |
2467 | } | 2467 | } |
2468 | void CalendarView::toggleCancelIncidence() | 2468 | void CalendarView::toggleCancelIncidence() |
2469 | { | 2469 | { |
2470 | Incidence *incidence = currentSelection(); | 2470 | Incidence *incidence = currentSelection(); |
2471 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2471 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2472 | if ( incidence ) { | 2472 | if ( incidence ) { |
2473 | cancelIncidence(incidence); | 2473 | cancelIncidence(incidence); |
2474 | } | 2474 | } |
2475 | } | 2475 | } |
2476 | 2476 | ||
2477 | 2477 | ||
2478 | void CalendarView::cancelIncidence(Incidence * inc ) | 2478 | void CalendarView::cancelIncidence(Incidence * inc ) |
2479 | { | 2479 | { |
2480 | inc->setCancelled( ! inc->cancelled() ); | 2480 | inc->setCancelled( ! inc->cancelled() ); |
2481 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2481 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2482 | updateView(); | 2482 | updateView(); |
2483 | } | 2483 | } |
2484 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2484 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2485 | { | 2485 | { |
2486 | Incidence * newInc = orgInc->clone(); | 2486 | Incidence * newInc = orgInc->clone(); |
2487 | newInc->recreate(); | 2487 | newInc->recreate(); |
2488 | 2488 | ||
2489 | if ( newInc->type() == "Todo" ) { | 2489 | if ( newInc->type() == "Todo" ) { |
2490 | Todo* t = (Todo*) newInc; | 2490 | Todo* t = (Todo*) newInc; |
2491 | mTodoEditor->editTodo( t ); | 2491 | mTodoEditor->editTodo( t ); |
2492 | showTodoEditor(); | 2492 | showTodoEditor(); |
2493 | if ( mTodoEditor->exec() ) { | 2493 | if ( mTodoEditor->exec() ) { |
2494 | mCalendar->addTodo( t ); | 2494 | mCalendar->addTodo( t ); |
2495 | updateView(); | 2495 | updateView(); |
2496 | } else { | 2496 | } else { |
2497 | delete t; | 2497 | delete t; |
2498 | } | 2498 | } |
2499 | } | 2499 | } |
2500 | else { | 2500 | else { |
2501 | Event* e = (Event*) newInc; | 2501 | Event* e = (Event*) newInc; |
2502 | mEventEditor->editEvent( e ); | 2502 | mEventEditor->editEvent( e ); |
2503 | showEventEditor(); | 2503 | showEventEditor(); |
2504 | if ( mEventEditor->exec() ) { | 2504 | if ( mEventEditor->exec() ) { |
2505 | mCalendar->addEvent( e ); | 2505 | mCalendar->addEvent( e ); |
2506 | updateView(); | 2506 | updateView(); |
2507 | } else { | 2507 | } else { |
2508 | delete e; | 2508 | delete e; |
2509 | } | 2509 | } |
2510 | } | 2510 | } |
2511 | } | 2511 | } |
2512 | 2512 | ||
2513 | void CalendarView::newEvent() | 2513 | void CalendarView::newEvent() |
2514 | { | 2514 | { |
2515 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2515 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2516 | KOAgendaView *aView = mViewManager->agendaView(); | 2516 | KOAgendaView *aView = mViewManager->agendaView(); |
2517 | if (aView) { | 2517 | if (aView) { |
2518 | if (aView->selectionStart().isValid()) { | 2518 | if (aView->selectionStart().isValid()) { |
2519 | if (aView->selectedIsAllDay()) { | 2519 | if (aView->selectedIsAllDay()) { |
2520 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2520 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2521 | } else { | 2521 | } else { |
2522 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2522 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2523 | } | 2523 | } |
2524 | return; | 2524 | return; |
2525 | } | 2525 | } |
2526 | } | 2526 | } |
2527 | 2527 | ||
2528 | QDate date = mNavigator->selectedDates().first(); | 2528 | QDate date = mNavigator->selectedDates().first(); |
2529 | QDateTime current = QDateTime::currentDateTime(); | 2529 | QDateTime current = QDateTime::currentDateTime(); |
2530 | if ( date <= current.date() ) { | 2530 | if ( date <= current.date() ) { |
2531 | int hour = current.time().hour() +1; | 2531 | int hour = current.time().hour() +1; |
2532 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2532 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2533 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2533 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2534 | } else | 2534 | } else |
2535 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2535 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2536 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2536 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2537 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2537 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2538 | } | 2538 | } |
2539 | 2539 | ||
2540 | void CalendarView::newEvent(QDateTime fh) | 2540 | void CalendarView::newEvent(QDateTime fh) |
2541 | { | 2541 | { |
2542 | newEvent(fh, | 2542 | newEvent(fh, |
2543 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2543 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2544 | } | 2544 | } |
2545 | 2545 | ||
2546 | void CalendarView::newEvent(QDate dt) | 2546 | void CalendarView::newEvent(QDate dt) |
2547 | { | 2547 | { |
2548 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2548 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2549 | QDateTime(dt, QTime(0,0,0)), true); | 2549 | QDateTime(dt, QTime(0,0,0)), true); |
2550 | } | 2550 | } |
2551 | 2551 | ||
2552 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2552 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2553 | { | 2553 | { |
2554 | 2554 | ||
2555 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2555 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2556 | if ( mFilterView->filtersEnabled() ) { | 2556 | if ( mFilterView->filtersEnabled() ) { |
2557 | CalFilter *filter = mFilterView->selectedFilter(); | 2557 | CalFilter *filter = mFilterView->selectedFilter(); |
2558 | if (filter && filter->showCategories()) { | 2558 | if (filter && filter->showCategories()) { |
2559 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2559 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2560 | } | 2560 | } |
2561 | if ( filter ) | 2561 | if ( filter ) |
2562 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2562 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2563 | } | 2563 | } |
2564 | showEventEditor(); | 2564 | showEventEditor(); |
2565 | } | 2565 | } |
2566 | void CalendarView::todoAdded(Todo * t) | 2566 | void CalendarView::todoAdded(Todo * t) |
2567 | { | 2567 | { |
2568 | 2568 | ||
2569 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2569 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2570 | updateTodoViews(); | 2570 | updateTodoViews(); |
2571 | } | 2571 | } |
2572 | void CalendarView::todoChanged(Todo * t) | 2572 | void CalendarView::todoChanged(Todo * t) |
2573 | { | 2573 | { |
2574 | emit todoModified( t, 4 ); | 2574 | emit todoModified( t, 4 ); |
2575 | // updateTodoViews(); | 2575 | // updateTodoViews(); |
2576 | } | 2576 | } |
2577 | void CalendarView::todoToBeDeleted(Todo *) | 2577 | void CalendarView::todoToBeDeleted(Todo *) |
2578 | { | 2578 | { |
2579 | //qDebug("todoToBeDeleted(Todo *) "); | 2579 | //qDebug("todoToBeDeleted(Todo *) "); |
2580 | updateTodoViews(); | 2580 | updateTodoViews(); |
2581 | } | 2581 | } |
2582 | void CalendarView::todoDeleted() | 2582 | void CalendarView::todoDeleted() |
2583 | { | 2583 | { |
2584 | //qDebug(" todoDeleted()"); | 2584 | //qDebug(" todoDeleted()"); |
2585 | updateTodoViews(); | 2585 | updateTodoViews(); |
2586 | } | 2586 | } |
2587 | 2587 | ||
2588 | 2588 | ||
2589 | 2589 | ||
2590 | void CalendarView::newTodo() | 2590 | void CalendarView::newTodo() |
2591 | { | 2591 | { |
2592 | 2592 | ||
2593 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); | 2593 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); |
2594 | if ( mFilterView->filtersEnabled() ) { | 2594 | if ( mFilterView->filtersEnabled() ) { |
2595 | CalFilter *filter = mFilterView->selectedFilter(); | 2595 | CalFilter *filter = mFilterView->selectedFilter(); |
2596 | if (filter && filter->showCategories()) { | 2596 | if (filter && filter->showCategories()) { |
2597 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2597 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2598 | } | 2598 | } |
2599 | if ( filter ) | 2599 | if ( filter ) |
2600 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2600 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2601 | } | 2601 | } |
2602 | showTodoEditor(); | 2602 | showTodoEditor(); |
2603 | } | 2603 | } |
2604 | 2604 | ||
2605 | void CalendarView::newSubTodo() | 2605 | void CalendarView::newSubTodo() |
2606 | { | 2606 | { |
2607 | Todo *todo = selectedTodo(); | 2607 | Todo *todo = selectedTodo(); |
2608 | if ( todo ) newSubTodo( todo ); | 2608 | if ( todo ) newSubTodo( todo ); |
2609 | } | 2609 | } |
2610 | 2610 | ||
2611 | void CalendarView::newSubTodo(Todo *parentEvent) | 2611 | void CalendarView::newSubTodo(Todo *parentEvent) |
2612 | { | 2612 | { |
2613 | 2613 | ||
2614 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); | 2614 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); |
2615 | showTodoEditor(); | 2615 | showTodoEditor(); |
2616 | } | 2616 | } |
2617 | 2617 | ||
2618 | void CalendarView::newFloatingEvent() | 2618 | void CalendarView::newFloatingEvent() |
2619 | { | 2619 | { |
2620 | DateList tmpList = mNavigator->selectedDates(); | 2620 | DateList tmpList = mNavigator->selectedDates(); |
2621 | QDate date = tmpList.first(); | 2621 | QDate date = tmpList.first(); |
2622 | 2622 | ||
2623 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2623 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2624 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2624 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2625 | } | 2625 | } |
2626 | 2626 | ||
2627 | 2627 | ||
2628 | void CalendarView::editEvent( Event *event ) | 2628 | void CalendarView::editEvent( Event *event ) |
2629 | { | 2629 | { |
2630 | 2630 | ||
2631 | if ( !event ) return; | 2631 | if ( !event ) return; |
2632 | if ( event->isReadOnly() ) { | 2632 | if ( event->isReadOnly() ) { |
2633 | showEvent( event ); | 2633 | showEvent( event ); |
2634 | return; | 2634 | return; |
2635 | } | 2635 | } |
2636 | mEventEditor->editEvent( event , mFlagEditDescription); | 2636 | mEventEditor->editEvent( event , mFlagEditDescription); |
2637 | showEventEditor(); | 2637 | showEventEditor(); |
2638 | } | 2638 | } |
2639 | void CalendarView::editJournal( Journal *jour ) | 2639 | void CalendarView::editJournal( Journal *jour ) |
2640 | { | 2640 | { |
2641 | if ( !jour ) return; | 2641 | if ( !jour ) return; |
2642 | mDialogManager->hideSearchDialog(); | 2642 | mDialogManager->hideSearchDialog(); |
2643 | mViewManager->showJournalView(); | 2643 | mViewManager->showJournalView(); |
2644 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2644 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2645 | } | 2645 | } |
2646 | void CalendarView::editTodo( Todo *todo ) | 2646 | void CalendarView::editTodo( Todo *todo ) |
2647 | { | 2647 | { |
2648 | if ( !todo ) return; | 2648 | if ( !todo ) return; |
2649 | 2649 | ||
2650 | if ( todo->isReadOnly() ) { | 2650 | if ( todo->isReadOnly() ) { |
2651 | showTodo( todo ); | 2651 | showTodo( todo ); |
2652 | return; | 2652 | return; |
2653 | } | 2653 | } |
2654 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2654 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2655 | showTodoEditor(); | 2655 | showTodoEditor(); |
2656 | 2656 | ||
2657 | } | 2657 | } |
2658 | 2658 | ||
2659 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2659 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2660 | { | 2660 | { |
2661 | if ( !mEventViewerDialog ) { | 2661 | if ( !mEventViewerDialog ) { |
2662 | mEventViewerDialog = new KOEventViewerDialog(this); | 2662 | mEventViewerDialog = new KOEventViewerDialog(this); |
2663 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2663 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2664 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2664 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2665 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2665 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2666 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2666 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2667 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2667 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2668 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2668 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2669 | mEventViewerDialog->resize( 640, 480 ); | 2669 | mEventViewerDialog->resize( 640, 480 ); |
2670 | 2670 | ||
2671 | } | 2671 | } |
2672 | return mEventViewerDialog; | 2672 | return mEventViewerDialog; |
2673 | } | 2673 | } |
2674 | void CalendarView::showEvent(Event *event) | 2674 | void CalendarView::showEvent(Event *event) |
2675 | { | 2675 | { |
2676 | getEventViewerDialog()->setEvent(event); | 2676 | getEventViewerDialog()->setEvent(event); |
2677 | getEventViewerDialog()->showMe(); | 2677 | getEventViewerDialog()->showMe(); |
2678 | } | 2678 | } |
2679 | 2679 | ||
2680 | void CalendarView::showTodo(Todo *event) | 2680 | void CalendarView::showTodo(Todo *event) |
2681 | { | 2681 | { |
2682 | getEventViewerDialog()->setTodo(event); | 2682 | getEventViewerDialog()->setTodo(event); |
2683 | getEventViewerDialog()->showMe(); | 2683 | getEventViewerDialog()->showMe(); |
2684 | } | 2684 | } |
2685 | void CalendarView::showJournal( Journal *jour ) | 2685 | void CalendarView::showJournal( Journal *jour ) |
2686 | { | 2686 | { |
2687 | getEventViewerDialog()->setJournal(jour); | 2687 | getEventViewerDialog()->setJournal(jour); |
2688 | getEventViewerDialog()->showMe(); | 2688 | getEventViewerDialog()->showMe(); |
2689 | 2689 | ||
2690 | } | 2690 | } |
2691 | // void CalendarView::todoModified (Todo *event, int changed) | 2691 | // void CalendarView::todoModified (Todo *event, int changed) |
2692 | // { | 2692 | // { |
2693 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2693 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2694 | // // kdDebug() << "Todo modified and open" << endl; | 2694 | // // kdDebug() << "Todo modified and open" << endl; |
2695 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2695 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2696 | // // temp->modified (changed); | 2696 | // // temp->modified (changed); |
2697 | 2697 | ||
2698 | // // } | 2698 | // // } |
2699 | 2699 | ||
2700 | // mViewManager->updateView(); | 2700 | // mViewManager->updateView(); |
2701 | // } | 2701 | // } |
2702 | 2702 | ||
2703 | void CalendarView::appointment_show() | 2703 | void CalendarView::appointment_show() |
2704 | { | 2704 | { |
2705 | Event *anEvent = 0; | 2705 | Event *anEvent = 0; |
2706 | 2706 | ||
2707 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2707 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2708 | 2708 | ||
2709 | if (mViewManager->currentView()->isEventView()) { | 2709 | if (mViewManager->currentView()->isEventView()) { |
2710 | if ( incidence && incidence->type() == "Event" ) { | 2710 | if ( incidence && incidence->type() == "Event" ) { |
2711 | anEvent = static_cast<Event *>(incidence); | 2711 | anEvent = static_cast<Event *>(incidence); |
2712 | } | 2712 | } |
2713 | } | 2713 | } |
2714 | 2714 | ||
2715 | if (!anEvent) { | 2715 | if (!anEvent) { |
2716 | KNotifyClient::beep(); | 2716 | KNotifyClient::beep(); |
2717 | return; | 2717 | return; |
2718 | } | 2718 | } |
2719 | 2719 | ||
2720 | showEvent(anEvent); | 2720 | showEvent(anEvent); |
2721 | } | 2721 | } |
2722 | 2722 | ||
2723 | void CalendarView::appointment_edit() | 2723 | void CalendarView::appointment_edit() |
2724 | { | 2724 | { |
2725 | Event *anEvent = 0; | 2725 | Event *anEvent = 0; |
2726 | 2726 | ||
2727 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2727 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2728 | 2728 | ||
2729 | if (mViewManager->currentView()->isEventView()) { | 2729 | if (mViewManager->currentView()->isEventView()) { |
2730 | if ( incidence && incidence->type() == "Event" ) { | 2730 | if ( incidence && incidence->type() == "Event" ) { |
2731 | anEvent = static_cast<Event *>(incidence); | 2731 | anEvent = static_cast<Event *>(incidence); |
2732 | } | 2732 | } |
2733 | } | 2733 | } |
2734 | 2734 | ||
2735 | if (!anEvent) { | 2735 | if (!anEvent) { |
2736 | KNotifyClient::beep(); | 2736 | KNotifyClient::beep(); |
2737 | return; | 2737 | return; |
2738 | } | 2738 | } |
2739 | 2739 | ||
2740 | editEvent(anEvent); | 2740 | editEvent(anEvent); |
2741 | } | 2741 | } |
2742 | 2742 | ||
2743 | void CalendarView::appointment_delete() | 2743 | void CalendarView::appointment_delete() |
2744 | { | 2744 | { |
2745 | Event *anEvent = 0; | 2745 | Event *anEvent = 0; |
2746 | 2746 | ||
2747 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2747 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2748 | 2748 | ||
2749 | if (mViewManager->currentView()->isEventView()) { | 2749 | if (mViewManager->currentView()->isEventView()) { |
2750 | if ( incidence && incidence->type() == "Event" ) { | 2750 | if ( incidence && incidence->type() == "Event" ) { |
2751 | anEvent = static_cast<Event *>(incidence); | 2751 | anEvent = static_cast<Event *>(incidence); |
2752 | } | 2752 | } |
2753 | } | 2753 | } |
2754 | 2754 | ||
2755 | if (!anEvent) { | 2755 | if (!anEvent) { |
2756 | KNotifyClient::beep(); | 2756 | KNotifyClient::beep(); |
2757 | return; | 2757 | return; |
2758 | } | 2758 | } |
2759 | 2759 | ||
2760 | deleteEvent(anEvent); | 2760 | deleteEvent(anEvent); |
2761 | } | 2761 | } |
2762 | 2762 | ||
2763 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 2763 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
2764 | { | 2764 | { |
2765 | if (!sub) return; | 2765 | if (!sub) return; |
2766 | if (!parent) return; | 2766 | if (!parent) return; |
2767 | if ( sub->relatedTo() ) | 2767 | if ( sub->relatedTo() ) |
2768 | sub->relatedTo()->removeRelation(sub); | 2768 | sub->relatedTo()->removeRelation(sub); |
2769 | sub->setRelatedTo(parent); | 2769 | sub->setRelatedTo(parent); |
2770 | sub->setRelatedToUid(parent->uid()); | 2770 | sub->setRelatedToUid(parent->uid()); |
2771 | parent->addRelation(sub); | 2771 | parent->addRelation(sub); |
2772 | sub->updated(); | 2772 | sub->updated(); |
2773 | parent->updated(); | 2773 | parent->updated(); |
2774 | setModified(true); | 2774 | setModified(true); |
2775 | updateView(); | 2775 | updateView(); |
2776 | } | 2776 | } |
2777 | void CalendarView::todo_unsub(Todo *anTodo ) | 2777 | void CalendarView::todo_unsub(Todo *anTodo ) |
2778 | { | 2778 | { |
2779 | // Todo *anTodo = selectedTodo(); | 2779 | // Todo *anTodo = selectedTodo(); |
2780 | if (!anTodo) return; | 2780 | if (!anTodo) return; |
2781 | if (!anTodo->relatedTo()) return; | 2781 | if (!anTodo->relatedTo()) return; |
2782 | anTodo->relatedTo()->removeRelation(anTodo); | 2782 | anTodo->relatedTo()->removeRelation(anTodo); |
2783 | anTodo->setRelatedTo(0); | 2783 | anTodo->setRelatedTo(0); |
2784 | anTodo->updated(); | 2784 | anTodo->updated(); |
2785 | anTodo->setRelatedToUid(""); | 2785 | anTodo->setRelatedToUid(""); |
2786 | setModified(true); | 2786 | setModified(true); |
2787 | updateView(); | 2787 | updateView(); |
2788 | } | 2788 | } |
2789 | 2789 | ||
2790 | void CalendarView::deleteTodo(Todo *todo) | 2790 | void CalendarView::deleteTodo(Todo *todo) |
2791 | { | 2791 | { |
2792 | if (!todo) { | 2792 | if (!todo) { |
2793 | KNotifyClient::beep(); | 2793 | KNotifyClient::beep(); |
2794 | return; | 2794 | return; |
2795 | } | 2795 | } |
2796 | if (KOPrefs::instance()->mConfirm) { | 2796 | if (KOPrefs::instance()->mConfirm) { |
2797 | switch (msgItemDelete()) { | 2797 | switch (msgItemDelete()) { |
2798 | case KMessageBox::Continue: // OK | 2798 | case KMessageBox::Continue: // OK |
2799 | if (!todo->relations().isEmpty()) { | 2799 | if (!todo->relations().isEmpty()) { |
2800 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2800 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2801 | i18n("Delete To-Do")); | 2801 | i18n("Delete To-Do")); |
2802 | } else { | 2802 | } else { |
2803 | checkExternalId( todo ); | 2803 | checkExternalId( todo ); |
2804 | calendar()->deleteTodo(todo); | 2804 | calendar()->deleteTodo(todo); |
2805 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2805 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2806 | updateView(); | 2806 | updateView(); |
2807 | } | 2807 | } |
2808 | break; | 2808 | break; |
2809 | } // switch | 2809 | } // switch |
2810 | } else { | 2810 | } else { |
2811 | if (!todo->relations().isEmpty()) { | 2811 | if (!todo->relations().isEmpty()) { |
2812 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2812 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2813 | i18n("Delete To-Do")); | 2813 | i18n("Delete To-Do")); |
2814 | } else { | 2814 | } else { |
2815 | checkExternalId( todo ); | 2815 | checkExternalId( todo ); |
2816 | mCalendar->deleteTodo(todo); | 2816 | mCalendar->deleteTodo(todo); |
2817 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2817 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2818 | updateView(); | 2818 | updateView(); |
2819 | } | 2819 | } |
2820 | } | 2820 | } |
2821 | emit updateSearchDialog(); | 2821 | emit updateSearchDialog(); |
2822 | } | 2822 | } |
2823 | void CalendarView::deleteJournal(Journal *jour) | 2823 | void CalendarView::deleteJournal(Journal *jour) |
2824 | { | 2824 | { |
2825 | if (!jour) { | 2825 | if (!jour) { |
2826 | KNotifyClient::beep(); | 2826 | KNotifyClient::beep(); |
2827 | return; | 2827 | return; |
2828 | } | 2828 | } |
2829 | if (KOPrefs::instance()->mConfirm) { | 2829 | if (KOPrefs::instance()->mConfirm) { |
2830 | switch (msgItemDelete()) { | 2830 | switch (msgItemDelete()) { |
2831 | case KMessageBox::Continue: // OK | 2831 | case KMessageBox::Continue: // OK |
2832 | calendar()->deleteJournal(jour); | 2832 | calendar()->deleteJournal(jour); |
2833 | updateView(); | 2833 | updateView(); |
2834 | break; | 2834 | break; |
2835 | } // switch | 2835 | } // switch |
2836 | } else { | 2836 | } else { |
2837 | calendar()->deleteJournal(jour);; | 2837 | calendar()->deleteJournal(jour);; |
2838 | updateView(); | 2838 | updateView(); |
2839 | } | 2839 | } |
2840 | emit updateSearchDialog(); | 2840 | emit updateSearchDialog(); |
2841 | } | 2841 | } |
2842 | 2842 | ||
2843 | void CalendarView::deleteEvent(Event *anEvent) | 2843 | void CalendarView::deleteEvent(Event *anEvent) |
2844 | { | 2844 | { |
2845 | if (!anEvent) { | 2845 | if (!anEvent) { |
2846 | KNotifyClient::beep(); | 2846 | KNotifyClient::beep(); |
2847 | return; | 2847 | return; |
2848 | } | 2848 | } |
2849 | 2849 | ||
2850 | if (anEvent->recurrence()->doesRecur()) { | 2850 | if (anEvent->recurrence()->doesRecur()) { |
2851 | QDate itemDate = mViewManager->currentSelectionDate(); | 2851 | QDate itemDate = mViewManager->currentSelectionDate(); |
2852 | int km; | 2852 | int km; |
2853 | if (!itemDate.isValid()) { | 2853 | if (!itemDate.isValid()) { |
2854 | //kdDebug() << "Date Not Valid" << endl; | 2854 | //kdDebug() << "Date Not Valid" << endl; |
2855 | if (KOPrefs::instance()->mConfirm) { | 2855 | if (KOPrefs::instance()->mConfirm) { |
2856 | km = KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2856 | km = KMessageBox::warningContinueCancel(this,anEvent->summary() + |
2857 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 2857 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
2858 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 2858 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
2859 | if ( km == KMessageBox::Continue ) | 2859 | if ( km == KMessageBox::Continue ) |
2860 | km = KMessageBox::No; // No = all below | 2860 | km = KMessageBox::No; // No = all below |
2861 | } else | 2861 | } else |
2862 | km = KMessageBox::No; | 2862 | km = KMessageBox::No; |
2863 | } else { | 2863 | } else { |
2864 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + | 2864 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + |
2865 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 2865 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
2866 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 2866 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
2867 | i18n("KO/Pi Confirmation"),i18n("Current"), | 2867 | i18n("KO/Pi Confirmation"),i18n("Current"), |
2868 | i18n("All")); | 2868 | i18n("All")); |
2869 | } | 2869 | } |
2870 | switch(km) { | 2870 | switch(km) { |
2871 | 2871 | ||
2872 | case KMessageBox::No: // Continue // all | 2872 | case KMessageBox::No: // Continue // all |
2873 | //qDebug("KMessageBox::No "); | 2873 | //qDebug("KMessageBox::No "); |
2874 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2874 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2875 | schedule(Scheduler::Cancel,anEvent); | 2875 | schedule(Scheduler::Cancel,anEvent); |
2876 | 2876 | ||
2877 | checkExternalId( anEvent); | 2877 | checkExternalId( anEvent); |
2878 | mCalendar->deleteEvent(anEvent); | 2878 | mCalendar->deleteEvent(anEvent); |
2879 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 2879 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
2880 | break; | 2880 | break; |
2881 | 2881 | ||
2882 | // Disabled because it does not work | 2882 | // Disabled because it does not work |
2883 | //#if 0 | 2883 | //#if 0 |
2884 | case KMessageBox::Yes: // just this one | 2884 | case KMessageBox::Yes: // just this one |
2885 | //QDate qd = mNavigator->selectedDates().first(); | 2885 | //QDate qd = mNavigator->selectedDates().first(); |
2886 | //if (!qd.isValid()) { | 2886 | //if (!qd.isValid()) { |
2887 | // kdDebug() << "no date selected, or invalid date" << endl; | 2887 | // kdDebug() << "no date selected, or invalid date" << endl; |
2888 | // KNotifyClient::beep(); | 2888 | // KNotifyClient::beep(); |
2889 | // return; | 2889 | // return; |
2890 | //} | 2890 | //} |
2891 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 2891 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
2892 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 2892 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
2893 | anEvent->addExDate(itemDate); | 2893 | anEvent->addExDate(itemDate); |
2894 | int duration = anEvent->recurrence()->duration(); | 2894 | int duration = anEvent->recurrence()->duration(); |
2895 | if ( duration > 0 ) { | 2895 | if ( duration > 0 ) { |
2896 | anEvent->recurrence()->setDuration( duration - 1 ); | 2896 | anEvent->recurrence()->setDuration( duration - 1 ); |
2897 | } | 2897 | } |
2898 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 2898 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
2899 | } | 2899 | } |
2900 | break; | 2900 | break; |
2901 | //#endif | 2901 | //#endif |
2902 | } // switch | 2902 | } // switch |
2903 | } else { | 2903 | } else { |
2904 | if (KOPrefs::instance()->mConfirm) { | 2904 | if (KOPrefs::instance()->mConfirm) { |
2905 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2905 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + |
2906 | i18n("\nAre you sure you want\nto delete this event?"), | 2906 | i18n("\nAre you sure you want\nto delete this event?"), |
2907 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 2907 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
2908 | case KMessageBox::Continue: // OK | 2908 | case KMessageBox::Continue: // OK |
2909 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2909 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2910 | schedule(Scheduler::Cancel,anEvent); | 2910 | schedule(Scheduler::Cancel,anEvent); |
2911 | checkExternalId( anEvent); | 2911 | checkExternalId( anEvent); |
2912 | mCalendar->deleteEvent(anEvent); | 2912 | mCalendar->deleteEvent(anEvent); |
2913 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2913 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2914 | break; | 2914 | break; |
2915 | } // switch | 2915 | } // switch |
2916 | } else { | 2916 | } else { |
2917 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2917 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2918 | schedule(Scheduler::Cancel,anEvent); | 2918 | schedule(Scheduler::Cancel,anEvent); |
2919 | checkExternalId( anEvent); | 2919 | checkExternalId( anEvent); |
2920 | mCalendar->deleteEvent(anEvent); | 2920 | mCalendar->deleteEvent(anEvent); |
2921 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2921 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2922 | } | 2922 | } |
2923 | } // if-else | 2923 | } // if-else |
2924 | emit updateSearchDialog(); | 2924 | emit updateSearchDialog(); |
2925 | } | 2925 | } |
2926 | 2926 | ||
2927 | bool CalendarView::deleteEvent(const QString &uid) | 2927 | bool CalendarView::deleteEvent(const QString &uid) |
2928 | { | 2928 | { |
2929 | Event *ev = mCalendar->event(uid); | 2929 | Event *ev = mCalendar->event(uid); |
2930 | if (ev) { | 2930 | if (ev) { |
2931 | deleteEvent(ev); | 2931 | deleteEvent(ev); |
2932 | return true; | 2932 | return true; |
2933 | } else { | 2933 | } else { |
2934 | return false; | 2934 | return false; |
2935 | } | 2935 | } |
2936 | } | 2936 | } |
2937 | 2937 | ||
2938 | /*****************************************************************************/ | 2938 | /*****************************************************************************/ |
2939 | 2939 | ||
2940 | void CalendarView::action_mail() | 2940 | void CalendarView::action_mail() |
2941 | { | 2941 | { |
2942 | #ifndef KORG_NOMAIL | 2942 | #ifndef KORG_NOMAIL |
2943 | KOMailClient mailClient; | 2943 | KOMailClient mailClient; |
2944 | 2944 | ||
2945 | Incidence *incidence = currentSelection(); | 2945 | Incidence *incidence = currentSelection(); |
2946 | 2946 | ||
2947 | if (!incidence) { | 2947 | if (!incidence) { |
2948 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 2948 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
2949 | return; | 2949 | return; |
2950 | } | 2950 | } |
2951 | if(incidence->attendeeCount() == 0 ) { | 2951 | if(incidence->attendeeCount() == 0 ) { |
2952 | KMessageBox::sorry(this, | 2952 | KMessageBox::sorry(this, |
2953 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 2953 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
2954 | return; | 2954 | return; |
2955 | } | 2955 | } |
2956 | 2956 | ||
2957 | CalendarLocal cal_tmp; | 2957 | CalendarLocal cal_tmp; |
2958 | Event *event = 0; | 2958 | Event *event = 0; |
2959 | Event *ev = 0; | 2959 | Event *ev = 0; |
2960 | if ( incidence && incidence->type() == "Event" ) { | 2960 | if ( incidence && incidence->type() == "Event" ) { |
2961 | event = static_cast<Event *>(incidence); | 2961 | event = static_cast<Event *>(incidence); |
2962 | ev = new Event(*event); | 2962 | ev = new Event(*event); |
2963 | cal_tmp.addEvent(ev); | 2963 | cal_tmp.addEvent(ev); |
2964 | } | 2964 | } |
2965 | ICalFormat mForm(); | 2965 | ICalFormat mForm(); |
2966 | QString attachment = mForm.toString( &cal_tmp ); | 2966 | QString attachment = mForm.toString( &cal_tmp ); |
2967 | if (ev) delete(ev); | 2967 | if (ev) delete(ev); |
2968 | 2968 | ||
2969 | mailClient.mailAttendees(currentSelection(), attachment); | 2969 | mailClient.mailAttendees(currentSelection(), attachment); |
2970 | 2970 | ||
2971 | #endif | 2971 | #endif |
2972 | 2972 | ||
2973 | #if 0 | 2973 | #if 0 |
2974 | Event *anEvent = 0; | 2974 | Event *anEvent = 0; |
2975 | if (mViewManager->currentView()->isEventView()) { | 2975 | if (mViewManager->currentView()->isEventView()) { |
2976 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 2976 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
2977 | } | 2977 | } |
2978 | 2978 | ||
2979 | if (!anEvent) { | 2979 | if (!anEvent) { |
2980 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 2980 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
2981 | return; | 2981 | return; |
2982 | } | 2982 | } |
2983 | if(anEvent->attendeeCount() == 0 ) { | 2983 | if(anEvent->attendeeCount() == 0 ) { |
2984 | KMessageBox::sorry(this, | 2984 | KMessageBox::sorry(this, |
2985 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 2985 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
2986 | return; | 2986 | return; |
2987 | } | 2987 | } |
2988 | 2988 | ||
2989 | mailobject.emailEvent(anEvent); | 2989 | mailobject.emailEvent(anEvent); |
2990 | #endif | 2990 | #endif |
2991 | } | 2991 | } |
2992 | 2992 | ||
2993 | 2993 | ||
2994 | void CalendarView::schedule_publish(Incidence *incidence) | 2994 | void CalendarView::schedule_publish(Incidence *incidence) |
2995 | { | 2995 | { |
2996 | Event *event = 0; | 2996 | Event *event = 0; |
2997 | Todo *todo = 0; | 2997 | Todo *todo = 0; |
2998 | 2998 | ||
2999 | if (incidence == 0) { | 2999 | if (incidence == 0) { |
3000 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3000 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3001 | if (incidence == 0) { | 3001 | if (incidence == 0) { |
3002 | incidence = mTodoList->selectedIncidences().first(); | 3002 | incidence = mTodoList->selectedIncidences().first(); |
3003 | } | 3003 | } |
3004 | } | 3004 | } |
3005 | if ( incidence && incidence->type() == "Event" ) { | 3005 | if ( incidence && incidence->type() == "Event" ) { |
3006 | event = static_cast<Event *>(incidence); | 3006 | event = static_cast<Event *>(incidence); |
3007 | } else { | 3007 | } else { |
3008 | if ( incidence && incidence->type() == "Todo" ) { | 3008 | if ( incidence && incidence->type() == "Todo" ) { |
3009 | todo = static_cast<Todo *>(incidence); | 3009 | todo = static_cast<Todo *>(incidence); |
3010 | } | 3010 | } |
3011 | } | 3011 | } |
3012 | 3012 | ||
3013 | if (!event && !todo) { | 3013 | if (!event && !todo) { |
3014 | KMessageBox::sorry(this,i18n("No event selected.")); | 3014 | KMessageBox::sorry(this,i18n("No event selected.")); |
3015 | return; | 3015 | return; |
3016 | } | 3016 | } |
3017 | 3017 | ||
3018 | PublishDialog *publishdlg = new PublishDialog(); | 3018 | PublishDialog *publishdlg = new PublishDialog(); |
3019 | if (incidence->attendeeCount()>0) { | 3019 | if (incidence->attendeeCount()>0) { |
3020 | QPtrList<Attendee> attendees = incidence->attendees(); | 3020 | QPtrList<Attendee> attendees = incidence->attendees(); |
3021 | attendees.first(); | 3021 | attendees.first(); |
3022 | while ( attendees.current()!=0 ) { | 3022 | while ( attendees.current()!=0 ) { |
3023 | publishdlg->addAttendee(attendees.current()); | 3023 | publishdlg->addAttendee(attendees.current()); |
3024 | attendees.next(); | 3024 | attendees.next(); |
3025 | } | 3025 | } |
3026 | } | 3026 | } |
3027 | bool send = true; | 3027 | bool send = true; |
3028 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3028 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3029 | if ( publishdlg->exec() != QDialog::Accepted ) | 3029 | if ( publishdlg->exec() != QDialog::Accepted ) |
3030 | send = false; | 3030 | send = false; |
3031 | } | 3031 | } |
3032 | if ( send ) { | 3032 | if ( send ) { |
3033 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3033 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3034 | if ( event ) { | 3034 | if ( event ) { |
3035 | Event *ev = new Event(*event); | 3035 | Event *ev = new Event(*event); |
3036 | ev->registerObserver(0); | 3036 | ev->registerObserver(0); |
3037 | ev->clearAttendees(); | 3037 | ev->clearAttendees(); |
3038 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3038 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3039 | delete(ev); | 3039 | delete(ev); |
3040 | } | 3040 | } |
3041 | } else { | 3041 | } else { |
3042 | if ( todo ) { | 3042 | if ( todo ) { |
3043 | Todo *ev = new Todo(*todo); | 3043 | Todo *ev = new Todo(*todo); |
3044 | ev->registerObserver(0); | 3044 | ev->registerObserver(0); |
3045 | ev->clearAttendees(); | 3045 | ev->clearAttendees(); |
3046 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3046 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3047 | delete(ev); | 3047 | delete(ev); |
3048 | } | 3048 | } |
3049 | } | 3049 | } |
3050 | } | 3050 | } |
3051 | } | 3051 | } |
3052 | delete publishdlg; | 3052 | delete publishdlg; |
3053 | } | 3053 | } |
3054 | 3054 | ||
3055 | void CalendarView::schedule_request(Incidence *incidence) | 3055 | void CalendarView::schedule_request(Incidence *incidence) |
3056 | { | 3056 | { |
3057 | schedule(Scheduler::Request,incidence); | 3057 | schedule(Scheduler::Request,incidence); |
3058 | } | 3058 | } |
3059 | 3059 | ||
3060 | void CalendarView::schedule_refresh(Incidence *incidence) | 3060 | void CalendarView::schedule_refresh(Incidence *incidence) |
3061 | { | 3061 | { |
3062 | schedule(Scheduler::Refresh,incidence); | 3062 | schedule(Scheduler::Refresh,incidence); |
3063 | } | 3063 | } |
3064 | 3064 | ||
3065 | void CalendarView::schedule_cancel(Incidence *incidence) | 3065 | void CalendarView::schedule_cancel(Incidence *incidence) |
3066 | { | 3066 | { |
3067 | schedule(Scheduler::Cancel,incidence); | 3067 | schedule(Scheduler::Cancel,incidence); |
3068 | } | 3068 | } |
3069 | 3069 | ||
3070 | void CalendarView::schedule_add(Incidence *incidence) | 3070 | void CalendarView::schedule_add(Incidence *incidence) |
3071 | { | 3071 | { |
3072 | schedule(Scheduler::Add,incidence); | 3072 | schedule(Scheduler::Add,incidence); |
3073 | } | 3073 | } |
3074 | 3074 | ||
3075 | void CalendarView::schedule_reply(Incidence *incidence) | 3075 | void CalendarView::schedule_reply(Incidence *incidence) |
3076 | { | 3076 | { |
3077 | schedule(Scheduler::Reply,incidence); | 3077 | schedule(Scheduler::Reply,incidence); |
3078 | } | 3078 | } |
3079 | 3079 | ||
3080 | void CalendarView::schedule_counter(Incidence *incidence) | 3080 | void CalendarView::schedule_counter(Incidence *incidence) |
3081 | { | 3081 | { |
3082 | schedule(Scheduler::Counter,incidence); | 3082 | schedule(Scheduler::Counter,incidence); |
3083 | } | 3083 | } |
3084 | 3084 | ||
3085 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3085 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3086 | { | 3086 | { |
3087 | schedule(Scheduler::Declinecounter,incidence); | 3087 | schedule(Scheduler::Declinecounter,incidence); |
3088 | } | 3088 | } |
3089 | 3089 | ||
3090 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3090 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3091 | { | 3091 | { |
3092 | QDateTime start = QDateTime::currentDateTime(); | 3092 | QDateTime start = QDateTime::currentDateTime(); |
3093 | QDateTime end = start.addDays(daysToPublish); | 3093 | QDateTime end = start.addDays(daysToPublish); |
3094 | 3094 | ||
3095 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3095 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3096 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3096 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3097 | 3097 | ||
3098 | 3098 | ||
3099 | PublishDialog *publishdlg = new PublishDialog(); | 3099 | PublishDialog *publishdlg = new PublishDialog(); |
3100 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3100 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3101 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3101 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3102 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3102 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3103 | delete(freebusy); | 3103 | delete(freebusy); |
3104 | } | 3104 | } |
3105 | } | 3105 | } |
3106 | delete publishdlg; | 3106 | delete publishdlg; |
3107 | } | 3107 | } |
3108 | 3108 | ||
3109 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3109 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3110 | { | 3110 | { |
3111 | Event *event = 0; | 3111 | Event *event = 0; |
3112 | Todo *todo = 0; | 3112 | Todo *todo = 0; |
3113 | 3113 | ||
3114 | if (incidence == 0) { | 3114 | if (incidence == 0) { |
3115 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3115 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3116 | if (incidence == 0) { | 3116 | if (incidence == 0) { |
3117 | incidence = mTodoList->selectedIncidences().first(); | 3117 | incidence = mTodoList->selectedIncidences().first(); |
3118 | } | 3118 | } |
3119 | } | 3119 | } |
3120 | if ( incidence && incidence->type() == "Event" ) { | 3120 | if ( incidence && incidence->type() == "Event" ) { |
3121 | event = static_cast<Event *>(incidence); | 3121 | event = static_cast<Event *>(incidence); |
3122 | } | 3122 | } |
3123 | if ( incidence && incidence->type() == "Todo" ) { | 3123 | if ( incidence && incidence->type() == "Todo" ) { |
3124 | todo = static_cast<Todo *>(incidence); | 3124 | todo = static_cast<Todo *>(incidence); |
3125 | } | 3125 | } |
3126 | 3126 | ||
3127 | if (!event && !todo) { | 3127 | if (!event && !todo) { |
3128 | KMessageBox::sorry(this,i18n("No event selected.")); | 3128 | KMessageBox::sorry(this,i18n("No event selected.")); |
3129 | return; | 3129 | return; |
3130 | } | 3130 | } |
3131 | 3131 | ||
3132 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3132 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3133 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3133 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3134 | return; | 3134 | return; |
3135 | } | 3135 | } |
3136 | 3136 | ||
3137 | Event *ev = 0; | 3137 | Event *ev = 0; |
3138 | if (event) ev = new Event(*event); | 3138 | if (event) ev = new Event(*event); |
3139 | Todo *to = 0; | 3139 | Todo *to = 0; |
3140 | if (todo) to = new Todo(*todo); | 3140 | if (todo) to = new Todo(*todo); |
3141 | 3141 | ||
3142 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3142 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3143 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3143 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3144 | if (!me) { | 3144 | if (!me) { |
3145 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3145 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3146 | return; | 3146 | return; |
3147 | } | 3147 | } |
3148 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3148 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3149 | StatusDialog *statdlg = new StatusDialog(this); | 3149 | StatusDialog *statdlg = new StatusDialog(this); |
3150 | if (!statdlg->exec()==QDialog::Accepted) return; | 3150 | if (!statdlg->exec()==QDialog::Accepted) return; |
3151 | me->setStatus( statdlg->status() ); | 3151 | me->setStatus( statdlg->status() ); |
3152 | delete(statdlg); | 3152 | delete(statdlg); |
3153 | } | 3153 | } |
3154 | Attendee *menew = new Attendee(*me); | 3154 | Attendee *menew = new Attendee(*me); |
3155 | if (ev) { | 3155 | if (ev) { |
3156 | ev->clearAttendees(); | 3156 | ev->clearAttendees(); |
3157 | ev->addAttendee(menew,false); | 3157 | ev->addAttendee(menew,false); |
3158 | } else { | 3158 | } else { |
3159 | if (to) { | 3159 | if (to) { |
3160 | todo->clearAttendees(); | 3160 | todo->clearAttendees(); |
3161 | todo->addAttendee(menew,false); | 3161 | todo->addAttendee(menew,false); |
3162 | } | 3162 | } |
3163 | } | 3163 | } |
3164 | } | 3164 | } |
3165 | 3165 | ||
3166 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3166 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3167 | if (ev) { | 3167 | if (ev) { |
3168 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3168 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3169 | } else { | 3169 | } else { |
3170 | if (to) { | 3170 | if (to) { |
3171 | if ( !dlg->addMessage(to,method) ) delete(to); | 3171 | if ( !dlg->addMessage(to,method) ) delete(to); |
3172 | } | 3172 | } |
3173 | } | 3173 | } |
3174 | } | 3174 | } |
3175 | 3175 | ||
3176 | void CalendarView::openAddressbook() | 3176 | void CalendarView::openAddressbook() |
3177 | { | 3177 | { |
3178 | KRun::runCommand("kaddressbook"); | 3178 | KRun::runCommand("kaddressbook"); |
3179 | } | 3179 | } |
3180 | 3180 | ||
3181 | void CalendarView::setModified(bool modified) | 3181 | void CalendarView::setModified(bool modified) |
3182 | { | 3182 | { |
3183 | if ( modified ) | 3183 | if ( modified ) |
3184 | emit signalmodified(); | 3184 | emit signalmodified(); |
3185 | if (mModified != modified) { | 3185 | if (mModified != modified) { |
3186 | mModified = modified; | 3186 | mModified = modified; |
3187 | emit modifiedChanged(mModified); | 3187 | emit modifiedChanged(mModified); |
3188 | } | 3188 | } |
3189 | } | 3189 | } |
3190 | 3190 | ||
3191 | bool CalendarView::isReadOnly() | 3191 | bool CalendarView::isReadOnly() |
3192 | { | 3192 | { |
3193 | return mReadOnly; | 3193 | return mReadOnly; |
3194 | } | 3194 | } |
3195 | 3195 | ||
3196 | void CalendarView::setReadOnly(bool readOnly) | 3196 | void CalendarView::setReadOnly(bool readOnly) |
3197 | { | 3197 | { |
3198 | if (mReadOnly != readOnly) { | 3198 | if (mReadOnly != readOnly) { |
3199 | mReadOnly = readOnly; | 3199 | mReadOnly = readOnly; |
3200 | emit readOnlyChanged(mReadOnly); | 3200 | emit readOnlyChanged(mReadOnly); |
3201 | } | 3201 | } |
3202 | } | 3202 | } |
3203 | 3203 | ||
3204 | bool CalendarView::isModified() | 3204 | bool CalendarView::isModified() |
3205 | { | 3205 | { |
3206 | return mModified; | 3206 | return mModified; |
3207 | } | 3207 | } |
3208 | 3208 | ||
3209 | void CalendarView::printSetup() | 3209 | void CalendarView::printSetup() |
3210 | { | 3210 | { |
3211 | #ifndef KORG_NOPRINTER | 3211 | #ifndef KORG_NOPRINTER |
3212 | createPrinter(); | 3212 | createPrinter(); |
3213 | 3213 | ||
3214 | mCalPrinter->setupPrinter(); | 3214 | mCalPrinter->setupPrinter(); |
3215 | #endif | 3215 | #endif |
3216 | } | 3216 | } |
3217 | 3217 | ||
3218 | void CalendarView::print() | 3218 | void CalendarView::print() |
3219 | { | 3219 | { |
3220 | #ifndef KORG_NOPRINTER | 3220 | #ifndef KORG_NOPRINTER |
3221 | createPrinter(); | 3221 | createPrinter(); |
3222 | 3222 | ||
3223 | DateList tmpDateList = mNavigator->selectedDates(); | 3223 | DateList tmpDateList = mNavigator->selectedDates(); |
3224 | mCalPrinter->print(CalPrinter::Month, | 3224 | mCalPrinter->print(CalPrinter::Month, |
3225 | tmpDateList.first(), tmpDateList.last()); | 3225 | tmpDateList.first(), tmpDateList.last()); |
3226 | #endif | 3226 | #endif |
3227 | } | 3227 | } |
3228 | 3228 | ||
3229 | void CalendarView::printPreview() | 3229 | void CalendarView::printPreview() |
3230 | { | 3230 | { |
3231 | #ifndef KORG_NOPRINTER | 3231 | #ifndef KORG_NOPRINTER |
3232 | kdDebug() << "CalendarView::printPreview()" << endl; | 3232 | kdDebug() << "CalendarView::printPreview()" << endl; |
3233 | 3233 | ||
3234 | createPrinter(); | 3234 | createPrinter(); |
3235 | 3235 | ||
3236 | DateList tmpDateList = mNavigator->selectedDates(); | 3236 | DateList tmpDateList = mNavigator->selectedDates(); |
3237 | 3237 | ||
3238 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3238 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3239 | tmpDateList.last()); | 3239 | tmpDateList.last()); |
3240 | #endif | 3240 | #endif |
3241 | } | 3241 | } |
3242 | 3242 | ||
3243 | void CalendarView::exportICalendar() | 3243 | void CalendarView::exportICalendar() |
3244 | { | 3244 | { |
3245 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3245 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3246 | 3246 | ||
3247 | // Force correct extension | 3247 | // Force correct extension |
3248 | if (filename.right(4) != ".ics") filename += ".ics"; | 3248 | if (filename.right(4) != ".ics") filename += ".ics"; |
3249 | 3249 | ||
3250 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3250 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3251 | storage.save(); | 3251 | storage.save(); |
3252 | } | 3252 | } |
3253 | 3253 | ||
3254 | bool CalendarView::exportVCalendar( QString filename ) | 3254 | bool CalendarView::exportVCalendar( QString filename ) |
3255 | { | 3255 | { |
3256 | if (mCalendar->journals().count() > 0) { | 3256 | if (mCalendar->journals().count() > 0) { |
3257 | int result = KMessageBox::warningContinueCancel(this, | 3257 | int result = KMessageBox::warningContinueCancel(this, |
3258 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3258 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3259 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3259 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3260 | true); | 3260 | true); |
3261 | if (result != KMessageBox::Continue) return false; | 3261 | if (result != KMessageBox::Continue) return false; |
3262 | } | 3262 | } |
3263 | 3263 | ||
3264 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3264 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3265 | 3265 | ||
3266 | // Force correct extension | 3266 | // Force correct extension |
3267 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3267 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3268 | 3268 | ||
3269 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3269 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3270 | return storage.save(); | 3270 | return storage.save(); |
3271 | 3271 | ||
3272 | } | 3272 | } |
3273 | 3273 | ||
3274 | void CalendarView::eventUpdated(Incidence *) | 3274 | void CalendarView::eventUpdated(Incidence *) |
3275 | { | 3275 | { |
3276 | setModified(); | 3276 | setModified(); |
3277 | // Don't call updateView here. The code, which has caused the update of the | 3277 | // Don't call updateView here. The code, which has caused the update of the |
3278 | // event is responsible for updating the view. | 3278 | // event is responsible for updating the view. |
3279 | // updateView(); | 3279 | // updateView(); |
3280 | } | 3280 | } |
3281 | 3281 | ||
3282 | void CalendarView::adaptNavigationUnits() | 3282 | void CalendarView::adaptNavigationUnits() |
3283 | { | 3283 | { |
3284 | if (mViewManager->currentView()->isEventView()) { | 3284 | if (mViewManager->currentView()->isEventView()) { |
3285 | int days = mViewManager->currentView()->currentDateCount(); | 3285 | int days = mViewManager->currentView()->currentDateCount(); |
3286 | if (days == 1) { | 3286 | if (days == 1) { |
3287 | emit changeNavStringPrev(i18n("&Previous Day")); | 3287 | emit changeNavStringPrev(i18n("&Previous Day")); |
3288 | emit changeNavStringNext(i18n("&Next Day")); | 3288 | emit changeNavStringNext(i18n("&Next Day")); |
3289 | } else { | 3289 | } else { |
3290 | emit changeNavStringPrev(i18n("&Previous Week")); | 3290 | emit changeNavStringPrev(i18n("&Previous Week")); |
3291 | emit changeNavStringNext(i18n("&Next Week")); | 3291 | emit changeNavStringNext(i18n("&Next Week")); |
3292 | } | 3292 | } |
3293 | } | 3293 | } |
3294 | } | 3294 | } |
3295 | 3295 | ||
3296 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3296 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3297 | { | 3297 | { |
3298 | if ( incidence ) mTodoList->clearSelection(); | 3298 | if ( incidence ) mTodoList->clearSelection(); |
3299 | processIncidenceSelection( incidence ); | 3299 | processIncidenceSelection( incidence ); |
3300 | } | 3300 | } |
3301 | 3301 | ||
3302 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3302 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3303 | { | 3303 | { |
3304 | if ( incidence && mViewManager->currentView() ) { | 3304 | if ( incidence && mViewManager->currentView() ) { |
3305 | mViewManager->currentView()->clearSelection(); | 3305 | mViewManager->currentView()->clearSelection(); |
3306 | } | 3306 | } |
3307 | processIncidenceSelection( incidence ); | 3307 | processIncidenceSelection( incidence ); |
3308 | } | 3308 | } |
3309 | 3309 | ||
3310 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3310 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3311 | { | 3311 | { |
3312 | if ( incidence == mSelectedIncidence ) return; | 3312 | if ( incidence == mSelectedIncidence ) return; |
3313 | 3313 | ||
3314 | mSelectedIncidence = incidence; | 3314 | mSelectedIncidence = incidence; |
3315 | 3315 | ||
3316 | emit incidenceSelected( mSelectedIncidence ); | 3316 | emit incidenceSelected( mSelectedIncidence ); |
3317 | 3317 | ||
3318 | if ( incidence && incidence->type() == "Event" ) { | 3318 | if ( incidence && incidence->type() == "Event" ) { |
3319 | Event *event = static_cast<Event *>( incidence ); | 3319 | Event *event = static_cast<Event *>( incidence ); |
3320 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3320 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3321 | emit organizerEventsSelected( true ); | 3321 | emit organizerEventsSelected( true ); |
3322 | } else { | 3322 | } else { |
3323 | emit organizerEventsSelected(false); | 3323 | emit organizerEventsSelected(false); |
3324 | } | 3324 | } |
3325 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3325 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3326 | KOPrefs::instance()->email() ) ) { | 3326 | KOPrefs::instance()->email() ) ) { |
3327 | emit groupEventsSelected( true ); | 3327 | emit groupEventsSelected( true ); |
3328 | } else { | 3328 | } else { |
3329 | emit groupEventsSelected(false); | 3329 | emit groupEventsSelected(false); |
3330 | } | 3330 | } |
3331 | return; | 3331 | return; |
3332 | } else { | 3332 | } else { |
3333 | if ( incidence && incidence->type() == "Todo" ) { | 3333 | if ( incidence && incidence->type() == "Todo" ) { |
3334 | emit todoSelected( true ); | 3334 | emit todoSelected( true ); |
3335 | Todo *event = static_cast<Todo *>( incidence ); | 3335 | Todo *event = static_cast<Todo *>( incidence ); |
3336 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3336 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3337 | emit organizerEventsSelected( true ); | 3337 | emit organizerEventsSelected( true ); |
3338 | } else { | 3338 | } else { |
3339 | emit organizerEventsSelected(false); | 3339 | emit organizerEventsSelected(false); |
3340 | } | 3340 | } |
3341 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3341 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3342 | KOPrefs::instance()->email() ) ) { | 3342 | KOPrefs::instance()->email() ) ) { |
3343 | emit groupEventsSelected( true ); | 3343 | emit groupEventsSelected( true ); |
3344 | } else { | 3344 | } else { |
3345 | emit groupEventsSelected(false); | 3345 | emit groupEventsSelected(false); |
3346 | } | 3346 | } |
3347 | return; | 3347 | return; |
3348 | } else { | 3348 | } else { |
3349 | emit todoSelected( false ); | 3349 | emit todoSelected( false ); |
3350 | emit organizerEventsSelected(false); | 3350 | emit organizerEventsSelected(false); |
3351 | emit groupEventsSelected(false); | 3351 | emit groupEventsSelected(false); |
3352 | } | 3352 | } |
3353 | return; | 3353 | return; |
3354 | } | 3354 | } |
3355 | 3355 | ||
3356 | /* if ( incidence && incidence->type() == "Todo" ) { | 3356 | /* if ( incidence && incidence->type() == "Todo" ) { |
3357 | emit todoSelected( true ); | 3357 | emit todoSelected( true ); |
3358 | } else { | 3358 | } else { |
3359 | emit todoSelected( false ); | 3359 | emit todoSelected( false ); |
3360 | }*/ | 3360 | }*/ |
3361 | } | 3361 | } |
3362 | 3362 | ||
3363 | 3363 | ||
3364 | void CalendarView::checkClipboard() | 3364 | void CalendarView::checkClipboard() |
3365 | { | 3365 | { |
3366 | #ifndef KORG_NODND | 3366 | #ifndef KORG_NODND |
3367 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3367 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3368 | emit pasteEnabled(true); | 3368 | emit pasteEnabled(true); |
3369 | } else { | 3369 | } else { |
3370 | emit pasteEnabled(false); | 3370 | emit pasteEnabled(false); |
3371 | } | 3371 | } |
3372 | #endif | 3372 | #endif |
3373 | } | 3373 | } |
3374 | 3374 | ||
3375 | void CalendarView::showDates(const DateList &selectedDates) | 3375 | void CalendarView::showDates(const DateList &selectedDates) |
3376 | { | 3376 | { |
3377 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3377 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3378 | 3378 | ||
3379 | if ( mViewManager->currentView() ) { | 3379 | if ( mViewManager->currentView() ) { |
3380 | updateView( selectedDates.first(), selectedDates.last() ); | 3380 | updateView( selectedDates.first(), selectedDates.last() ); |
3381 | } else { | 3381 | } else { |
3382 | mViewManager->showAgendaView(); | 3382 | mViewManager->showAgendaView(); |
3383 | } | 3383 | } |
3384 | 3384 | ||
3385 | QString selDates; | 3385 | QString selDates; |
3386 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); | 3386 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); |
3387 | if (selectedDates.first() < selectedDates.last() ) | 3387 | if (selectedDates.first() < selectedDates.last() ) |
3388 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3388 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3389 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3389 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3390 | 3390 | ||
3391 | } | 3391 | } |
3392 | 3392 | ||
3393 | QPtrList<CalFilter> CalendarView::filters() | 3393 | QPtrList<CalFilter> CalendarView::filters() |
3394 | { | 3394 | { |
3395 | return mFilters; | 3395 | return mFilters; |
3396 | 3396 | ||
3397 | } | 3397 | } |
3398 | void CalendarView::editFilters() | 3398 | void CalendarView::editFilters() |
3399 | { | 3399 | { |
3400 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3400 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3401 | 3401 | ||
3402 | CalFilter *filter = mFilters.first(); | 3402 | CalFilter *filter = mFilters.first(); |
3403 | while(filter) { | 3403 | while(filter) { |
3404 | kdDebug() << " Filter: " << filter->name() << endl; | 3404 | kdDebug() << " Filter: " << filter->name() << endl; |
3405 | filter = mFilters.next(); | 3405 | filter = mFilters.next(); |
3406 | } | 3406 | } |
3407 | 3407 | ||
3408 | mDialogManager->showFilterEditDialog(&mFilters); | 3408 | mDialogManager->showFilterEditDialog(&mFilters); |
3409 | } | 3409 | } |
3410 | void CalendarView::toggleFilter() | 3410 | void CalendarView::toggleFilter() |
3411 | { | 3411 | { |
3412 | showFilter(! mFilterView->isVisible()); | 3412 | showFilter(! mFilterView->isVisible()); |
3413 | } | 3413 | } |
3414 | 3414 | ||
3415 | KOFilterView *CalendarView::filterView() | 3415 | KOFilterView *CalendarView::filterView() |
3416 | { | 3416 | { |
3417 | return mFilterView; | 3417 | return mFilterView; |
3418 | } | 3418 | } |
3419 | void CalendarView::selectFilter( int fil ) | 3419 | void CalendarView::selectFilter( int fil ) |
3420 | { | 3420 | { |
3421 | mFilterView->setSelectedFilter( fil ); | 3421 | mFilterView->setSelectedFilter( fil ); |
3422 | } | 3422 | } |
3423 | void CalendarView::showFilter(bool visible) | 3423 | void CalendarView::showFilter(bool visible) |
3424 | { | 3424 | { |
3425 | if (visible) mFilterView->show(); | 3425 | if (visible) mFilterView->show(); |
3426 | else mFilterView->hide(); | 3426 | else mFilterView->hide(); |
3427 | } | 3427 | } |
3428 | void CalendarView::toggleFilerEnabled( ) | 3428 | void CalendarView::toggleFilerEnabled( ) |
3429 | { | 3429 | { |
3430 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3430 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3431 | if ( !mFilterView->filtersEnabled() ) | 3431 | if ( !mFilterView->filtersEnabled() ) |
3432 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3432 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3433 | 3433 | ||
3434 | } | 3434 | } |
3435 | void CalendarView::updateFilter() | 3435 | void CalendarView::updateFilter() |
3436 | { | 3436 | { |
3437 | CalFilter *filter = mFilterView->selectedFilter(); | 3437 | CalFilter *filter = mFilterView->selectedFilter(); |
3438 | if (filter) { | 3438 | if (filter) { |
3439 | if (mFilterView->filtersEnabled()) { | 3439 | if (mFilterView->filtersEnabled()) { |
3440 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); | 3440 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); |
3441 | filter->setEnabled(true); | 3441 | filter->setEnabled(true); |
3442 | } | 3442 | } |
3443 | else filter->setEnabled(false); | 3443 | else filter->setEnabled(false); |
3444 | mCalendar->setFilter(filter); | 3444 | mCalendar->setFilter(filter); |
3445 | updateView(); | 3445 | updateView(); |
3446 | } | 3446 | } |
3447 | } | 3447 | } |
3448 | 3448 | ||
3449 | void CalendarView::filterEdited() | 3449 | void CalendarView::filterEdited() |
3450 | { | 3450 | { |
3451 | mFilterView->updateFilters(); | 3451 | mFilterView->updateFilters(); |
3452 | updateFilter(); | 3452 | updateFilter(); |
3453 | writeSettings(); | 3453 | writeSettings(); |
3454 | } | 3454 | } |
3455 | 3455 | ||
3456 | 3456 | ||
3457 | void CalendarView::takeOverEvent() | 3457 | void CalendarView::takeOverEvent() |
3458 | { | 3458 | { |
3459 | Incidence *incidence = currentSelection(); | 3459 | Incidence *incidence = currentSelection(); |
3460 | 3460 | ||
3461 | if (!incidence) return; | 3461 | if (!incidence) return; |
3462 | 3462 | ||
3463 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3463 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3464 | incidence->recreate(); | 3464 | incidence->recreate(); |
3465 | incidence->setReadOnly(false); | 3465 | incidence->setReadOnly(false); |
3466 | 3466 | ||
3467 | updateView(); | 3467 | updateView(); |
3468 | } | 3468 | } |
3469 | 3469 | ||
3470 | void CalendarView::takeOverCalendar() | 3470 | void CalendarView::takeOverCalendar() |
3471 | { | 3471 | { |
3472 | // TODO: Create Calendar::allIncidences() function and use it here | 3472 | // TODO: Create Calendar::allIncidences() function and use it here |
3473 | 3473 | ||
3474 | QPtrList<Event> events = mCalendar->events(); | 3474 | QPtrList<Event> events = mCalendar->events(); |
3475 | for(uint i=0; i<events.count(); ++i) { | 3475 | for(uint i=0; i<events.count(); ++i) { |
3476 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3476 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3477 | events.at(i)->recreate(); | 3477 | events.at(i)->recreate(); |
3478 | events.at(i)->setReadOnly(false); | 3478 | events.at(i)->setReadOnly(false); |
3479 | } | 3479 | } |
3480 | 3480 | ||
3481 | QPtrList<Todo> todos = mCalendar->todos(); | 3481 | QPtrList<Todo> todos = mCalendar->todos(); |
3482 | for(uint i=0; i<todos.count(); ++i) { | 3482 | for(uint i=0; i<todos.count(); ++i) { |
3483 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3483 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3484 | todos.at(i)->recreate(); | 3484 | todos.at(i)->recreate(); |
3485 | todos.at(i)->setReadOnly(false); | 3485 | todos.at(i)->setReadOnly(false); |
3486 | } | 3486 | } |
3487 | 3487 | ||
3488 | QPtrList<Journal> journals = mCalendar->journals(); | 3488 | QPtrList<Journal> journals = mCalendar->journals(); |
3489 | for(uint i=0; i<journals.count(); ++i) { | 3489 | for(uint i=0; i<journals.count(); ++i) { |
3490 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3490 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3491 | journals.at(i)->recreate(); | 3491 | journals.at(i)->recreate(); |
3492 | journals.at(i)->setReadOnly(false); | 3492 | journals.at(i)->setReadOnly(false); |
3493 | } | 3493 | } |
3494 | 3494 | ||
3495 | updateView(); | 3495 | updateView(); |
3496 | } | 3496 | } |
3497 | 3497 | ||
3498 | void CalendarView::showIntro() | 3498 | void CalendarView::showIntro() |
3499 | { | 3499 | { |
3500 | kdDebug() << "To be implemented." << endl; | 3500 | kdDebug() << "To be implemented." << endl; |
3501 | } | 3501 | } |
3502 | 3502 | ||
3503 | QWidgetStack *CalendarView::viewStack() | 3503 | QWidgetStack *CalendarView::viewStack() |
3504 | { | 3504 | { |
3505 | return mRightFrame; | 3505 | return mRightFrame; |
3506 | } | 3506 | } |
3507 | 3507 | ||
3508 | QWidget *CalendarView::leftFrame() | 3508 | QWidget *CalendarView::leftFrame() |
3509 | { | 3509 | { |
3510 | return mLeftFrame; | 3510 | return mLeftFrame; |
3511 | } | 3511 | } |
3512 | 3512 | ||
3513 | DateNavigator *CalendarView::dateNavigator() | 3513 | DateNavigator *CalendarView::dateNavigator() |
3514 | { | 3514 | { |
3515 | return mNavigator; | 3515 | return mNavigator; |
3516 | } | 3516 | } |
3517 | 3517 | ||
3518 | KDateNavigator* CalendarView::dateNavigatorWidget() | 3518 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3519 | { | 3519 | { |
3520 | return mDateNavigator; | 3520 | return mDateNavigator; |
3521 | } | 3521 | } |
3522 | void CalendarView::toggleDateNavigatorWidget() | 3522 | void CalendarView::toggleDateNavigatorWidget() |
3523 | { | 3523 | { |
3524 | if (mDateNavigator->isVisible()) | 3524 | if (mDateNavigator->isVisible()) |
3525 | mDateNavigator->hide(); | 3525 | mDateNavigator->hide(); |
3526 | else | 3526 | else |
3527 | mDateNavigator->show(); | 3527 | mDateNavigator->show(); |
3528 | } | 3528 | } |
3529 | void CalendarView::addView(KOrg::BaseView *view) | 3529 | void CalendarView::addView(KOrg::BaseView *view) |
3530 | { | 3530 | { |
3531 | mViewManager->addView(view); | 3531 | mViewManager->addView(view); |
3532 | } | 3532 | } |
3533 | 3533 | ||
3534 | void CalendarView::showView(KOrg::BaseView *view) | 3534 | void CalendarView::showView(KOrg::BaseView *view) |
3535 | { | 3535 | { |
3536 | mViewManager->showView(view, mLeftFrame->isVisible()); | 3536 | mViewManager->showView(view, mLeftFrame->isVisible()); |
3537 | } | 3537 | } |
3538 | 3538 | ||
3539 | Incidence *CalendarView::currentSelection() | 3539 | Incidence *CalendarView::currentSelection() |
3540 | { | 3540 | { |
3541 | return mViewManager->currentSelection(); | 3541 | return mViewManager->currentSelection(); |
3542 | } | 3542 | } |
3543 | void CalendarView::toggleAllDaySize() | 3543 | void CalendarView::toggleAllDaySize() |
3544 | { | 3544 | { |
3545 | /* | 3545 | /* |
3546 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 3546 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
3547 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 3547 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
3548 | else | 3548 | else |
3549 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3549 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3550 | */ | 3550 | */ |
3551 | viewManager()->agendaView()->toggleAllDay(); | 3551 | viewManager()->agendaView()->toggleAllDay(); |
3552 | } | 3552 | } |
3553 | void CalendarView::toggleExpand() | 3553 | void CalendarView::toggleExpand() |
3554 | { | 3554 | { |
3555 | // if ( mLeftFrame->isHidden() ) { | 3555 | // if ( mLeftFrame->isHidden() ) { |
3556 | // mLeftFrame->show(); | 3556 | // mLeftFrame->show(); |
3557 | // emit calendarViewExpanded( false ); | 3557 | // emit calendarViewExpanded( false ); |
3558 | // } else { | 3558 | // } else { |
3559 | // mLeftFrame->hide(); | 3559 | // mLeftFrame->hide(); |
3560 | // emit calendarViewExpanded( true ); | 3560 | // emit calendarViewExpanded( true ); |
3561 | // } | 3561 | // } |
3562 | 3562 | ||
3563 | globalFlagBlockAgenda = 1; | 3563 | globalFlagBlockAgenda = 1; |
3564 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3564 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3565 | globalFlagBlockAgenda = 5; | 3565 | globalFlagBlockAgenda = 5; |
3566 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3566 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3567 | //mViewManager->showView( 0, true ); | 3567 | //mViewManager->showView( 0, true ); |
3568 | } | 3568 | } |
3569 | 3569 | ||
3570 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3570 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3571 | { | 3571 | { |
3572 | setModified( modified ); | 3572 | setModified( modified ); |
3573 | } | 3573 | } |
3574 | 3574 | ||
3575 | Todo *CalendarView::selectedTodo() | 3575 | Todo *CalendarView::selectedTodo() |
3576 | { | 3576 | { |
3577 | Incidence *incidence = currentSelection(); | 3577 | Incidence *incidence = currentSelection(); |
3578 | if ( incidence && incidence->type() == "Todo" ) { | 3578 | if ( incidence && incidence->type() == "Todo" ) { |
3579 | return static_cast<Todo *>( incidence ); | 3579 | return static_cast<Todo *>( incidence ); |
3580 | } | 3580 | } |
3581 | 3581 | ||
3582 | incidence = mTodoList->selectedIncidences().first(); | 3582 | incidence = mTodoList->selectedIncidences().first(); |
3583 | if ( incidence && incidence->type() == "Todo" ) { | 3583 | if ( incidence && incidence->type() == "Todo" ) { |
3584 | return static_cast<Todo *>( incidence ); | 3584 | return static_cast<Todo *>( incidence ); |
3585 | } | 3585 | } |
3586 | 3586 | ||
3587 | return 0; | 3587 | return 0; |
3588 | } | 3588 | } |
3589 | 3589 | ||
3590 | void CalendarView::dialogClosing(Incidence *in) | 3590 | void CalendarView::dialogClosing(Incidence *in) |
3591 | { | 3591 | { |
3592 | // mDialogList.remove(in); | 3592 | // mDialogList.remove(in); |
3593 | } | 3593 | } |
3594 | 3594 | ||
3595 | void CalendarView::showIncidence() | 3595 | void CalendarView::showIncidence() |
3596 | { | 3596 | { |
3597 | Incidence *incidence = currentSelection(); | 3597 | Incidence *incidence = currentSelection(); |
3598 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3598 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3599 | if ( incidence ) { | 3599 | if ( incidence ) { |
3600 | ShowIncidenceVisitor v; | 3600 | ShowIncidenceVisitor v; |
3601 | v.act( incidence, this ); | 3601 | v.act( incidence, this ); |
3602 | } | 3602 | } |
3603 | } | 3603 | } |
3604 | void CalendarView::editIncidenceDescription() | 3604 | void CalendarView::editIncidenceDescription() |
3605 | { | 3605 | { |
3606 | mFlagEditDescription = true; | 3606 | mFlagEditDescription = true; |
3607 | editIncidence(); | 3607 | editIncidence(); |
3608 | mFlagEditDescription = false; | 3608 | mFlagEditDescription = false; |
3609 | } | 3609 | } |
3610 | void CalendarView::editIncidence() | 3610 | void CalendarView::editIncidence() |
3611 | { | 3611 | { |
3612 | // qDebug("editIncidence() "); | 3612 | // qDebug("editIncidence() "); |
3613 | Incidence *incidence = currentSelection(); | 3613 | Incidence *incidence = currentSelection(); |
3614 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3614 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3615 | if ( incidence ) { | 3615 | if ( incidence ) { |
3616 | EditIncidenceVisitor v; | 3616 | EditIncidenceVisitor v; |
3617 | v.act( incidence, this ); | 3617 | v.act( incidence, this ); |
3618 | } | 3618 | } |
3619 | } | 3619 | } |
3620 | 3620 | ||
3621 | void CalendarView::deleteIncidence() | 3621 | void CalendarView::deleteIncidence() |
3622 | { | 3622 | { |
3623 | Incidence *incidence = currentSelection(); | 3623 | Incidence *incidence = currentSelection(); |
3624 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3624 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3625 | if ( incidence ) { | 3625 | if ( incidence ) { |
3626 | deleteIncidence(incidence); | 3626 | deleteIncidence(incidence); |
3627 | } | 3627 | } |
3628 | } | 3628 | } |
3629 | 3629 | ||
3630 | void CalendarView::showIncidence(Incidence *incidence) | 3630 | void CalendarView::showIncidence(Incidence *incidence) |
3631 | { | 3631 | { |
3632 | if ( incidence ) { | 3632 | if ( incidence ) { |
3633 | ShowIncidenceVisitor v; | 3633 | ShowIncidenceVisitor v; |
3634 | v.act( incidence, this ); | 3634 | v.act( incidence, this ); |
3635 | } | 3635 | } |
3636 | } | 3636 | } |
3637 | 3637 | ||
3638 | void CalendarView::editIncidence(Incidence *incidence) | 3638 | void CalendarView::editIncidence(Incidence *incidence) |
3639 | { | 3639 | { |
3640 | if ( incidence ) { | 3640 | if ( incidence ) { |
3641 | 3641 | ||
3642 | EditIncidenceVisitor v; | 3642 | EditIncidenceVisitor v; |
3643 | v.act( incidence, this ); | 3643 | v.act( incidence, this ); |
3644 | 3644 | ||
3645 | } | 3645 | } |
3646 | } | 3646 | } |
3647 | 3647 | ||
3648 | void CalendarView::deleteIncidence(Incidence *incidence) | 3648 | void CalendarView::deleteIncidence(Incidence *incidence) |
3649 | { | 3649 | { |
3650 | //qDebug(" CalendarView::deleteIncidence "); | 3650 | //qDebug(" CalendarView::deleteIncidence "); |
3651 | if ( incidence ) { | 3651 | if ( incidence ) { |
3652 | DeleteIncidenceVisitor v; | 3652 | DeleteIncidenceVisitor v; |
3653 | v.act( incidence, this ); | 3653 | v.act( incidence, this ); |
3654 | } | 3654 | } |
3655 | } | 3655 | } |
3656 | 3656 | ||
3657 | 3657 | ||
3658 | void CalendarView::lookForOutgoingMessages() | 3658 | void CalendarView::lookForOutgoingMessages() |
3659 | { | 3659 | { |
3660 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3660 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3661 | ogd->loadMessages(); | 3661 | ogd->loadMessages(); |
3662 | } | 3662 | } |
3663 | 3663 | ||
3664 | void CalendarView::lookForIncomingMessages() | 3664 | void CalendarView::lookForIncomingMessages() |
3665 | { | 3665 | { |
3666 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3666 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3667 | icd->retrieve(); | 3667 | icd->retrieve(); |
3668 | } | 3668 | } |
3669 | 3669 | ||
3670 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3670 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3671 | { | 3671 | { |
3672 | bool deleteTodo = true; | 3672 | bool deleteTodo = true; |
3673 | QPtrList<Incidence> subTodos; | 3673 | QPtrList<Incidence> subTodos; |
3674 | Incidence *aTodo; | 3674 | Incidence *aTodo; |
3675 | subTodos = t->relations(); | 3675 | subTodos = t->relations(); |
3676 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3676 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3677 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3677 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3678 | deleteTodo = false; | 3678 | deleteTodo = false; |
3679 | } | 3679 | } |
3680 | if ( deleteTodo ) { | 3680 | if ( deleteTodo ) { |
3681 | if ( t->isCompleted() ) { | 3681 | if ( t->isCompleted() ) { |
3682 | checkExternalId( t ); | 3682 | checkExternalId( t ); |
3683 | mCalendar->deleteTodo( t ); | 3683 | mCalendar->deleteTodo( t ); |
3684 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3684 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3685 | } | 3685 | } |
3686 | else | 3686 | else |
3687 | deleteTodo = false; | 3687 | deleteTodo = false; |
3688 | } | 3688 | } |
3689 | return deleteTodo; | 3689 | return deleteTodo; |
3690 | 3690 | ||
3691 | } | 3691 | } |
3692 | void CalendarView::purgeCompleted() | 3692 | void CalendarView::purgeCompleted() |
3693 | { | 3693 | { |
3694 | int result = KMessageBox::warningContinueCancel(this, | 3694 | int result = KMessageBox::warningContinueCancel(this, |
3695 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3695 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3696 | 3696 | ||
3697 | if (result == KMessageBox::Continue) { | 3697 | if (result == KMessageBox::Continue) { |
3698 | 3698 | ||
3699 | QPtrList<Todo> todoCal; | 3699 | QPtrList<Todo> todoCal; |
3700 | QPtrList<Todo> rootTodos; | 3700 | QPtrList<Todo> rootTodos; |
3701 | //QPtrList<Incidence> rel; | 3701 | //QPtrList<Incidence> rel; |
3702 | Todo *aTodo;//, *rTodo; | 3702 | Todo *aTodo;//, *rTodo; |
3703 | Incidence *rIncidence; | 3703 | Incidence *rIncidence; |
3704 | bool childDelete = false; | 3704 | bool childDelete = false; |
3705 | bool deletedOne = true; | 3705 | bool deletedOne = true; |
3706 | todoCal = calendar()->todos(); | 3706 | todoCal = calendar()->todos(); |
3707 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3707 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3708 | if ( !aTodo->relatedTo() ) | 3708 | if ( !aTodo->relatedTo() ) |
3709 | rootTodos.append( aTodo ); | 3709 | rootTodos.append( aTodo ); |
3710 | } | 3710 | } |
3711 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3711 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3712 | removeCompletedSubTodos( aTodo ); | 3712 | removeCompletedSubTodos( aTodo ); |
3713 | } | 3713 | } |
3714 | 3714 | ||
3715 | updateView(); | 3715 | updateView(); |
3716 | } | 3716 | } |
3717 | } | 3717 | } |
3718 | 3718 | ||
3719 | void CalendarView::slotCalendarChanged() | 3719 | void CalendarView::slotCalendarChanged() |
3720 | { | 3720 | { |
3721 | ; | 3721 | ; |
3722 | } | 3722 | } |
3723 | 3723 | ||
3724 | NavigatorBar *CalendarView::navigatorBar() | 3724 | NavigatorBar *CalendarView::navigatorBar() |
3725 | { | 3725 | { |
3726 | return mNavigatorBar; | 3726 | return mNavigatorBar; |
3727 | } | 3727 | } |
3728 | 3728 | ||
3729 | 3729 | ||
3730 | 3730 | ||
3731 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3731 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3732 | { | 3732 | { |
3733 | //qDebug(" alendarView::keyPressEvent "); | 3733 | //qDebug(" alendarView::keyPressEvent "); |
3734 | e->ignore(); | 3734 | e->ignore(); |
3735 | } | 3735 | } |
3736 | 3736 | ||
3737 | 3737 | ||
3738 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 3738 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3739 | { | 3739 | { |
3740 | // mSyncManager = manager; | 3740 | // mSyncManager = manager; |
3741 | mSyncKDE = false; | 3741 | mSyncKDE = false; |
3742 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 3742 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
3743 | qDebug("SyncKDE request detected!"); | 3743 | qDebug("SyncKDE request detected!"); |
3744 | mSyncKDE = true; | 3744 | mSyncKDE = true; |
3745 | } | 3745 | } |
3746 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3746 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3747 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3747 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3748 | return syncCalendar( filename, mode ); | 3748 | return syncCalendar( filename, mode ); |
3749 | } | 3749 | } |
3750 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 3750 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
3751 | { | 3751 | { |
3752 | mSyncKDE = false; | 3752 | mSyncKDE = false; |
3753 | //mSyncManager = manager; | 3753 | //mSyncManager = manager; |
3754 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3754 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3755 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3755 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3756 | if ( resource == "sharp" ) | 3756 | if ( resource == "sharp" ) |
3757 | syncExternal( 0 ); | 3757 | syncExternal( 0 ); |
3758 | if ( resource == "phone" ) | 3758 | if ( resource == "phone" ) |
3759 | syncExternal( 1 ); | 3759 | syncExternal( 1 ); |
3760 | // pending setmodified | 3760 | // pending setmodified |
3761 | return true; | 3761 | return true; |
3762 | } | 3762 | } |
3763 | void CalendarView::setSyncManager(KSyncManager* manager) | 3763 | void CalendarView::setSyncManager(KSyncManager* manager) |
3764 | { | 3764 | { |
3765 | mSyncManager = manager; | 3765 | mSyncManager = manager; |
3766 | } | 3766 | } |
3767 | |||
3768 | void CalendarView::removeSyncInfo( QString syncProfile) | ||
3769 | { | ||
3770 | qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); | ||
3771 | |||
3772 | } | ||
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index 2818ee9..acc20d6 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -1,605 +1,606 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000, 2001 | 3 | Copyright (c) 2000, 2001 |
4 | Cornelius Schumacher <schumacher@kde.org> | 4 | Cornelius Schumacher <schumacher@kde.org> |
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 as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | #ifndef CALENDARVIEW_H | 24 | #ifndef CALENDARVIEW_H |
25 | #define CALENDARVIEW_H | 25 | #define CALENDARVIEW_H |
26 | 26 | ||
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #include <qptrlist.h> | 30 | #include <qptrlist.h> |
31 | #include <qvbox.h> | 31 | #include <qvbox.h> |
32 | #include <qmap.h> | 32 | #include <qmap.h> |
33 | #ifndef DESKTOP_VERSION | 33 | #ifndef DESKTOP_VERSION |
34 | #include <qtopia/ir.h> | 34 | #include <qtopia/ir.h> |
35 | #else | 35 | #else |
36 | #define Ir char | 36 | #define Ir char |
37 | #endif | 37 | #endif |
38 | #include <libkcal/calendar.h> | 38 | #include <libkcal/calendar.h> |
39 | #include <libkcal/scheduler.h> | 39 | #include <libkcal/scheduler.h> |
40 | #include <libkcal/calendarresources.h> | 40 | #include <libkcal/calendarresources.h> |
41 | #include <libkcal/resourcecalendar.h> | 41 | #include <libkcal/resourcecalendar.h> |
42 | 42 | ||
43 | #include <korganizer/calendarviewbase.h> | 43 | #include <korganizer/calendarviewbase.h> |
44 | 44 | ||
45 | #include <ksyncmanager.h> | 45 | #include <ksyncmanager.h> |
46 | 46 | ||
47 | class QWidgetStack; | 47 | class QWidgetStack; |
48 | class QSplitter; | 48 | class QSplitter; |
49 | 49 | ||
50 | class CalPrinter; | 50 | class CalPrinter; |
51 | class KOFilterView; | 51 | class KOFilterView; |
52 | class KOViewManager; | 52 | class KOViewManager; |
53 | class KODialogManager; | 53 | class KODialogManager; |
54 | class KOTodoView; | 54 | class KOTodoView; |
55 | class KDateNavigator; | 55 | class KDateNavigator; |
56 | class DateNavigator; | 56 | class DateNavigator; |
57 | class KOIncidenceEditor; | 57 | class KOIncidenceEditor; |
58 | class KDatePicker; | 58 | class KDatePicker; |
59 | class ResourceView; | 59 | class ResourceView; |
60 | class NavigatorBar; | 60 | class NavigatorBar; |
61 | class KOEventEditor; | 61 | class KOEventEditor; |
62 | class KOTodoEditor ; | 62 | class KOTodoEditor ; |
63 | class KOEventViewerDialog; | 63 | class KOEventViewerDialog; |
64 | class KOBeamPrefs; | 64 | class KOBeamPrefs; |
65 | class KSyncProfile; | 65 | class KSyncProfile; |
66 | class AlarmDialog; | 66 | class AlarmDialog; |
67 | class KCal::Attendee; | 67 | class KCal::Attendee; |
68 | 68 | ||
69 | namespace KCal { class FileStorage; } | 69 | namespace KCal { class FileStorage; } |
70 | 70 | ||
71 | using namespace KCal; | 71 | using namespace KCal; |
72 | 72 | ||
73 | /** | 73 | /** |
74 | This is the main calendar widget. It provides the different vies on t he | 74 | This is the main calendar widget. It provides the different vies on t he |
75 | calendar data as well as the date navigator. It also handles synchronisation | 75 | calendar data as well as the date navigator. It also handles synchronisation |
76 | of the different views and controls the different dialogs like preferences, | 76 | of the different views and controls the different dialogs like preferences, |
77 | event editor, search dialog etc. | 77 | event editor, search dialog etc. |
78 | 78 | ||
79 | @short main calendar view widget | 79 | @short main calendar view widget |
80 | @author Cornelius Schumacher | 80 | @author Cornelius Schumacher |
81 | */ | 81 | */ |
82 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface | 82 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface |
83 | { | 83 | { |
84 | Q_OBJECT | 84 | Q_OBJECT |
85 | public: | 85 | public: |
86 | /** | 86 | /** |
87 | Constructs a new calendar view widget. | 87 | Constructs a new calendar view widget. |
88 | 88 | ||
89 | @param calendar calendar document | 89 | @param calendar calendar document |
90 | @param parent parent window | 90 | @param parent parent window |
91 | @param name Qt internal widget object name | 91 | @param name Qt internal widget object name |
92 | */ | 92 | */ |
93 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, | 93 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, |
94 | const char *name = 0 ); | 94 | const char *name = 0 ); |
95 | CalendarView( Calendar *calendar, QWidget *parent = 0, | 95 | CalendarView( Calendar *calendar, QWidget *parent = 0, |
96 | const char *name = 0 ); | 96 | const char *name = 0 ); |
97 | virtual ~CalendarView(); | 97 | virtual ~CalendarView(); |
98 | 98 | ||
99 | Calendar *calendar() { return mCalendar; } | 99 | Calendar *calendar() { return mCalendar; } |
100 | 100 | ||
101 | KOViewManager *viewManager(); | 101 | KOViewManager *viewManager(); |
102 | KODialogManager *dialogManager(); | 102 | KODialogManager *dialogManager(); |
103 | 103 | ||
104 | QDate startDate(); | 104 | QDate startDate(); |
105 | QDate endDate(); | 105 | QDate endDate(); |
106 | 106 | ||
107 | QWidgetStack *viewStack(); | 107 | QWidgetStack *viewStack(); |
108 | QWidget *leftFrame(); | 108 | QWidget *leftFrame(); |
109 | NavigatorBar *navigatorBar(); | 109 | NavigatorBar *navigatorBar(); |
110 | 110 | ||
111 | DateNavigator *dateNavigator(); | 111 | DateNavigator *dateNavigator(); |
112 | KDateNavigator *dateNavigatorWidget(); | 112 | KDateNavigator *dateNavigatorWidget(); |
113 | 113 | ||
114 | void addView(KOrg::BaseView *); | 114 | void addView(KOrg::BaseView *); |
115 | void showView(KOrg::BaseView *); | 115 | void showView(KOrg::BaseView *); |
116 | KOEventViewerDialog* getEventViewerDialog(); | 116 | KOEventViewerDialog* getEventViewerDialog(); |
117 | Incidence *currentSelection(); | 117 | Incidence *currentSelection(); |
118 | 118 | ||
119 | signals: | 119 | signals: |
120 | void tempDisableBR(bool); | 120 | void tempDisableBR(bool); |
121 | /** This todo has been modified */ | 121 | /** This todo has been modified */ |
122 | void todoModified(Todo *, int); | 122 | void todoModified(Todo *, int); |
123 | 123 | ||
124 | /** when change is made to options dialog, the topwidget will catch this | 124 | /** when change is made to options dialog, the topwidget will catch this |
125 | * and emit this signal which notifies all widgets which have registered | 125 | * and emit this signal which notifies all widgets which have registered |
126 | * for notification to update their settings. */ | 126 | * for notification to update their settings. */ |
127 | void configChanged(); | 127 | void configChanged(); |
128 | /** emitted when the topwidget is closing down, so that any attached | 128 | /** emitted when the topwidget is closing down, so that any attached |
129 | child windows can also close. */ | 129 | child windows can also close. */ |
130 | void closingDown(); | 130 | void closingDown(); |
131 | /** emitted right before we die */ | 131 | /** emitted right before we die */ |
132 | void closed(QWidget *); | 132 | void closed(QWidget *); |
133 | 133 | ||
134 | /** Emitted when state of modified flag changes */ | 134 | /** Emitted when state of modified flag changes */ |
135 | void modifiedChanged(bool); | 135 | void modifiedChanged(bool); |
136 | void signalmodified(); | 136 | void signalmodified(); |
137 | 137 | ||
138 | /** Emitted when state of read-only flag changes */ | 138 | /** Emitted when state of read-only flag changes */ |
139 | void readOnlyChanged(bool); | 139 | void readOnlyChanged(bool); |
140 | 140 | ||
141 | /** Emitted when the unit of navigation changes */ | 141 | /** Emitted when the unit of navigation changes */ |
142 | void changeNavStringPrev(const QString &); | 142 | void changeNavStringPrev(const QString &); |
143 | void changeNavStringNext(const QString &); | 143 | void changeNavStringNext(const QString &); |
144 | 144 | ||
145 | /** Emitted when state of events selection has changed and user is organizer*/ | 145 | /** Emitted when state of events selection has changed and user is organizer*/ |
146 | void organizerEventsSelected(bool); | 146 | void organizerEventsSelected(bool); |
147 | /** Emitted when state of events selection has changed and user is attendee*/ | 147 | /** Emitted when state of events selection has changed and user is attendee*/ |
148 | void groupEventsSelected(bool); | 148 | void groupEventsSelected(bool); |
149 | /** | 149 | /** |
150 | Emitted when an incidence gets selected. If the selection is cleared the | 150 | Emitted when an incidence gets selected. If the selection is cleared the |
151 | signal is emitted with 0 as argument. | 151 | signal is emitted with 0 as argument. |
152 | */ | 152 | */ |
153 | void incidenceSelected( Incidence * ); | 153 | void incidenceSelected( Incidence * ); |
154 | /** Emitted, when a todoitem is selected or deselected. */ | 154 | /** Emitted, when a todoitem is selected or deselected. */ |
155 | void todoSelected( bool ); | 155 | void todoSelected( bool ); |
156 | 156 | ||
157 | /** | 157 | /** |
158 | Emitted, when clipboard content changes. Parameter indicates if paste | 158 | Emitted, when clipboard content changes. Parameter indicates if paste |
159 | is possible or not. | 159 | is possible or not. |
160 | */ | 160 | */ |
161 | void pasteEnabled(bool); | 161 | void pasteEnabled(bool); |
162 | 162 | ||
163 | /** Emitted, when the number of incoming messages has changed. */ | 163 | /** Emitted, when the number of incoming messages has changed. */ |
164 | void numIncomingChanged(int); | 164 | void numIncomingChanged(int); |
165 | 165 | ||
166 | /** Emitted, when the number of outgoing messages has changed. */ | 166 | /** Emitted, when the number of outgoing messages has changed. */ |
167 | void numOutgoingChanged(int); | 167 | void numOutgoingChanged(int); |
168 | 168 | ||
169 | /** Send status message, which can e.g. be displayed in the status bar. */ | 169 | /** Send status message, which can e.g. be displayed in the status bar. */ |
170 | void statusMessage(const QString &); | 170 | void statusMessage(const QString &); |
171 | 171 | ||
172 | void calendarViewExpanded( bool ); | 172 | void calendarViewExpanded( bool ); |
173 | void updateSearchDialog(); | 173 | void updateSearchDialog(); |
174 | 174 | ||
175 | 175 | ||
176 | public slots: | 176 | public slots: |
177 | void showOpenError(); | 177 | void showOpenError(); |
178 | void watchSavedFile(); | 178 | void watchSavedFile(); |
179 | void recheckTimerAlarm(); | 179 | void recheckTimerAlarm(); |
180 | void checkNextTimerAlarm(); | 180 | void checkNextTimerAlarm(); |
181 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 181 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
182 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); | 182 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); |
183 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 183 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
184 | 184 | ||
185 | /** options dialog made a changed to the configuration. we catch this | 185 | /** options dialog made a changed to the configuration. we catch this |
186 | * and notify all widgets which need to update their configuration. */ | 186 | * and notify all widgets which need to update their configuration. */ |
187 | void updateConfig(); | 187 | void updateConfig(); |
188 | 188 | ||
189 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, | 189 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, |
190 | const QStringList& anniversaryList, const QStringList& realNameList, | 190 | const QStringList& anniversaryList, const QStringList& realNameList, |
191 | const QStringList& emailList, const QStringList& assembledNameList, | 191 | const QStringList& emailList, const QStringList& assembledNameList, |
192 | const QStringList& uidList); | 192 | const QStringList& uidList); |
193 | 193 | ||
194 | /** | 194 | /** |
195 | Load calendar from file \a filename. If \a merge is true, load | 195 | Load calendar from file \a filename. If \a merge is true, load |
196 | calendar into existing one, if it is false, clear calendar, before | 196 | calendar into existing one, if it is false, clear calendar, before |
197 | loading. Return true, if calendar could be successfully loaded. | 197 | loading. Return true, if calendar could be successfully loaded. |
198 | */ | 198 | */ |
199 | bool openCalendar(QString filename, bool merge=false); | 199 | bool openCalendar(QString filename, bool merge=false); |
200 | bool syncCalendar(QString filename,int mode = 0 ); | 200 | bool syncCalendar(QString filename,int mode = 0 ); |
201 | 201 | ||
202 | /** | 202 | /** |
203 | Save calendar data to file. Return true if calendar could be | 203 | Save calendar data to file. Return true if calendar could be |
204 | successfully saved. | 204 | successfully saved. |
205 | */ | 205 | */ |
206 | bool saveCalendar(QString filename); | 206 | bool saveCalendar(QString filename); |
207 | 207 | ||
208 | /** | 208 | /** |
209 | Close calendar. Clear calendar data and reset views to display an empty | 209 | Close calendar. Clear calendar data and reset views to display an empty |
210 | calendar. | 210 | calendar. |
211 | */ | 211 | */ |
212 | void closeCalendar(); | 212 | void closeCalendar(); |
213 | 213 | ||
214 | /** Archive old events of calendar */ | 214 | /** Archive old events of calendar */ |
215 | void archiveCalendar(); | 215 | void archiveCalendar(); |
216 | 216 | ||
217 | void showIncidence(); | 217 | void showIncidence(); |
218 | void editIncidence(); | 218 | void editIncidence(); |
219 | void editIncidenceDescription(); | 219 | void editIncidenceDescription(); |
220 | void deleteIncidence(); | 220 | void deleteIncidence(); |
221 | void cloneIncidence(); | 221 | void cloneIncidence(); |
222 | void moveIncidence(); | 222 | void moveIncidence(); |
223 | void beamIncidence(); | 223 | void beamIncidence(); |
224 | void toggleCancelIncidence(); | 224 | void toggleCancelIncidence(); |
225 | 225 | ||
226 | /** create an editeventwin with supplied date/time, and if bool is true, | 226 | /** create an editeventwin with supplied date/time, and if bool is true, |
227 | * make the event take all day. */ | 227 | * make the event take all day. */ |
228 | void newEvent(QDateTime, QDateTime, bool allDay = false); | 228 | void newEvent(QDateTime, QDateTime, bool allDay = false); |
229 | void newEvent(QDateTime fh); | 229 | void newEvent(QDateTime fh); |
230 | void newEvent(QDate dt); | 230 | void newEvent(QDate dt); |
231 | /** create new event without having a date hint. Takes current date as | 231 | /** create new event without having a date hint. Takes current date as |
232 | default hint. */ | 232 | default hint. */ |
233 | void newEvent(); | 233 | void newEvent(); |
234 | void newFloatingEvent(); | 234 | void newFloatingEvent(); |
235 | 235 | ||
236 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ | 236 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ |
237 | void showIncidence(Incidence *); | 237 | void showIncidence(Incidence *); |
238 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ | 238 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ |
239 | void editIncidence(Incidence *); | 239 | void editIncidence(Incidence *); |
240 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ | 240 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ |
241 | void deleteIncidence(Incidence *); | 241 | void deleteIncidence(Incidence *); |
242 | void cloneIncidence(Incidence *); | 242 | void cloneIncidence(Incidence *); |
243 | void cancelIncidence(Incidence *); | 243 | void cancelIncidence(Incidence *); |
244 | /** Create an editor for the supplied event. */ | 244 | /** Create an editor for the supplied event. */ |
245 | void editEvent(Event *); | 245 | void editEvent(Event *); |
246 | /** Delete the supplied event. */ | 246 | /** Delete the supplied event. */ |
247 | void deleteEvent(Event *); | 247 | void deleteEvent(Event *); |
248 | /** Delete the event with the given unique ID. Returns false, if event wasn't | 248 | /** Delete the event with the given unique ID. Returns false, if event wasn't |
249 | found. */ | 249 | found. */ |
250 | bool deleteEvent(const QString &uid); | 250 | bool deleteEvent(const QString &uid); |
251 | /** Create a read-only viewer dialog for the supplied event. */ | 251 | /** Create a read-only viewer dialog for the supplied event. */ |
252 | void showEvent(Event *); | 252 | void showEvent(Event *); |
253 | 253 | ||
254 | void editJournal(Journal *); | 254 | void editJournal(Journal *); |
255 | void showJournal(Journal *); | 255 | void showJournal(Journal *); |
256 | void deleteJournal(Journal *); | 256 | void deleteJournal(Journal *); |
257 | /** Create an editor dialog for a todo */ | 257 | /** Create an editor dialog for a todo */ |
258 | void editTodo(Todo *); | 258 | void editTodo(Todo *); |
259 | /** Create a read-only viewer dialog for the supplied todo */ | 259 | /** Create a read-only viewer dialog for the supplied todo */ |
260 | void showTodo(Todo *); | 260 | void showTodo(Todo *); |
261 | /** create new todo */ | 261 | /** create new todo */ |
262 | void newTodo(); | 262 | void newTodo(); |
263 | /** create new todo with a parent todo */ | 263 | /** create new todo with a parent todo */ |
264 | void newSubTodo(); | 264 | void newSubTodo(); |
265 | /** create new todo with a parent todo */ | 265 | /** create new todo with a parent todo */ |
266 | void newSubTodo(Todo *); | 266 | void newSubTodo(Todo *); |
267 | /** Delete todo */ | 267 | /** Delete todo */ |
268 | void deleteTodo(Todo *); | 268 | void deleteTodo(Todo *); |
269 | 269 | ||
270 | 270 | ||
271 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is | 271 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is |
272 | * emitted as result. */ | 272 | * emitted as result. */ |
273 | void checkClipboard(); | 273 | void checkClipboard(); |
274 | 274 | ||
275 | /** using the KConfig associated with the kapp variable, read in the | 275 | /** using the KConfig associated with the kapp variable, read in the |
276 | * settings from the config file. | 276 | * settings from the config file. |
277 | */ | 277 | */ |
278 | void readSettings(); | 278 | void readSettings(); |
279 | 279 | ||
280 | /** write current state to config file. */ | 280 | /** write current state to config file. */ |
281 | void writeSettings(); | 281 | void writeSettings(); |
282 | 282 | ||
283 | /** read settings for calendar filters */ | 283 | /** read settings for calendar filters */ |
284 | void readFilterSettings(KConfig *config); | 284 | void readFilterSettings(KConfig *config); |
285 | 285 | ||
286 | /** write settings for calendar filters */ | 286 | /** write settings for calendar filters */ |
287 | void writeFilterSettings(KConfig *config); | 287 | void writeFilterSettings(KConfig *config); |
288 | 288 | ||
289 | /** passes on the message that an event has changed to the currently | 289 | /** passes on the message that an event has changed to the currently |
290 | * activated view so that it can make appropriate display changes. */ | 290 | * activated view so that it can make appropriate display changes. */ |
291 | void changeEventDisplay(Event *, int); | 291 | void changeEventDisplay(Event *, int); |
292 | void changeIncidenceDisplay(Incidence *, int); | 292 | void changeIncidenceDisplay(Incidence *, int); |
293 | void changeTodoDisplay(Todo *, int); | 293 | void changeTodoDisplay(Todo *, int); |
294 | 294 | ||
295 | void eventAdded(Event *); | 295 | void eventAdded(Event *); |
296 | void eventChanged(Event *); | 296 | void eventChanged(Event *); |
297 | void eventToBeDeleted(Event *); | 297 | void eventToBeDeleted(Event *); |
298 | void eventDeleted(); | 298 | void eventDeleted(); |
299 | 299 | ||
300 | void todoAdded(Todo *); | 300 | void todoAdded(Todo *); |
301 | void todoChanged(Todo *); | 301 | void todoChanged(Todo *); |
302 | void todoToBeDeleted(Todo *); | 302 | void todoToBeDeleted(Todo *); |
303 | void todoDeleted(); | 303 | void todoDeleted(); |
304 | 304 | ||
305 | void updateView(const QDate &start, const QDate &end); | 305 | void updateView(const QDate &start, const QDate &end); |
306 | void updateView(); | 306 | void updateView(); |
307 | 307 | ||
308 | /** Full update of visible todo views */ | 308 | /** Full update of visible todo views */ |
309 | void updateTodoViews(); | 309 | void updateTodoViews(); |
310 | 310 | ||
311 | void updateUnmanagedViews(); | 311 | void updateUnmanagedViews(); |
312 | 312 | ||
313 | /** cut the current appointment to the clipboard */ | 313 | /** cut the current appointment to the clipboard */ |
314 | void edit_cut(); | 314 | void edit_cut(); |
315 | 315 | ||
316 | /** copy the current appointment(s) to the clipboard */ | 316 | /** copy the current appointment(s) to the clipboard */ |
317 | void edit_copy(); | 317 | void edit_copy(); |
318 | 318 | ||
319 | /** paste the current vobject(s) in the clipboard buffer into calendar */ | 319 | /** paste the current vobject(s) in the clipboard buffer into calendar */ |
320 | void edit_paste(); | 320 | void edit_paste(); |
321 | 321 | ||
322 | /** edit viewing and configuration options. */ | 322 | /** edit viewing and configuration options. */ |
323 | void edit_options(); | 323 | void edit_options(); |
324 | /** | 324 | /** |
325 | Functions for printing, previewing a print, and setting up printing | 325 | Functions for printing, previewing a print, and setting up printing |
326 | parameters. | 326 | parameters. |
327 | */ | 327 | */ |
328 | void print(); | 328 | void print(); |
329 | void printSetup(); | 329 | void printSetup(); |
330 | void printPreview(); | 330 | void printPreview(); |
331 | 331 | ||
332 | /** Export as iCalendar file */ | 332 | /** Export as iCalendar file */ |
333 | void exportICalendar(); | 333 | void exportICalendar(); |
334 | 334 | ||
335 | /** Export as vCalendar file */ | 335 | /** Export as vCalendar file */ |
336 | bool exportVCalendar( QString fn); | 336 | bool exportVCalendar( QString fn); |
337 | 337 | ||
338 | /** pop up a dialog to show an existing appointment. */ | 338 | /** pop up a dialog to show an existing appointment. */ |
339 | void appointment_show(); | 339 | void appointment_show(); |
340 | /** | 340 | /** |
341 | * pop up an Appointment Dialog to edit an existing appointment.Get | 341 | * pop up an Appointment Dialog to edit an existing appointment.Get |
342 | * information on the appointment from the list of unique IDs that is | 342 | * information on the appointment from the list of unique IDs that is |
343 | * currently in the View, called currIds. | 343 | * currently in the View, called currIds. |
344 | */ | 344 | */ |
345 | void appointment_edit(); | 345 | void appointment_edit(); |
346 | /** | 346 | /** |
347 | * pop up dialog confirming deletion of currently selected event in the | 347 | * pop up dialog confirming deletion of currently selected event in the |
348 | * View. | 348 | * View. |
349 | */ | 349 | */ |
350 | void appointment_delete(); | 350 | void appointment_delete(); |
351 | 351 | ||
352 | /** mails the currently selected event to a particular user as a vCalendar | 352 | /** mails the currently selected event to a particular user as a vCalendar |
353 | attachment. */ | 353 | attachment. */ |
354 | void action_mail(); | 354 | void action_mail(); |
355 | 355 | ||
356 | /* frees a subtodo from it's relation */ | 356 | /* frees a subtodo from it's relation */ |
357 | void todo_unsub( Todo * ); | 357 | void todo_unsub( Todo * ); |
358 | void todo_resub( Todo * parent, Todo * sub ); | 358 | void todo_resub( Todo * parent, Todo * sub ); |
359 | 359 | ||
360 | /** Take ownership of selected event. */ | 360 | /** Take ownership of selected event. */ |
361 | void takeOverEvent(); | 361 | void takeOverEvent(); |
362 | 362 | ||
363 | /** Take ownership of all events in calendar. */ | 363 | /** Take ownership of all events in calendar. */ |
364 | void takeOverCalendar(); | 364 | void takeOverCalendar(); |
365 | 365 | ||
366 | /** query whether or not the calendar is "dirty". */ | 366 | /** query whether or not the calendar is "dirty". */ |
367 | bool isModified(); | 367 | bool isModified(); |
368 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ | 368 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ |
369 | void setModified(bool modified=true); | 369 | void setModified(bool modified=true); |
370 | 370 | ||
371 | /** query if the calendar is read-only. */ | 371 | /** query if the calendar is read-only. */ |
372 | bool isReadOnly(); | 372 | bool isReadOnly(); |
373 | /** set state of calendar to read-only */ | 373 | /** set state of calendar to read-only */ |
374 | void setReadOnly(bool readOnly=true); | 374 | void setReadOnly(bool readOnly=true); |
375 | 375 | ||
376 | void eventUpdated(Incidence *); | 376 | void eventUpdated(Incidence *); |
377 | 377 | ||
378 | /* iTIP scheduling actions */ | 378 | /* iTIP scheduling actions */ |
379 | void schedule_publish(Incidence *incidence = 0); | 379 | void schedule_publish(Incidence *incidence = 0); |
380 | void schedule_request(Incidence *incidence = 0); | 380 | void schedule_request(Incidence *incidence = 0); |
381 | void schedule_refresh(Incidence *incidence = 0); | 381 | void schedule_refresh(Incidence *incidence = 0); |
382 | void schedule_cancel(Incidence *incidence = 0); | 382 | void schedule_cancel(Incidence *incidence = 0); |
383 | void schedule_add(Incidence *incidence = 0); | 383 | void schedule_add(Incidence *incidence = 0); |
384 | void schedule_reply(Incidence *incidence = 0); | 384 | void schedule_reply(Incidence *incidence = 0); |
385 | void schedule_counter(Incidence *incidence = 0); | 385 | void schedule_counter(Incidence *incidence = 0); |
386 | void schedule_declinecounter(Incidence *incidence = 0); | 386 | void schedule_declinecounter(Incidence *incidence = 0); |
387 | void schedule_publish_freebusy(int daysToPublish = 30); | 387 | void schedule_publish_freebusy(int daysToPublish = 30); |
388 | 388 | ||
389 | void openAddressbook(); | 389 | void openAddressbook(); |
390 | 390 | ||
391 | void editFilters(); | 391 | void editFilters(); |
392 | void toggleFilerEnabled(); | 392 | void toggleFilerEnabled(); |
393 | QPtrList<CalFilter> filters(); | 393 | QPtrList<CalFilter> filters(); |
394 | void toggleFilter(); | 394 | void toggleFilter(); |
395 | void showFilter(bool visible); | 395 | void showFilter(bool visible); |
396 | void updateFilter(); | 396 | void updateFilter(); |
397 | void filterEdited(); | 397 | void filterEdited(); |
398 | void selectFilter( int ); | 398 | void selectFilter( int ); |
399 | KOFilterView *filterView(); | 399 | KOFilterView *filterView(); |
400 | 400 | ||
401 | void showIntro(); | 401 | void showIntro(); |
402 | 402 | ||
403 | /** Move the curdatepient view date to today */ | 403 | /** Move the curdatepient view date to today */ |
404 | void goToday(); | 404 | void goToday(); |
405 | 405 | ||
406 | /** Move to the next date(s) in the current view */ | 406 | /** Move to the next date(s) in the current view */ |
407 | void goNext(); | 407 | void goNext(); |
408 | 408 | ||
409 | /** Move to the previous date(s) in the current view */ | 409 | /** Move to the previous date(s) in the current view */ |
410 | void goPrevious(); | 410 | void goPrevious(); |
411 | /** Move to the next date(s) in the current view */ | 411 | /** Move to the next date(s) in the current view */ |
412 | void goNextMonth(); | 412 | void goNextMonth(); |
413 | 413 | ||
414 | /** Move to the previous date(s) in the current view */ | 414 | /** Move to the previous date(s) in the current view */ |
415 | void goPreviousMonth(); | 415 | void goPreviousMonth(); |
416 | 416 | ||
417 | void toggleExpand(); | 417 | void toggleExpand(); |
418 | void toggleDateNavigatorWidget(); | 418 | void toggleDateNavigatorWidget(); |
419 | void toggleAllDaySize(); | 419 | void toggleAllDaySize(); |
420 | void dialogClosing(Incidence *); | 420 | void dialogClosing(Incidence *); |
421 | 421 | ||
422 | /** Look for new messages in the inbox */ | 422 | /** Look for new messages in the inbox */ |
423 | void lookForIncomingMessages(); | 423 | void lookForIncomingMessages(); |
424 | /** Look for new messages in the outbox */ | 424 | /** Look for new messages in the outbox */ |
425 | void lookForOutgoingMessages(); | 425 | void lookForOutgoingMessages(); |
426 | 426 | ||
427 | void processMainViewSelection( Incidence * ); | 427 | void processMainViewSelection( Incidence * ); |
428 | void processTodoListSelection( Incidence * ); | 428 | void processTodoListSelection( Incidence * ); |
429 | 429 | ||
430 | void processIncidenceSelection( Incidence * ); | 430 | void processIncidenceSelection( Incidence * ); |
431 | 431 | ||
432 | void purgeCompleted(); | 432 | void purgeCompleted(); |
433 | bool removeCompletedSubTodos( Todo* ); | 433 | bool removeCompletedSubTodos( Todo* ); |
434 | void slotCalendarChanged(); | 434 | void slotCalendarChanged(); |
435 | bool importBday(); | 435 | bool importBday(); |
436 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); | 436 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); |
437 | bool importQtopia( const QString &categoriesFile, | 437 | bool importQtopia( const QString &categoriesFile, |
438 | const QString &datebookFile, | 438 | const QString &datebookFile, |
439 | const QString &tasklistFile ); | 439 | const QString &tasklistFile ); |
440 | void syncExternal( int mode ); | 440 | void syncExternal( int mode ); |
441 | void slotSelectPickerDate( QDate ) ; | 441 | void slotSelectPickerDate( QDate ) ; |
442 | void showDatePicker( ) ; | 442 | void showDatePicker( ) ; |
443 | void moveIncidence(Incidence *) ; | 443 | void moveIncidence(Incidence *) ; |
444 | void beamIncidence(Incidence *) ; | 444 | void beamIncidence(Incidence *) ; |
445 | void beamCalendar() ; | 445 | void beamCalendar() ; |
446 | void beamFilteredCalendar() ; | 446 | void beamFilteredCalendar() ; |
447 | void beamIncidenceList(QPtrList<Incidence>) ; | 447 | void beamIncidenceList(QPtrList<Incidence>) ; |
448 | void manageCategories(); | 448 | void manageCategories(); |
449 | int addCategories(); | 449 | int addCategories(); |
450 | void removeCategories(); | 450 | void removeCategories(); |
451 | void setSyncDevice( QString ); | 451 | void setSyncDevice( QString ); |
452 | void setSyncName( QString ); | 452 | void setSyncName( QString ); |
453 | protected slots: | 453 | protected slots: |
454 | void timerAlarm(); | 454 | void timerAlarm(); |
455 | void suspendAlarm(); | 455 | void suspendAlarm(); |
456 | void beamDone( Ir *ir ); | 456 | void beamDone( Ir *ir ); |
457 | /** Select a view or adapt the current view to display the specified dates. */ | 457 | /** Select a view or adapt the current view to display the specified dates. */ |
458 | void showDates( const KCal::DateList & ); | 458 | void showDates( const KCal::DateList & ); |
459 | void selectWeekNum ( int ); | 459 | void selectWeekNum ( int ); |
460 | 460 | ||
461 | public: | 461 | public: |
462 | // show a standard warning | 462 | // show a standard warning |
463 | // returns KMsgBox::yesNoCancel() | 463 | // returns KMsgBox::yesNoCancel() |
464 | int msgCalModified(); | 464 | int msgCalModified(); |
465 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 465 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
466 | 466 | ||
467 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 467 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
468 | virtual void removeSyncInfo( QString syncProfile); | ||
468 | void setSyncManager(KSyncManager* manager); | 469 | void setSyncManager(KSyncManager* manager); |
469 | void setLoadedFileVersion(QDateTime); | 470 | void setLoadedFileVersion(QDateTime); |
470 | bool checkFileVersion(QString fn); | 471 | bool checkFileVersion(QString fn); |
471 | bool checkFileChanged(QString fn); | 472 | bool checkFileChanged(QString fn); |
472 | Event* getLastSyncEvent(); | 473 | Event* getLastSyncEvent(); |
473 | /** Adapt navigation units correpsonding to step size of navigation of the | 474 | /** Adapt navigation units correpsonding to step size of navigation of the |
474 | * current view. | 475 | * current view. |
475 | */ | 476 | */ |
476 | void adaptNavigationUnits(); | 477 | void adaptNavigationUnits(); |
477 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); | 478 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); |
478 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); | 479 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); |
479 | //Attendee* getYourAttendee(Event *event); | 480 | //Attendee* getYourAttendee(Event *event); |
480 | protected: | 481 | protected: |
481 | void schedule(Scheduler::Method, Incidence *incidence = 0); | 482 | void schedule(Scheduler::Method, Incidence *incidence = 0); |
482 | 483 | ||
483 | // returns KMsgBox::OKCandel() | 484 | // returns KMsgBox::OKCandel() |
484 | int msgItemDelete(); | 485 | int msgItemDelete(); |
485 | void showEventEditor(); | 486 | void showEventEditor(); |
486 | void showTodoEditor(); | 487 | void showTodoEditor(); |
487 | void writeLocale(); | 488 | void writeLocale(); |
488 | Todo *selectedTodo(); | 489 | Todo *selectedTodo(); |
489 | 490 | ||
490 | private: | 491 | private: |
491 | bool mSyncKDE; | 492 | bool mSyncKDE; |
492 | KSyncManager* mSyncManager; | 493 | KSyncManager* mSyncManager; |
493 | AlarmDialog * mAlarmDialog; | 494 | AlarmDialog * mAlarmDialog; |
494 | QString mAlarmNotification; | 495 | QString mAlarmNotification; |
495 | QString mSuspendAlarmNotification; | 496 | QString mSuspendAlarmNotification; |
496 | QTimer* mSuspendTimer; | 497 | QTimer* mSuspendTimer; |
497 | QTimer* mAlarmTimer; | 498 | QTimer* mAlarmTimer; |
498 | QTimer* mRecheckAlarmTimer; | 499 | QTimer* mRecheckAlarmTimer; |
499 | void computeAlarm( QString ); | 500 | void computeAlarm( QString ); |
500 | void startAlarm( QString, QString ); | 501 | void startAlarm( QString, QString ); |
501 | void setSyncEventsReadOnly(); | 502 | void setSyncEventsReadOnly(); |
502 | 503 | ||
503 | QDateTime loadedFileVersion; | 504 | QDateTime loadedFileVersion; |
504 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); | 505 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); |
505 | void checkExternalId( Incidence * inc ); | 506 | void checkExternalId( Incidence * inc ); |
506 | int mGlobalSyncMode; | 507 | int mGlobalSyncMode; |
507 | QString mCurrentSyncDevice; | 508 | QString mCurrentSyncDevice; |
508 | QString mCurrentSyncName; | 509 | QString mCurrentSyncName; |
509 | KOBeamPrefs* beamDialog; | 510 | KOBeamPrefs* beamDialog; |
510 | void init(); | 511 | void init(); |
511 | int mDatePickerMode; | 512 | int mDatePickerMode; |
512 | bool mFlagEditDescription; | 513 | bool mFlagEditDescription; |
513 | QDateTime mLastCalendarSync; | 514 | QDateTime mLastCalendarSync; |
514 | void createPrinter(); | 515 | void createPrinter(); |
515 | 516 | ||
516 | void calendarModified( bool, Calendar * ); | 517 | void calendarModified( bool, Calendar * ); |
517 | 518 | ||
518 | CalPrinter *mCalPrinter; | 519 | CalPrinter *mCalPrinter; |
519 | 520 | ||
520 | QSplitter *mPanner; | 521 | QSplitter *mPanner; |
521 | QSplitter *mLeftSplitter; | 522 | QSplitter *mLeftSplitter; |
522 | QWidget *mLeftFrame; | 523 | QWidget *mLeftFrame; |
523 | QWidgetStack *mRightFrame; | 524 | QWidgetStack *mRightFrame; |
524 | 525 | ||
525 | KDatePicker* mDatePicker; | 526 | KDatePicker* mDatePicker; |
526 | QVBox* mDateFrame; | 527 | QVBox* mDateFrame; |
527 | NavigatorBar *mNavigatorBar; | 528 | NavigatorBar *mNavigatorBar; |
528 | 529 | ||
529 | KDateNavigator *mDateNavigator; // widget showing small month view. | 530 | KDateNavigator *mDateNavigator; // widget showing small month view. |
530 | 531 | ||
531 | KOFilterView *mFilterView; | 532 | KOFilterView *mFilterView; |
532 | 533 | ||
533 | ResourceView *mResourceView; | 534 | ResourceView *mResourceView; |
534 | 535 | ||
535 | // calendar object for this viewing instance | 536 | // calendar object for this viewing instance |
536 | Calendar *mCalendar; | 537 | Calendar *mCalendar; |
537 | 538 | ||
538 | CalendarResourceManager *mResourceManager; | 539 | CalendarResourceManager *mResourceManager; |
539 | 540 | ||
540 | FileStorage *mStorage; | 541 | FileStorage *mStorage; |
541 | 542 | ||
542 | DateNavigator *mNavigator; | 543 | DateNavigator *mNavigator; |
543 | 544 | ||
544 | KOViewManager *mViewManager; | 545 | KOViewManager *mViewManager; |
545 | KODialogManager *mDialogManager; | 546 | KODialogManager *mDialogManager; |
546 | 547 | ||
547 | // Calendar filters | 548 | // Calendar filters |
548 | QPtrList<CalFilter> mFilters; | 549 | QPtrList<CalFilter> mFilters; |
549 | 550 | ||
550 | // various housekeeping variables. | 551 | // various housekeeping variables. |
551 | bool mModified; // flag indicating if calendar is modified | 552 | bool mModified; // flag indicating if calendar is modified |
552 | bool mReadOnly; // flag indicating if calendar is read-only | 553 | bool mReadOnly; // flag indicating if calendar is read-only |
553 | QDate mSaveSingleDate; | 554 | QDate mSaveSingleDate; |
554 | 555 | ||
555 | Incidence *mSelectedIncidence; | 556 | Incidence *mSelectedIncidence; |
556 | Incidence *mMoveIncidence; | 557 | Incidence *mMoveIncidence; |
557 | KOTodoView *mTodoList; | 558 | KOTodoView *mTodoList; |
558 | KOEventEditor * mEventEditor; | 559 | KOEventEditor * mEventEditor; |
559 | KOTodoEditor * mTodoEditor; | 560 | KOTodoEditor * mTodoEditor; |
560 | KOEventViewerDialog * mEventViewerDialog; | 561 | KOEventViewerDialog * mEventViewerDialog; |
561 | void keyPressEvent ( QKeyEvent *e) ; | 562 | void keyPressEvent ( QKeyEvent *e) ; |
562 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; | 563 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; |
563 | }; | 564 | }; |
564 | 565 | ||
565 | 566 | ||
566 | class CalendarViewVisitor : public Incidence::Visitor | 567 | class CalendarViewVisitor : public Incidence::Visitor |
567 | { | 568 | { |
568 | public: | 569 | public: |
569 | CalendarViewVisitor() : mView( 0 ) {} | 570 | CalendarViewVisitor() : mView( 0 ) {} |
570 | 571 | ||
571 | bool act( Incidence *incidence, CalendarView *view ) | 572 | bool act( Incidence *incidence, CalendarView *view ) |
572 | { | 573 | { |
573 | mView = view; | 574 | mView = view; |
574 | return incidence->accept( *this ); | 575 | return incidence->accept( *this ); |
575 | } | 576 | } |
576 | 577 | ||
577 | protected: | 578 | protected: |
578 | CalendarView *mView; | 579 | CalendarView *mView; |
579 | }; | 580 | }; |
580 | 581 | ||
581 | class ShowIncidenceVisitor : public CalendarViewVisitor | 582 | class ShowIncidenceVisitor : public CalendarViewVisitor |
582 | { | 583 | { |
583 | protected: | 584 | protected: |
584 | bool visit( Event *event ) { mView->showEvent( event ); return true; } | 585 | bool visit( Event *event ) { mView->showEvent( event ); return true; } |
585 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } | 586 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } |
586 | bool visit( Journal * j ) { mView->showJournal( j );return true; } | 587 | bool visit( Journal * j ) { mView->showJournal( j );return true; } |
587 | }; | 588 | }; |
588 | 589 | ||
589 | class EditIncidenceVisitor : public CalendarViewVisitor | 590 | class EditIncidenceVisitor : public CalendarViewVisitor |
590 | { | 591 | { |
591 | protected: | 592 | protected: |
592 | bool visit( Event *event ) { mView->editEvent( event ); return true; } | 593 | bool visit( Event *event ) { mView->editEvent( event ); return true; } |
593 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } | 594 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } |
594 | bool visit( Journal *j ) { mView->editJournal( j); return true; } | 595 | bool visit( Journal *j ) { mView->editJournal( j); return true; } |
595 | }; | 596 | }; |
596 | 597 | ||
597 | class DeleteIncidenceVisitor : public CalendarViewVisitor | 598 | class DeleteIncidenceVisitor : public CalendarViewVisitor |
598 | { | 599 | { |
599 | protected: | 600 | protected: |
600 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } | 601 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } |
601 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } | 602 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } |
602 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } | 603 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } |
603 | }; | 604 | }; |
604 | 605 | ||
605 | #endif | 606 | #endif |
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index 4a610fa..af4f1ab 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h | |||
@@ -1,211 +1,212 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KDE-Pim/Pi. | 2 | This file is part of KDE-Pim/Pi. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | $Id$ | 20 | $Id$ |
21 | */ | 21 | */ |
22 | #ifndef _KSYNCMANAGER_H | 22 | #ifndef _KSYNCMANAGER_H |
23 | #define _KSYNCMANAGER_H | 23 | #define _KSYNCMANAGER_H |
24 | 24 | ||
25 | #include <qobject.h> | 25 | #include <qobject.h> |
26 | #include <qstring.h> | 26 | #include <qstring.h> |
27 | #include <qsocket.h> | 27 | #include <qsocket.h> |
28 | #include <qdatetime.h> | 28 | #include <qdatetime.h> |
29 | #include <qserversocket.h> | 29 | #include <qserversocket.h> |
30 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | 32 | ||
33 | class QPopupMenu; | 33 | class QPopupMenu; |
34 | class KSyncProfile; | 34 | class KSyncProfile; |
35 | class KPimPrefs; | 35 | class KPimPrefs; |
36 | class QWidget; | 36 | class QWidget; |
37 | class KSyncManager; | 37 | class KSyncManager; |
38 | class KSyncInterface; | 38 | class KSyncInterface; |
39 | class QProgressBar; | 39 | class QProgressBar; |
40 | 40 | ||
41 | 41 | ||
42 | class KServerSocket : public QServerSocket | 42 | class KServerSocket : public QServerSocket |
43 | { | 43 | { |
44 | Q_OBJECT | 44 | Q_OBJECT |
45 | 45 | ||
46 | public: | 46 | public: |
47 | KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); | 47 | KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); |
48 | 48 | ||
49 | void newConnection ( int socket ) ; | 49 | void newConnection ( int socket ) ; |
50 | void setFileName( QString fn ) {mFileName = fn;}; | 50 | void setFileName( QString fn ) {mFileName = fn;}; |
51 | signals: | 51 | signals: |
52 | void file_received( bool ); | 52 | void file_received( bool ); |
53 | void request_file(); | 53 | void request_file(); |
54 | void saveFile(); | 54 | void saveFile(); |
55 | void endConnect(); | 55 | void endConnect(); |
56 | private slots: | 56 | private slots: |
57 | void discardClient(); | 57 | void discardClient(); |
58 | void readClient(); | 58 | void readClient(); |
59 | void readBackFileFromSocket(); | 59 | void readBackFileFromSocket(); |
60 | private : | 60 | private : |
61 | bool blockRC; | 61 | bool blockRC; |
62 | void send_file(); | 62 | void send_file(); |
63 | void get_file(); | 63 | void get_file(); |
64 | void end_connect(); | 64 | void end_connect(); |
65 | QDialog* mSyncActionDialog; | 65 | QDialog* mSyncActionDialog; |
66 | QSocket* mSocket; | 66 | QSocket* mSocket; |
67 | QString mPassWord; | 67 | QString mPassWord; |
68 | QString mFileName; | 68 | QString mFileName; |
69 | QTime piTime; | 69 | QTime piTime; |
70 | QString piFileString; | 70 | QString piFileString; |
71 | }; | 71 | }; |
72 | 72 | ||
73 | class KCommandSocket : public QObject | 73 | class KCommandSocket : public QObject |
74 | { | 74 | { |
75 | Q_OBJECT | 75 | Q_OBJECT |
76 | public: | 76 | public: |
77 | enum state { successR, errorR, successW, errorW, errorTO, quiet }; | 77 | enum state { successR, errorR, successW, errorW, errorTO, quiet }; |
78 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); | 78 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); |
79 | void readFile( QString ); | 79 | void readFile( QString ); |
80 | void writeFile( QString ); | 80 | void writeFile( QString ); |
81 | void sendStop(); | 81 | void sendStop(); |
82 | 82 | ||
83 | signals: | 83 | signals: |
84 | void commandFinished( KCommandSocket*, int ); | 84 | void commandFinished( KCommandSocket*, int ); |
85 | private slots: | 85 | private slots: |
86 | void startReadFileFromSocket(); | 86 | void startReadFileFromSocket(); |
87 | void readFileFromSocket(); | 87 | void readFileFromSocket(); |
88 | void deleteSocket(); | 88 | void deleteSocket(); |
89 | void writeFileToSocket(); | 89 | void writeFileToSocket(); |
90 | private : | 90 | private : |
91 | QSocket* mSocket; | 91 | QSocket* mSocket; |
92 | QString mPassWord; | 92 | QString mPassWord; |
93 | Q_UINT16 mPort; | 93 | Q_UINT16 mPort; |
94 | QString mHost; | 94 | QString mHost; |
95 | QString mFileName; | 95 | QString mFileName; |
96 | QTimer* mTimerSocket; | 96 | QTimer* mTimerSocket; |
97 | int mRetVal; | 97 | int mRetVal; |
98 | QTime mTime; | 98 | QTime mTime; |
99 | QString mFileString; | 99 | QString mFileString; |
100 | bool mFirst; | 100 | bool mFirst; |
101 | }; | 101 | }; |
102 | 102 | ||
103 | 103 | ||
104 | class KSyncManager : public QObject | 104 | class KSyncManager : public QObject |
105 | { | 105 | { |
106 | Q_OBJECT | 106 | Q_OBJECT |
107 | 107 | ||
108 | public: | 108 | public: |
109 | enum TargetApp { | 109 | enum TargetApp { |
110 | KOPI = 0, | 110 | KOPI = 0, |
111 | KAPI = 1, | 111 | KAPI = 1, |
112 | PWMPI = 2 }; | 112 | PWMPI = 2 }; |
113 | 113 | ||
114 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); | 114 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); |
115 | ~KSyncManager() ; | 115 | ~KSyncManager() ; |
116 | 116 | ||
117 | void multiSync( bool askforPrefs ); | 117 | void multiSync( bool askforPrefs ); |
118 | bool blockSave() { return mBlockSaveFlag; } | 118 | bool blockSave() { return mBlockSaveFlag; } |
119 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } | 119 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } |
120 | void setDefaultFileName( QString s) { mDefFileName = s ;} | 120 | void setDefaultFileName( QString s) { mDefFileName = s ;} |
121 | QString defaultFileName() { return mDefFileName ;} | 121 | QString defaultFileName() { return mDefFileName ;} |
122 | QString syncFileName(); | 122 | QString syncFileName(); |
123 | void enableQuick( bool ask = true); | 123 | void enableQuick( bool ask = true); |
124 | 124 | ||
125 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } | 125 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } |
126 | QString getCurrentSyncName() { return mCurrentSyncName; } | 126 | QString getCurrentSyncName() { return mCurrentSyncName; } |
127 | 127 | ||
128 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); | 128 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); |
129 | void hideProgressBar(); | 129 | void hideProgressBar(); |
130 | bool isProgressBarCanceled(); | 130 | bool isProgressBarCanceled(); |
131 | 131 | ||
132 | // sync stuff | 132 | // sync stuff |
133 | QString mLocalMachineName; | 133 | QString mLocalMachineName; |
134 | QStringList mExternSyncProfiles; | 134 | QStringList mExternSyncProfiles; |
135 | QStringList mSyncProfileNames; | 135 | QStringList mSyncProfileNames; |
136 | bool mAskForPreferences; | 136 | bool mAskForPreferences; |
137 | bool mShowSyncSummary; | 137 | bool mShowSyncSummary; |
138 | bool mIsKapiFile; | 138 | bool mIsKapiFile; |
139 | bool mWriteBackExistingOnly; | 139 | bool mWriteBackExistingOnly; |
140 | int mSyncAlgoPrefs; | 140 | int mSyncAlgoPrefs; |
141 | bool mWriteBackFile; | 141 | bool mWriteBackFile; |
142 | int mWriteBackInFuture; | 142 | int mWriteBackInFuture; |
143 | QString mPhoneDevice; | 143 | QString mPhoneDevice; |
144 | QString mPhoneConnection; | 144 | QString mPhoneConnection; |
145 | QString mPhoneModel; | 145 | QString mPhoneModel; |
146 | QString mPassWordPiSync; | 146 | QString mPassWordPiSync; |
147 | QString mActiveSyncPort; | 147 | QString mActiveSyncPort; |
148 | QString mActiveSyncIP ; | 148 | QString mActiveSyncIP ; |
149 | 149 | ||
150 | signals: | 150 | signals: |
151 | void save(); | 151 | void save(); |
152 | void request_file(); | 152 | void request_file(); |
153 | void getFile( bool ); | 153 | void getFile( bool ); |
154 | 154 | ||
155 | public slots: | 155 | public slots: |
156 | void slotSyncMenu( int ); | 156 | void slotSyncMenu( int ); |
157 | void deleteCommandSocket(KCommandSocket*s, int state); | 157 | void deleteCommandSocket(KCommandSocket*s, int state); |
158 | void readFileFromSocket(); | 158 | void readFileFromSocket(); |
159 | void fillSyncMenu(); | 159 | void fillSyncMenu(); |
160 | 160 | ||
161 | private: | 161 | private: |
162 | void syncPi(); | 162 | void syncPi(); |
163 | KServerSocket * mServerSocket; | 163 | KServerSocket * mServerSocket; |
164 | KPimPrefs* mPrefs; | 164 | KPimPrefs* mPrefs; |
165 | QString mDefFileName; | 165 | QString mDefFileName; |
166 | QString mCurrentSyncDevice; | 166 | QString mCurrentSyncDevice; |
167 | QString mCurrentSyncName; | 167 | QString mCurrentSyncName; |
168 | void quickSyncLocalFile(); | 168 | void quickSyncLocalFile(); |
169 | bool syncWithFile( QString fn , bool quick ); | 169 | bool syncWithFile( QString fn , bool quick ); |
170 | void syncLocalFile(); | 170 | void syncLocalFile(); |
171 | void syncPhone(); | 171 | void syncPhone(); |
172 | void syncSharp(); | 172 | void syncSharp(); |
173 | void syncKDE(); | 173 | void syncKDE(); |
174 | bool syncExternalApplication(QString); | 174 | bool syncExternalApplication(QString); |
175 | int mCurrentSyncProfile ; | 175 | int mCurrentSyncProfile ; |
176 | void syncRemote( KSyncProfile* prof, bool ask = true); | 176 | void syncRemote( KSyncProfile* prof, bool ask = true); |
177 | bool edit_sync_options(); | 177 | bool edit_sync_options(); |
178 | bool edit_pisync_options(); | 178 | bool edit_pisync_options(); |
179 | int ringSync(); | 179 | int ringSync(); |
180 | QString getPassword( ); | 180 | QString getPassword( ); |
181 | bool mPisyncFinished; | 181 | bool mPisyncFinished; |
182 | bool mBlockSaveFlag; | 182 | bool mBlockSaveFlag; |
183 | QWidget* mParent; | 183 | QWidget* mParent; |
184 | KSyncInterface* mImplementation; | 184 | KSyncInterface* mImplementation; |
185 | TargetApp mTargetApp; | 185 | TargetApp mTargetApp; |
186 | QPopupMenu* mSyncMenu; | 186 | QPopupMenu* mSyncMenu; |
187 | QProgressBar* bar; | 187 | QProgressBar* bar; |
188 | 188 | ||
189 | private slots: | 189 | private slots: |
190 | void confSync(); | 190 | void confSync(); |
191 | 191 | ||
192 | 192 | ||
193 | }; | 193 | }; |
194 | 194 | ||
195 | 195 | ||
196 | class KSyncInterface | 196 | class KSyncInterface |
197 | { | 197 | { |
198 | public : | 198 | public : |
199 | virtual void removeSyncInfo( QString syncProfile) = 0; | ||
199 | virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; | 200 | virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; |
200 | virtual bool syncExternal(KSyncManager* manager, QString resource) | 201 | virtual bool syncExternal(KSyncManager* manager, QString resource) |
201 | { | 202 | { |
202 | // empty implementation, because some syncable applications do not | 203 | // empty implementation, because some syncable applications do not |
203 | // have an external(sharpdtm) syncmode, like pwmanager. | 204 | // have an external(sharpdtm) syncmode, like pwmanager. |
204 | return false; | 205 | return false; |
205 | } | 206 | } |
206 | 207 | ||
207 | 208 | ||
208 | }; | 209 | }; |
209 | 210 | ||
210 | 211 | ||
211 | #endif | 212 | #endif |
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp index 2b8f2fa..6ae6e28 100644 --- a/pwmanager/pwmanager/pwm.cpp +++ b/pwmanager/pwmanager/pwm.cpp | |||
@@ -1,1472 +1,1478 @@ | |||
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 | #include <klocale.h> | 20 | #include <klocale.h> |
21 | #include <klistview.h> | 21 | #include <klistview.h> |
22 | #include <ktoolbar.h> | 22 | #include <ktoolbar.h> |
23 | #include <kfiledialog.h> | 23 | #include <kfiledialog.h> |
24 | #include <kiconloader.h> | 24 | #include <kiconloader.h> |
25 | #include <kmessagebox.h> | 25 | #include <kmessagebox.h> |
26 | 26 | ||
27 | #include <qstatusbar.h> | 27 | #include <qstatusbar.h> |
28 | 28 | ||
29 | #ifndef PWM_EMBEDDED | 29 | #ifndef PWM_EMBEDDED |
30 | #include <kmenubar.h> | 30 | #include <kmenubar.h> |
31 | #include <kstatusbar.h> | 31 | #include <kstatusbar.h> |
32 | #include <dcopclient.h> | 32 | #include <dcopclient.h> |
33 | #include "configwndimpl.h" | 33 | #include "configwndimpl.h" |
34 | #include "configuration.h" | 34 | #include "configuration.h" |
35 | #else | 35 | #else |
36 | #include <qmenubar.h> | 36 | #include <qmenubar.h> |
37 | #include <qmessagebox.h> | 37 | #include <qmessagebox.h> |
38 | #include <pwmprefs.h> | 38 | #include <pwmprefs.h> |
39 | #include <kpimglobalprefs.h> | 39 | #include <kpimglobalprefs.h> |
40 | #include <kcmconfigs/kcmpwmconfig.h> | 40 | #include <kcmconfigs/kcmpwmconfig.h> |
41 | #include <kcmconfigs/kcmkdepimconfig.h> | 41 | #include <kcmconfigs/kcmkdepimconfig.h> |
42 | #include <kcmultidialog.h> | 42 | #include <kcmultidialog.h> |
43 | #endif | 43 | #endif |
44 | 44 | ||
45 | 45 | ||
46 | #ifndef DESKTOP_VERSION | 46 | #ifndef DESKTOP_VERSION |
47 | #include <qpe/global.h> | 47 | #include <qpe/global.h> |
48 | #endif | 48 | #endif |
49 | 49 | ||
50 | #include <qpixmap.h> | 50 | #include <qpixmap.h> |
51 | #include <qcheckbox.h> | 51 | #include <qcheckbox.h> |
52 | #include <qspinbox.h> | 52 | #include <qspinbox.h> |
53 | #include <qlineedit.h> | 53 | #include <qlineedit.h> |
54 | #include <qfileinfo.h> | 54 | #include <qfileinfo.h> |
55 | #include <qclipboard.h> | 55 | #include <qclipboard.h> |
56 | 56 | ||
57 | 57 | ||
58 | #include <stdio.h> | 58 | #include <stdio.h> |
59 | 59 | ||
60 | #include "pwm.h" | 60 | #include "pwm.h" |
61 | #include "pwminit.h" | 61 | #include "pwminit.h" |
62 | #include "pwmprint.h" | 62 | #include "pwmprint.h" |
63 | #include "addentrywndimpl.h" | 63 | #include "addentrywndimpl.h" |
64 | #include "globalstuff.h" | 64 | #include "globalstuff.h" |
65 | #include "findwndimpl.h" | 65 | #include "findwndimpl.h" |
66 | #include "csv.h" | 66 | #include "csv.h" |
67 | 67 | ||
68 | #ifdef CONFIG_KWALLETIF | 68 | #ifdef CONFIG_KWALLETIF |
69 | # include "kwalletif.h" | 69 | # include "kwalletif.h" |
70 | # include "kwalletemu.h" | 70 | # include "kwalletemu.h" |
71 | #endif | 71 | #endif |
72 | #ifdef CONFIG_KEYCARD | 72 | #ifdef CONFIG_KEYCARD |
73 | # include "pwmkeycard.h" | 73 | # include "pwmkeycard.h" |
74 | #endif | 74 | #endif |
75 | 75 | ||
76 | 76 | ||
77 | #define DEFAULT_SIZE (QSize(700, 400)) | 77 | #define DEFAULT_SIZE (QSize(700, 400)) |
78 | 78 | ||
79 | // Button IDs for "file" popup menu | 79 | // Button IDs for "file" popup menu |
80 | enum { | 80 | enum { |
81 | BUTTON_POPUP_FILE_NEW = 0, | 81 | BUTTON_POPUP_FILE_NEW = 0, |
82 | BUTTON_POPUP_FILE_OPEN, | 82 | BUTTON_POPUP_FILE_OPEN, |
83 | BUTTON_POPUP_FILE_CLOSE, | 83 | BUTTON_POPUP_FILE_CLOSE, |
84 | BUTTON_POPUP_FILE_SAVE, | 84 | BUTTON_POPUP_FILE_SAVE, |
85 | BUTTON_POPUP_FILE_SAVEAS, | 85 | BUTTON_POPUP_FILE_SAVEAS, |
86 | BUTTON_POPUP_FILE_EXPORT, | 86 | BUTTON_POPUP_FILE_EXPORT, |
87 | BUTTON_POPUP_FILE_IMPORT, | 87 | BUTTON_POPUP_FILE_IMPORT, |
88 | BUTTON_POPUP_FILE_PRINT, | 88 | BUTTON_POPUP_FILE_PRINT, |
89 | BUTTON_POPUP_FILE_QUIT | 89 | BUTTON_POPUP_FILE_QUIT |
90 | }; | 90 | }; |
91 | // Button IDs for "manage" popup menu | 91 | // Button IDs for "manage" popup menu |
92 | enum { | 92 | enum { |
93 | BUTTON_POPUP_MANAGE_ADD = 0, | 93 | BUTTON_POPUP_MANAGE_ADD = 0, |
94 | BUTTON_POPUP_MANAGE_EDIT, | 94 | BUTTON_POPUP_MANAGE_EDIT, |
95 | BUTTON_POPUP_MANAGE_DEL, | 95 | BUTTON_POPUP_MANAGE_DEL, |
96 | BUTTON_POPUP_MANAGE_CHANGEMP | 96 | BUTTON_POPUP_MANAGE_CHANGEMP |
97 | }; | 97 | }; |
98 | // Button IDs for chipcard popup menu | 98 | // Button IDs for chipcard popup menu |
99 | enum { | 99 | enum { |
100 | #ifdef CONFIG_KEYCARD | 100 | #ifdef CONFIG_KEYCARD |
101 | BUTTON_POPUP_CHIPCARD_GENNEW = 0, | 101 | BUTTON_POPUP_CHIPCARD_GENNEW = 0, |
102 | BUTTON_POPUP_CHIPCARD_DEL, | 102 | BUTTON_POPUP_CHIPCARD_DEL, |
103 | BUTTON_POPUP_CHIPCARD_READID, | 103 | BUTTON_POPUP_CHIPCARD_READID, |
104 | BUTTON_POPUP_CHIPCARD_SAVEBACKUP, | 104 | BUTTON_POPUP_CHIPCARD_SAVEBACKUP, |
105 | BUTTON_POPUP_CHIPCARD_REPLAYBACKUP | 105 | BUTTON_POPUP_CHIPCARD_REPLAYBACKUP |
106 | #else // CONFIG_KEYCARD | 106 | #else // CONFIG_KEYCARD |
107 | BUTTON_POPUP_CHIPCARD_NO = 0 | 107 | BUTTON_POPUP_CHIPCARD_NO = 0 |
108 | #endif // CONFIG_KEYCARD | 108 | #endif // CONFIG_KEYCARD |
109 | }; | 109 | }; |
110 | // Button IDs for "view" popup menu | 110 | // Button IDs for "view" popup menu |
111 | enum { | 111 | enum { |
112 | BUTTON_POPUP_VIEW_FIND = 0, | 112 | BUTTON_POPUP_VIEW_FIND = 0, |
113 | BUTTON_POPUP_VIEW_LOCK, | 113 | BUTTON_POPUP_VIEW_LOCK, |
114 | BUTTON_POPUP_VIEW_DEEPLOCK, | 114 | BUTTON_POPUP_VIEW_DEEPLOCK, |
115 | BUTTON_POPUP_VIEW_UNLOCK | 115 | BUTTON_POPUP_VIEW_UNLOCK |
116 | }; | 116 | }; |
117 | // Button IDs for "options" popup menu | 117 | // Button IDs for "options" popup menu |
118 | enum { | 118 | enum { |
119 | BUTTON_POPUP_OPTIONS_CONFIG = 0 | 119 | BUTTON_POPUP_OPTIONS_CONFIG = 0 |
120 | }; | 120 | }; |
121 | // Button IDs for "export" popup menu (in "file" popup menu) | 121 | // Button IDs for "export" popup menu (in "file" popup menu) |
122 | enum { | 122 | enum { |
123 | BUTTON_POPUP_EXPORT_TEXT = 0, | 123 | BUTTON_POPUP_EXPORT_TEXT = 0, |
124 | BUTTON_POPUP_EXPORT_GPASMAN, | 124 | BUTTON_POPUP_EXPORT_GPASMAN, |
125 | BUTTON_POPUP_EXPORT_CSV | 125 | BUTTON_POPUP_EXPORT_CSV |
126 | #ifdef CONFIG_KWALLETIF | 126 | #ifdef CONFIG_KWALLETIF |
127 | ,BUTTON_POPUP_EXPORT_KWALLET | 127 | ,BUTTON_POPUP_EXPORT_KWALLET |
128 | #endif | 128 | #endif |
129 | }; | 129 | }; |
130 | // Button IDs for "import" popup menu (in "file" popup menu) | 130 | // Button IDs for "import" popup menu (in "file" popup menu) |
131 | enum { | 131 | enum { |
132 | BUTTON_POPUP_IMPORT_TEXT = 0, | 132 | BUTTON_POPUP_IMPORT_TEXT = 0, |
133 | BUTTON_POPUP_IMPORT_GPASMAN, | 133 | BUTTON_POPUP_IMPORT_GPASMAN, |
134 | BUTTON_POPUP_IMPORT_CSV | 134 | BUTTON_POPUP_IMPORT_CSV |
135 | #ifdef CONFIG_KWALLETIF | 135 | #ifdef CONFIG_KWALLETIF |
136 | ,BUTTON_POPUP_IMPORT_KWALLET | 136 | ,BUTTON_POPUP_IMPORT_KWALLET |
137 | #endif | 137 | #endif |
138 | }; | 138 | }; |
139 | 139 | ||
140 | #ifdef PWM_EMBEDDED | 140 | #ifdef PWM_EMBEDDED |
141 | // Button IDs for "help" popup menu | 141 | // Button IDs for "help" popup menu |
142 | enum { | 142 | enum { |
143 | BUTTON_POPUP_HELP_LICENSE = 0, | 143 | BUTTON_POPUP_HELP_LICENSE = 0, |
144 | BUTTON_POPUP_HELP_FAQ, | 144 | BUTTON_POPUP_HELP_FAQ, |
145 | BUTTON_POPUP_HELP_ABOUT, | 145 | BUTTON_POPUP_HELP_ABOUT, |
146 | BUTTON_POPUP_HELP_SYNC, | 146 | BUTTON_POPUP_HELP_SYNC, |
147 | BUTTON_POPUP_HELP_WHATSNEW | 147 | BUTTON_POPUP_HELP_WHATSNEW |
148 | }; | 148 | }; |
149 | #endif | 149 | #endif |
150 | 150 | ||
151 | // Button IDs for toolbar | 151 | // Button IDs for toolbar |
152 | enum { | 152 | enum { |
153 | BUTTON_TOOL_NEW = 0, | 153 | BUTTON_TOOL_NEW = 0, |
154 | BUTTON_TOOL_OPEN, | 154 | BUTTON_TOOL_OPEN, |
155 | BUTTON_TOOL_SAVE, | 155 | BUTTON_TOOL_SAVE, |
156 | BUTTON_TOOL_SAVEAS, | 156 | BUTTON_TOOL_SAVEAS, |
157 | BUTTON_TOOL_PRINT, | 157 | BUTTON_TOOL_PRINT, |
158 | BUTTON_TOOL_ADD, | 158 | BUTTON_TOOL_ADD, |
159 | BUTTON_TOOL_EDIT, | 159 | BUTTON_TOOL_EDIT, |
160 | BUTTON_TOOL_DEL, | 160 | BUTTON_TOOL_DEL, |
161 | BUTTON_TOOL_FIND, | 161 | BUTTON_TOOL_FIND, |
162 | BUTTON_TOOL_LOCK, | 162 | BUTTON_TOOL_LOCK, |
163 | BUTTON_TOOL_DEEPLOCK, | 163 | BUTTON_TOOL_DEEPLOCK, |
164 | BUTTON_TOOL_UNLOCK | 164 | BUTTON_TOOL_UNLOCK |
165 | }; | 165 | }; |
166 | 166 | ||
167 | 167 | ||
168 | PwM::PwM(PwMInit *_init, PwMDoc *doc, | 168 | PwM::PwM(PwMInit *_init, PwMDoc *doc, |
169 | bool virginity, | 169 | bool virginity, |
170 | QWidget *parent, const char *name) | 170 | QWidget *parent, const char *name) |
171 | : KMainWindow(parent, "HALLO") | 171 | : KMainWindow(parent, "HALLO") |
172 | , forceQuit (false) | 172 | , forceQuit (false) |
173 | , forceMinimizeToTray (false) | 173 | , forceMinimizeToTray (false) |
174 | { | 174 | { |
175 | syncManager = 0; | 175 | syncManager = 0; |
176 | virgin = !virginity; | 176 | virgin = !virginity; |
177 | init = _init; | 177 | init = _init; |
178 | connect(doc, SIGNAL(docClosed(PwMDoc *)), | 178 | connect(doc, SIGNAL(docClosed(PwMDoc *)), |
179 | this, SLOT(docClosed(PwMDoc *))); | 179 | this, SLOT(docClosed(PwMDoc *))); |
180 | initMenubar(); | 180 | initMenubar(); |
181 | initToolbar(); | 181 | initToolbar(); |
182 | initMetrics(); | 182 | initMetrics(); |
183 | setVirgin(virginity); | 183 | setVirgin(virginity); |
184 | setFocusPolicy(QWidget::WheelFocus); | 184 | setFocusPolicy(QWidget::WheelFocus); |
185 | #ifndef PWM_EMBEDDED | 185 | #ifndef PWM_EMBEDDED |
186 | statusBar()->show(); | 186 | statusBar()->show(); |
187 | #endif | 187 | #endif |
188 | view = makeNewListView(doc); | 188 | view = makeNewListView(doc); |
189 | setCentralWidget(view); | 189 | setCentralWidget(view); |
190 | updateCaption(); | 190 | updateCaption(); |
191 | showStatMsg(i18n("Ready.")); | 191 | showStatMsg(i18n("Ready.")); |
192 | } | 192 | } |
193 | 193 | ||
194 | PwM::~PwM() | 194 | PwM::~PwM() |
195 | { | 195 | { |
196 | qDebug("PwM::~PwM() %x", this); | 196 | qDebug("PwM::~PwM() %x", this); |
197 | disconnect(curDoc(), SIGNAL(docClosed(PwMDoc *)), | 197 | disconnect(curDoc(), SIGNAL(docClosed(PwMDoc *)), |
198 | this, SLOT(docClosed(PwMDoc *))); | 198 | this, SLOT(docClosed(PwMDoc *))); |
199 | conf()->confWndMainWndSize(size()); | 199 | conf()->confWndMainWndSize(size()); |
200 | //LR closing of windows changed | 200 | //LR closing of windows changed |
201 | //needed for fastload option on PDA | 201 | //needed for fastload option on PDA |
202 | //emit closed(this); | 202 | //emit closed(this); |
203 | //qDebug("PwM::~PwM() emited closed(this)"); | 203 | //qDebug("PwM::~PwM() emited closed(this)"); |
204 | delete view; | 204 | delete view; |
205 | delete syncManager; | 205 | delete syncManager; |
206 | } | 206 | } |
207 | 207 | ||
208 | void PwM::initMenubar() | 208 | void PwM::initMenubar() |
209 | { | 209 | { |
210 | KIconLoader* picons; | 210 | KIconLoader* picons; |
211 | #ifndef PWM_EMBEDDED | 211 | #ifndef PWM_EMBEDDED |
212 | KIconLoader icons; | 212 | KIconLoader icons; |
213 | picons = &icons; | 213 | picons = &icons; |
214 | #else | 214 | #else |
215 | picons = KGlobal::iconLoader(); | 215 | picons = KGlobal::iconLoader(); |
216 | 216 | ||
217 | 217 | ||
218 | syncPopup = new KPopupMenu(this); | 218 | syncPopup = new KPopupMenu(this); |
219 | 219 | ||
220 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::PWMPI, PWMPrefs::instance(), syncPopup); | 220 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::PWMPI, PWMPrefs::instance(), syncPopup); |
221 | syncManager->setBlockSave(false); | 221 | syncManager->setBlockSave(false); |
222 | 222 | ||
223 | connect ( syncPopup, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 223 | connect ( syncPopup, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
224 | syncManager->fillSyncMenu(); | 224 | syncManager->fillSyncMenu(); |
225 | 225 | ||
226 | #endif | 226 | #endif |
227 | filePopup = new KPopupMenu(this); | 227 | filePopup = new KPopupMenu(this); |
228 | importPopup = new KPopupMenu(filePopup); | 228 | importPopup = new KPopupMenu(filePopup); |
229 | exportPopup = new KPopupMenu(filePopup); | 229 | exportPopup = new KPopupMenu(filePopup); |
230 | managePopup = new KPopupMenu(this); | 230 | managePopup = new KPopupMenu(this); |
231 | #ifdef CONFIG_KEYCARD | 231 | #ifdef CONFIG_KEYCARD |
232 | chipcardPopup = new KPopupMenu(this); | 232 | chipcardPopup = new KPopupMenu(this); |
233 | #endif // CONFIG_KEYCARD | 233 | #endif // CONFIG_KEYCARD |
234 | viewPopup = new KPopupMenu(this); | 234 | viewPopup = new KPopupMenu(this); |
235 | optionsPopup = new KPopupMenu(this); | 235 | optionsPopup = new KPopupMenu(this); |
236 | 236 | ||
237 | // "file" popup menu | 237 | // "file" popup menu |
238 | filePopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), | 238 | filePopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), |
239 | i18n("&New"), this, | 239 | i18n("&New"), this, |
240 | SLOT(new_slot()), 0, BUTTON_POPUP_FILE_NEW); | 240 | SLOT(new_slot()), 0, BUTTON_POPUP_FILE_NEW); |
241 | filePopup->insertItem(QIconSet(picons->loadIcon("fileopen", KIcon::Small)), | 241 | filePopup->insertItem(QIconSet(picons->loadIcon("fileopen", KIcon::Small)), |
242 | i18n("&Open"), this, | 242 | i18n("&Open"), this, |
243 | SLOT(open_slot()), 0, BUTTON_POPUP_FILE_OPEN); | 243 | SLOT(open_slot()), 0, BUTTON_POPUP_FILE_OPEN); |
244 | filePopup->insertItem(QIconSet(picons->loadIcon("fileclose", KIcon::Small)), | 244 | filePopup->insertItem(QIconSet(picons->loadIcon("fileclose", KIcon::Small)), |
245 | i18n("&Close"), this, | 245 | i18n("&Close"), this, |
246 | SLOT(close_slot()), 0, BUTTON_POPUP_FILE_CLOSE); | 246 | SLOT(close_slot()), 0, BUTTON_POPUP_FILE_CLOSE); |
247 | filePopup->insertSeparator(); | 247 | filePopup->insertSeparator(); |
248 | filePopup->insertItem(QIconSet(picons->loadIcon("filesave", KIcon::Small)), | 248 | filePopup->insertItem(QIconSet(picons->loadIcon("filesave", KIcon::Small)), |
249 | i18n("&Save"), this, | 249 | i18n("&Save"), this, |
250 | SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE); | 250 | SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE); |
251 | filePopup->insertItem(QIconSet(picons->loadIcon("filesaveas", KIcon::Small)), | 251 | filePopup->insertItem(QIconSet(picons->loadIcon("filesaveas", KIcon::Small)), |
252 | i18n("Save &as..."), | 252 | i18n("Save &as..."), |
253 | this, SLOT(saveAs_slot()), 0, | 253 | this, SLOT(saveAs_slot()), 0, |
254 | BUTTON_POPUP_FILE_SAVEAS); | 254 | BUTTON_POPUP_FILE_SAVEAS); |
255 | filePopup->insertSeparator(); | 255 | filePopup->insertSeparator(); |
256 | // "file/export" popup menu | 256 | // "file/export" popup menu |
257 | exportPopup->insertItem(i18n("&Text-file..."), this, | 257 | exportPopup->insertItem(i18n("&Text-file..."), this, |
258 | SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT); | 258 | SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT); |
259 | exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, | 259 | exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, |
260 | SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN); | 260 | SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN); |
261 | exportPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this, | 261 | exportPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this, |
262 | SLOT(exportToCsv()), 0, BUTTON_POPUP_EXPORT_CSV); | 262 | SLOT(exportToCsv()), 0, BUTTON_POPUP_EXPORT_CSV); |
263 | #ifdef CONFIG_KWALLETIF | 263 | #ifdef CONFIG_KWALLETIF |
264 | exportPopup->insertItem(i18n("&KWallet..."), this, | 264 | exportPopup->insertItem(i18n("&KWallet..."), this, |
265 | SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET); | 265 | SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET); |
266 | #endif | 266 | #endif |
267 | filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)), | 267 | filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)), |
268 | i18n("E&xport"), exportPopup, | 268 | i18n("E&xport"), exportPopup, |
269 | BUTTON_POPUP_FILE_EXPORT); | 269 | BUTTON_POPUP_FILE_EXPORT); |
270 | // "file/import" popup menu | 270 | // "file/import" popup menu |
271 | importPopup->insertItem(i18n("&Text-file..."), this, | 271 | importPopup->insertItem(i18n("&Text-file..."), this, |
272 | SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT); | 272 | SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT); |
273 | importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, | 273 | importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, |
274 | SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN); | 274 | SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN); |
275 | importPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this, | 275 | importPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this, |
276 | SLOT(importCsv()), 0, BUTTON_POPUP_IMPORT_CSV); | 276 | SLOT(importCsv()), 0, BUTTON_POPUP_IMPORT_CSV); |
277 | #ifdef CONFIG_KWALLETIF | 277 | #ifdef CONFIG_KWALLETIF |
278 | importPopup->insertItem(i18n("&KWallet..."), this, | 278 | importPopup->insertItem(i18n("&KWallet..."), this, |
279 | SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET); | 279 | SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET); |
280 | #endif | 280 | #endif |
281 | filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)), | 281 | filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)), |
282 | i18n("I&mport"), importPopup, | 282 | i18n("I&mport"), importPopup, |
283 | BUTTON_POPUP_FILE_IMPORT); | 283 | BUTTON_POPUP_FILE_IMPORT); |
284 | filePopup->insertSeparator(); | 284 | filePopup->insertSeparator(); |
285 | filePopup->insertItem(QIconSet(picons->loadIcon("fileprint", KIcon::Small)), | 285 | filePopup->insertItem(QIconSet(picons->loadIcon("fileprint", KIcon::Small)), |
286 | i18n("&Print..."), this, | 286 | i18n("&Print..."), this, |
287 | SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT); | 287 | SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT); |
288 | filePopup->insertSeparator(); | 288 | filePopup->insertSeparator(); |
289 | filePopup->insertItem(QIconSet(picons->loadIcon("exit", KIcon::Small)), | 289 | filePopup->insertItem(QIconSet(picons->loadIcon("exit", KIcon::Small)), |
290 | i18n("&Quit"), this, | 290 | i18n("&Quit"), this, |
291 | SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT); | 291 | SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT); |
292 | menuBar()->insertItem(i18n("&File"), filePopup); | 292 | menuBar()->insertItem(i18n("&File"), filePopup); |
293 | // "manage" popup menu | 293 | // "manage" popup menu |
294 | managePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)), | 294 | managePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)), |
295 | i18n("&Add password"), this, | 295 | i18n("&Add password"), this, |
296 | SLOT(addPwd_slot()), 0, | 296 | SLOT(addPwd_slot()), 0, |
297 | BUTTON_POPUP_MANAGE_ADD); | 297 | BUTTON_POPUP_MANAGE_ADD); |
298 | managePopup->insertItem(QIconSet(picons->loadIcon("edit", KIcon::Small)), | 298 | managePopup->insertItem(QIconSet(picons->loadIcon("edit", KIcon::Small)), |
299 | i18n("&Edit"), this, SLOT(editPwd_slot()), 0, | 299 | i18n("&Edit"), this, SLOT(editPwd_slot()), 0, |
300 | BUTTON_POPUP_MANAGE_EDIT); | 300 | BUTTON_POPUP_MANAGE_EDIT); |
301 | managePopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), | 301 | managePopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), |
302 | i18n("&Delete"), this, SLOT(deletePwd_slot()), | 302 | i18n("&Delete"), this, SLOT(deletePwd_slot()), |
303 | 0, BUTTON_POPUP_MANAGE_DEL); | 303 | 0, BUTTON_POPUP_MANAGE_DEL); |
304 | managePopup->insertSeparator(); | 304 | managePopup->insertSeparator(); |
305 | managePopup->insertItem(QIconSet(picons->loadIcon("rotate", KIcon::Small)), | 305 | managePopup->insertItem(QIconSet(picons->loadIcon("rotate", KIcon::Small)), |
306 | i18n("Change &Master Password"), this, | 306 | i18n("Change &Master Password"), this, |
307 | SLOT(changeMasterPwd_slot()), 0, | 307 | SLOT(changeMasterPwd_slot()), 0, |
308 | BUTTON_POPUP_MANAGE_CHANGEMP); | 308 | BUTTON_POPUP_MANAGE_CHANGEMP); |
309 | menuBar()->insertItem(i18n("&Manage"), managePopup); | 309 | menuBar()->insertItem(i18n("&Manage"), managePopup); |
310 | // "chipcard" popup menu | 310 | // "chipcard" popup menu |
311 | #ifdef CONFIG_KEYCARD | 311 | #ifdef CONFIG_KEYCARD |
312 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), | 312 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), |
313 | i18n("&Generate new key-card"), this, | 313 | i18n("&Generate new key-card"), this, |
314 | SLOT(genNewCard_slot()), 0, | 314 | SLOT(genNewCard_slot()), 0, |
315 | BUTTON_POPUP_CHIPCARD_GENNEW); | 315 | BUTTON_POPUP_CHIPCARD_GENNEW); |
316 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), | 316 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), |
317 | i18n("&Erase key-card"), this, | 317 | i18n("&Erase key-card"), this, |
318 | SLOT(eraseCard_slot()), 0, | 318 | SLOT(eraseCard_slot()), 0, |
319 | BUTTON_POPUP_CHIPCARD_DEL); | 319 | BUTTON_POPUP_CHIPCARD_DEL); |
320 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("", KIcon::Small)), | 320 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("", KIcon::Small)), |
321 | i18n("Read card-&ID"), this, | 321 | i18n("Read card-&ID"), this, |
322 | SLOT(readCardId_slot()), 0, | 322 | SLOT(readCardId_slot()), 0, |
323 | BUTTON_POPUP_CHIPCARD_READID); | 323 | BUTTON_POPUP_CHIPCARD_READID); |
324 | chipcardPopup->insertSeparator(); | 324 | chipcardPopup->insertSeparator(); |
325 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("2rightarrow", KIcon::Small)), | 325 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("2rightarrow", KIcon::Small)), |
326 | i18n("&Make card backup-image"), this, | 326 | i18n("&Make card backup-image"), this, |
327 | SLOT(makeCardBackup_slot()), 0, | 327 | SLOT(makeCardBackup_slot()), 0, |
328 | BUTTON_POPUP_CHIPCARD_SAVEBACKUP); | 328 | BUTTON_POPUP_CHIPCARD_SAVEBACKUP); |
329 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("2leftarrow", KIcon::Small)), | 329 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("2leftarrow", KIcon::Small)), |
330 | i18n("&Replay card backup-image"), this, | 330 | i18n("&Replay card backup-image"), this, |
331 | SLOT(replayCardBackup_slot()), 0, | 331 | SLOT(replayCardBackup_slot()), 0, |
332 | BUTTON_POPUP_CHIPCARD_REPLAYBACKUP); | 332 | BUTTON_POPUP_CHIPCARD_REPLAYBACKUP); |
333 | menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup); | 333 | menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup); |
334 | #endif // CONFIG_KEYCARD | 334 | #endif // CONFIG_KEYCARD |
335 | // "view" popup menu | 335 | // "view" popup menu |
336 | viewPopup->insertItem(QIconSet(picons->loadIcon("find", KIcon::Small)), | 336 | viewPopup->insertItem(QIconSet(picons->loadIcon("find", KIcon::Small)), |
337 | i18n("&Find"), this, | 337 | i18n("&Find"), this, |
338 | SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND); | 338 | SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND); |
339 | viewPopup->insertSeparator(); | 339 | viewPopup->insertSeparator(); |
340 | viewPopup->insertItem(QIconSet(picons->loadIcon("halfencrypted", KIcon::Small)), | 340 | viewPopup->insertItem(QIconSet(picons->loadIcon("halfencrypted", KIcon::Small)), |
341 | i18n("&Lock all entries"), this, | 341 | i18n("&Lock all entries"), this, |
342 | SLOT(lockWnd_slot()), 0, | 342 | SLOT(lockWnd_slot()), 0, |
343 | BUTTON_POPUP_VIEW_LOCK); | 343 | BUTTON_POPUP_VIEW_LOCK); |
344 | viewPopup->insertItem(QIconSet(picons->loadIcon("encrypted", KIcon::Small)), | 344 | viewPopup->insertItem(QIconSet(picons->loadIcon("encrypted", KIcon::Small)), |
345 | i18n("&Deep-lock all entries"), this, | 345 | i18n("&Deep-lock all entries"), this, |
346 | SLOT(deepLockWnd_slot()), 0, | 346 | SLOT(deepLockWnd_slot()), 0, |
347 | BUTTON_POPUP_VIEW_DEEPLOCK); | 347 | BUTTON_POPUP_VIEW_DEEPLOCK); |
348 | viewPopup->insertItem(QIconSet(picons->loadIcon("decrypted", KIcon::Small)), | 348 | viewPopup->insertItem(QIconSet(picons->loadIcon("decrypted", KIcon::Small)), |
349 | i18n("&Unlock all entries"), this, | 349 | i18n("&Unlock all entries"), this, |
350 | SLOT(unlockWnd_slot()), 0, | 350 | SLOT(unlockWnd_slot()), 0, |
351 | BUTTON_POPUP_VIEW_UNLOCK); | 351 | BUTTON_POPUP_VIEW_UNLOCK); |
352 | menuBar()->insertItem(i18n("&View"), viewPopup); | 352 | menuBar()->insertItem(i18n("&View"), viewPopup); |
353 | // "options" popup menu | 353 | // "options" popup menu |
354 | optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)), | 354 | optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)), |
355 | i18n("&Configure..."), this, | 355 | i18n("&Configure..."), this, |
356 | SLOT(config_slot()), | 356 | SLOT(config_slot()), |
357 | BUTTON_POPUP_OPTIONS_CONFIG); | 357 | BUTTON_POPUP_OPTIONS_CONFIG); |
358 | menuBar()->insertItem(i18n("&Options"), optionsPopup); | 358 | menuBar()->insertItem(i18n("&Options"), optionsPopup); |
359 | // "help" popup menu | 359 | // "help" popup menu |
360 | #ifndef PWM_EMBEDDED | 360 | #ifndef PWM_EMBEDDED |
361 | helpPopup = helpMenu(QString::null, false); | 361 | helpPopup = helpMenu(QString::null, false); |
362 | #else | 362 | #else |
363 | menuBar()->insertItem(i18n("&Sync"), syncPopup); | 363 | menuBar()->insertItem(i18n("&Sync"), syncPopup); |
364 | 364 | ||
365 | 365 | ||
366 | 366 | ||
367 | 367 | ||
368 | 368 | ||
369 | helpPopup = new KPopupMenu(this); | 369 | helpPopup = new KPopupMenu(this); |
370 | 370 | ||
371 | 371 | ||
372 | helpPopup->insertItem(i18n("&License"), this, | 372 | helpPopup->insertItem(i18n("&License"), this, |
373 | SLOT(showLicense_slot()), 0, | 373 | SLOT(showLicense_slot()), 0, |
374 | BUTTON_POPUP_HELP_LICENSE); | 374 | BUTTON_POPUP_HELP_LICENSE); |
375 | 375 | ||
376 | helpPopup->insertItem(i18n("&Faq"), this, | 376 | helpPopup->insertItem(i18n("&Faq"), this, |
377 | SLOT(faq_slot()), 0, | 377 | SLOT(faq_slot()), 0, |
378 | BUTTON_POPUP_HELP_FAQ); | 378 | BUTTON_POPUP_HELP_FAQ); |
379 | 379 | ||
380 | helpPopup->insertItem(i18n("&About PwManager"), this, | 380 | helpPopup->insertItem(i18n("&About PwManager"), this, |
381 | SLOT(createAboutData_slot()), 0, | 381 | SLOT(createAboutData_slot()), 0, |
382 | BUTTON_POPUP_HELP_ABOUT); | 382 | BUTTON_POPUP_HELP_ABOUT); |
383 | 383 | ||
384 | helpPopup->insertItem(i18n("&Sync HowTo"), this, | 384 | helpPopup->insertItem(i18n("&Sync HowTo"), this, |
385 | SLOT(syncHowTo_slot()), 0, | 385 | SLOT(syncHowTo_slot()), 0, |
386 | BUTTON_POPUP_HELP_SYNC); | 386 | BUTTON_POPUP_HELP_SYNC); |
387 | 387 | ||
388 | helpPopup->insertItem(i18n("&What's New"), this, | 388 | helpPopup->insertItem(i18n("&What's New"), this, |
389 | SLOT(whatsnew_slot()), 0, | 389 | SLOT(whatsnew_slot()), 0, |
390 | BUTTON_POPUP_HELP_WHATSNEW); | 390 | BUTTON_POPUP_HELP_WHATSNEW); |
391 | 391 | ||
392 | #endif | 392 | #endif |
393 | menuBar()->insertItem(i18n("&Help"), helpPopup); | 393 | menuBar()->insertItem(i18n("&Help"), helpPopup); |
394 | 394 | ||
395 | } | 395 | } |
396 | 396 | ||
397 | void PwM::initToolbar() | 397 | void PwM::initToolbar() |
398 | { | 398 | { |
399 | KIconLoader* picons; | 399 | KIconLoader* picons; |
400 | #ifndef PWM_EMBEDDED | 400 | #ifndef PWM_EMBEDDED |
401 | KIconLoader icons; | 401 | KIconLoader icons; |
402 | picons = &icons; | 402 | picons = &icons; |
403 | #else | 403 | #else |
404 | picons = KGlobal::iconLoader(); | 404 | picons = KGlobal::iconLoader(); |
405 | #endif | 405 | #endif |
406 | 406 | ||
407 | #ifdef PWM_EMBEDDED | 407 | #ifdef PWM_EMBEDDED |
408 | if ( QApplication::desktop()->width() > 320 ) | 408 | if ( QApplication::desktop()->width() > 320 ) |
409 | #endif | 409 | #endif |
410 | { | 410 | { |
411 | toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar), | 411 | toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar), |
412 | BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this, | 412 | BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this, |
413 | SLOT(new_slot()), true, i18n("New")); | 413 | SLOT(new_slot()), true, i18n("New")); |
414 | toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar), | 414 | toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar), |
415 | BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this, | 415 | BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this, |
416 | SLOT(open_slot()), true, i18n("Open")); | 416 | SLOT(open_slot()), true, i18n("Open")); |
417 | toolBar()->insertSeparator(); | 417 | toolBar()->insertSeparator(); |
418 | } | 418 | } |
419 | toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar), | 419 | toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar), |
420 | BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this, | 420 | BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this, |
421 | SLOT(save_slot()), true, i18n("Save")); | 421 | SLOT(save_slot()), true, i18n("Save")); |
422 | toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar), | 422 | toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar), |
423 | BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this, | 423 | BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this, |
424 | SLOT(saveAs_slot()), true, i18n("Save as")); | 424 | SLOT(saveAs_slot()), true, i18n("Save as")); |
425 | toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar), | 425 | toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar), |
426 | BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this, | 426 | BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this, |
427 | SLOT(print_slot()), true, i18n("Print...")); | 427 | SLOT(print_slot()), true, i18n("Print...")); |
428 | toolBar()->insertSeparator(); | 428 | toolBar()->insertSeparator(); |
429 | toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar), | 429 | toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar), |
430 | BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this, | 430 | BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this, |
431 | SLOT(addPwd_slot()), true, | 431 | SLOT(addPwd_slot()), true, |
432 | i18n("Add password")); | 432 | i18n("Add password")); |
433 | toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar), | 433 | toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar), |
434 | BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this, | 434 | BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this, |
435 | SLOT(editPwd_slot()), true, | 435 | SLOT(editPwd_slot()), true, |
436 | i18n("Edit password")); | 436 | i18n("Edit password")); |
437 | toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar), | 437 | toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar), |
438 | BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this, | 438 | BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this, |
439 | SLOT(deletePwd_slot()), true, | 439 | SLOT(deletePwd_slot()), true, |
440 | i18n("Delete password")); | 440 | i18n("Delete password")); |
441 | toolBar()->insertSeparator(); | 441 | toolBar()->insertSeparator(); |
442 | toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar), | 442 | toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar), |
443 | BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this, | 443 | BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this, |
444 | SLOT(find_slot()), true, i18n("Find entry")); | 444 | SLOT(find_slot()), true, i18n("Find entry")); |
445 | toolBar()->insertSeparator(); | 445 | toolBar()->insertSeparator(); |
446 | toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar), | 446 | toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar), |
447 | BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this, | 447 | BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this, |
448 | SLOT(lockWnd_slot()), true, | 448 | SLOT(lockWnd_slot()), true, |
449 | i18n("Lock all entries")); | 449 | i18n("Lock all entries")); |
450 | toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar), | 450 | toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar), |
451 | BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this, | 451 | BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this, |
452 | SLOT(deepLockWnd_slot()), true, | 452 | SLOT(deepLockWnd_slot()), true, |
453 | i18n("Deep-Lock all entries")); | 453 | i18n("Deep-Lock all entries")); |
454 | toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar), | 454 | toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar), |
455 | BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this, | 455 | BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this, |
456 | SLOT(unlockWnd_slot()), true, | 456 | SLOT(unlockWnd_slot()), true, |
457 | i18n("Unlock all entries")); | 457 | i18n("Unlock all entries")); |
458 | } | 458 | } |
459 | 459 | ||
460 | void PwM::initMetrics() | 460 | void PwM::initMetrics() |
461 | { | 461 | { |
462 | QSize s = conf()->confWndMainWndSize(); | 462 | QSize s = conf()->confWndMainWndSize(); |
463 | if (s.isValid()) | 463 | if (s.isValid()) |
464 | resize(s); | 464 | resize(s); |
465 | else | 465 | else |
466 | resize(DEFAULT_SIZE); | 466 | resize(DEFAULT_SIZE); |
467 | } | 467 | } |
468 | 468 | ||
469 | void PwM::updateCaption() | 469 | void PwM::updateCaption() |
470 | { | 470 | { |
471 | setPlainCaption(curDoc()->getTitle() + " - " PROG_NAME " " PACKAGE_VER); | 471 | setPlainCaption(curDoc()->getTitle() + " - " PROG_NAME " " PACKAGE_VER); |
472 | } | 472 | } |
473 | 473 | ||
474 | void PwM::hideEvent(QHideEvent *) | 474 | void PwM::hideEvent(QHideEvent *) |
475 | { | 475 | { |
476 | if (isMinimized()) { | 476 | if (isMinimized()) { |
477 | if (init->tray()) { | 477 | if (init->tray()) { |
478 | forceMinimizeToTray = true; | 478 | forceMinimizeToTray = true; |
479 | close(); | 479 | close(); |
480 | } | 480 | } |
481 | int mmlock = conf()->confGlobMinimizeLock(); | 481 | int mmlock = conf()->confGlobMinimizeLock(); |
482 | switch (mmlock) { | 482 | switch (mmlock) { |
483 | case 0: // don't lock anything | 483 | case 0: // don't lock anything |
484 | break; | 484 | break; |
485 | case 1: {// normal lock | 485 | case 1: {// normal lock |
486 | curDoc()->lockAll(true); | 486 | curDoc()->lockAll(true); |
487 | break; | 487 | break; |
488 | } case 2: {// deep-lock | 488 | } case 2: {// deep-lock |
489 | curDoc()->deepLock(); | 489 | curDoc()->deepLock(); |
490 | break; | 490 | break; |
491 | } default: | 491 | } default: |
492 | WARN(); | 492 | WARN(); |
493 | } | 493 | } |
494 | } | 494 | } |
495 | } | 495 | } |
496 | 496 | ||
497 | void PwM::setVirgin(bool v) | 497 | void PwM::setVirgin(bool v) |
498 | { | 498 | { |
499 | if (virgin == v) | 499 | if (virgin == v) |
500 | return; | 500 | return; |
501 | virgin = v; | 501 | virgin = v; |
502 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVE, !v); | 502 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVE, !v); |
503 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVEAS, !v); | 503 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVEAS, !v); |
504 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_EXPORT, !v); | 504 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_EXPORT, !v); |
505 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_PRINT, !v); | 505 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_PRINT, !v); |
506 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_EDIT, !v); | 506 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_EDIT, !v); |
507 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_DEL, !v); | 507 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_DEL, !v); |
508 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, !v); | 508 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, !v); |
509 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_LOCK, !v); | 509 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_LOCK, !v); |
510 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_DEEPLOCK, !v); | 510 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_DEEPLOCK, !v); |
511 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_UNLOCK, !v); | 511 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_UNLOCK, !v); |
512 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_FIND, !v); | 512 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_FIND, !v); |
513 | toolBar()->setItemEnabled(BUTTON_TOOL_SAVE, !v); | 513 | toolBar()->setItemEnabled(BUTTON_TOOL_SAVE, !v); |
514 | toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v); | 514 | toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v); |
515 | toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v); | 515 | toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v); |
516 | toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v); | 516 | toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v); |
517 | toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v); | 517 | toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v); |
518 | toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v); | 518 | toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v); |
519 | toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v); | 519 | toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v); |
520 | toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v); | 520 | toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v); |
521 | toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v); | 521 | toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v); |
522 | } | 522 | } |
523 | 523 | ||
524 | void PwM::new_slot() | 524 | void PwM::new_slot() |
525 | { | 525 | { |
526 | init->createMainWnd(); | 526 | init->createMainWnd(); |
527 | } | 527 | } |
528 | 528 | ||
529 | //US ENH | 529 | //US ENH |
530 | void PwM::open_slot() | 530 | void PwM::open_slot() |
531 | { | 531 | { |
532 | open_slot(""); | 532 | open_slot(""); |
533 | } | 533 | } |
534 | 534 | ||
535 | void PwM::open_slot(QString fn) | 535 | void PwM::open_slot(QString fn) |
536 | { | 536 | { |
537 | openDoc(fn); | 537 | openDoc(fn); |
538 | } | 538 | } |
539 | 539 | ||
540 | PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked) | 540 | PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked) |
541 | { | 541 | { |
542 | if (!isVirgin()) { | 542 | if (!isVirgin()) { |
543 | // open the document in a new window. | 543 | // open the document in a new window. |
544 | PwM *newInstance = init->createMainWnd(); | 544 | PwM *newInstance = init->createMainWnd(); |
545 | PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked); | 545 | PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked); |
546 | if (!newDoc) { | 546 | if (!newDoc) { |
547 | newInstance->setForceQuit(true); | 547 | newInstance->setForceQuit(true); |
548 | delete_and_null(newInstance); | 548 | delete_and_null(newInstance); |
549 | } | 549 | } |
550 | return newDoc; | 550 | return newDoc; |
551 | } | 551 | } |
552 | 552 | ||
553 | if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked)) | 553 | if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked)) |
554 | return 0; | 554 | return 0; |
555 | showStatMsg(i18n("Successfully opened file.")); | 555 | showStatMsg(i18n("Successfully opened file.")); |
556 | updateCaption(); | 556 | updateCaption(); |
557 | setVirgin(false); | 557 | setVirgin(false); |
558 | return curDoc(); | 558 | return curDoc(); |
559 | } | 559 | } |
560 | 560 | ||
561 | PwMView * PwM::makeNewListView(PwMDoc *doc) | 561 | PwMView * PwM::makeNewListView(PwMDoc *doc) |
562 | { | 562 | { |
563 | PwMView *ret = new PwMView(this, this, doc); | 563 | PwMView *ret = new PwMView(this, this, doc); |
564 | ret->setFont(conf()->confGlobEntryFont()); | 564 | ret->setFont(conf()->confGlobEntryFont()); |
565 | ret->show(); | 565 | ret->show(); |
566 | return ret; | 566 | return ret; |
567 | } | 567 | } |
568 | 568 | ||
569 | void PwM::close_slot() | 569 | void PwM::close_slot() |
570 | { | 570 | { |
571 | close(); | 571 | close(); |
572 | } | 572 | } |
573 | 573 | ||
574 | void PwM::quitButton_slot() | 574 | void PwM::quitButton_slot() |
575 | { | 575 | { |
576 | init->shutdownApp(0); | 576 | init->shutdownApp(0); |
577 | } | 577 | } |
578 | 578 | ||
579 | void PwM::save_slot() | 579 | void PwM::save_slot() |
580 | { | 580 | { |
581 | save(); | 581 | save(); |
582 | } | 582 | } |
583 | 583 | ||
584 | bool PwM::save() | 584 | bool PwM::save() |
585 | { | 585 | { |
586 | if (!curDoc()->saveDocUi(curDoc())) | 586 | if (!curDoc()->saveDocUi(curDoc())) |
587 | return false; | 587 | return false; |
588 | showStatMsg(i18n("Successfully saved data.")); | 588 | showStatMsg(i18n("Successfully saved data.")); |
589 | updateCaption(); | 589 | updateCaption(); |
590 | return true; | 590 | return true; |
591 | } | 591 | } |
592 | 592 | ||
593 | void PwM::saveAs_slot() | 593 | void PwM::saveAs_slot() |
594 | { | 594 | { |
595 | saveAs(); | 595 | saveAs(); |
596 | } | 596 | } |
597 | 597 | ||
598 | bool PwM::saveAs() | 598 | bool PwM::saveAs() |
599 | { | 599 | { |
600 | if (!curDoc()->saveAsDocUi(curDoc())) | 600 | if (!curDoc()->saveAsDocUi(curDoc())) |
601 | return false; | 601 | return false; |
602 | showStatMsg(i18n("Successfully saved data.")); | 602 | showStatMsg(i18n("Successfully saved data.")); |
603 | updateCaption(); | 603 | updateCaption(); |
604 | return true; | 604 | return true; |
605 | } | 605 | } |
606 | 606 | ||
607 | //US ENH : changed code to run with older MOC | 607 | //US ENH : changed code to run with older MOC |
608 | void PwM::addPwd_slot() | 608 | void PwM::addPwd_slot() |
609 | { | 609 | { |
610 | addPwd_slot1(0, 0); | 610 | addPwd_slot1(0, 0); |
611 | } | 611 | } |
612 | 612 | ||
613 | void PwM::addPwd_slot1(QString *pw, PwMDoc *_doc) | 613 | void PwM::addPwd_slot1(QString *pw, PwMDoc *_doc) |
614 | { | 614 | { |
615 | PwMDoc *doc; | 615 | PwMDoc *doc; |
616 | if (_doc) { | 616 | if (_doc) { |
617 | doc = _doc; | 617 | doc = _doc; |
618 | } else { | 618 | } else { |
619 | doc = curDoc(); | 619 | doc = curDoc(); |
620 | } | 620 | } |
621 | PWM_ASSERT(doc); | 621 | PWM_ASSERT(doc); |
622 | doc->timer()->getLock(DocTimer::id_autoLockTimer); | 622 | doc->timer()->getLock(DocTimer::id_autoLockTimer); |
623 | #ifndef PWM_EMBEDDED | 623 | #ifndef PWM_EMBEDDED |
624 | AddEntryWndImpl w; | 624 | AddEntryWndImpl w; |
625 | #else | 625 | #else |
626 | AddEntryWndImpl w(this, "addentrywndimpl"); | 626 | AddEntryWndImpl w(this, "addentrywndimpl"); |
627 | #endif | 627 | #endif |
628 | 628 | ||
629 | vector<string> catList; | 629 | vector<string> catList; |
630 | doc->getCategoryList(&catList); | 630 | doc->getCategoryList(&catList); |
631 | unsigned i, size = catList.size(); | 631 | unsigned i, size = catList.size(); |
632 | for (i = 0; i < size; ++i) { | 632 | for (i = 0; i < size; ++i) { |
633 | w.addCategory(catList[i].c_str()); | 633 | w.addCategory(catList[i].c_str()); |
634 | } | 634 | } |
635 | w.setCurrCategory(view->getCurrentCategory()); | 635 | w.setCurrCategory(view->getCurrentCategory()); |
636 | if (pw) | 636 | if (pw) |
637 | w.pwLineEdit->setText(*pw); | 637 | w.pwLineEdit->setText(*pw); |
638 | 638 | ||
639 | tryAgain: | 639 | tryAgain: |
640 | if (w.exec() == 1) | 640 | if (w.exec() == 1) |
641 | { | 641 | { |
642 | PwMDataItem d; | 642 | PwMDataItem d; |
643 | 643 | ||
644 | //US BUG: to initialize all values of curEntr with meaningfulldata, | 644 | //US BUG: to initialize all values of curEntr with meaningfulldata, |
645 | // we call clear on it. Reason: Metadata will be uninitialized otherwise. | 645 | // we call clear on it. Reason: Metadata will be uninitialized otherwise. |
646 | // another option would be to create a constructor for PwMDataItem | 646 | // another option would be to create a constructor for PwMDataItem |
647 | d.clear(true); | 647 | d.clear(true); |
648 | 648 | ||
649 | d.desc = w.getDescription().latin1(); | 649 | d.desc = w.getDescription().latin1(); |
650 | d.name = w.getUsername().latin1(); | 650 | d.name = w.getUsername().latin1(); |
651 | d.pw = w.getPassword().latin1(); | 651 | d.pw = w.getPassword().latin1(); |
652 | d.comment = w.getComment().latin1(); | 652 | d.comment = w.getComment().latin1(); |
653 | d.url = w.getUrl().latin1(); | 653 | d.url = w.getUrl().latin1(); |
654 | d.launcher = w.getLauncher().latin1(); | 654 | d.launcher = w.getLauncher().latin1(); |
655 | PwMerror ret = doc->addEntry(w.getCategory(), &d); | 655 | PwMerror ret = doc->addEntry(w.getCategory(), &d); |
656 | if (ret == e_entryExists) { | 656 | if (ret == e_entryExists) { |
657 | KMessageBox::error(this, | 657 | KMessageBox::error(this, |
658 | i18n | 658 | i18n |
659 | ("An entry with this \"Description\",\n" | 659 | ("An entry with this \"Description\",\n" |
660 | "does already exist.\n" | 660 | "does already exist.\n" |
661 | "Please select another description."), | 661 | "Please select another description."), |
662 | i18n("entry already exists.")); | 662 | i18n("entry already exists.")); |
663 | goto tryAgain; | 663 | goto tryAgain; |
664 | } else if (ret == e_maxAllowedEntr) { | 664 | } else if (ret == e_maxAllowedEntr) { |
665 | KMessageBox::error(this, i18n("The maximum possible number of\nentries" | 665 | KMessageBox::error(this, i18n("The maximum possible number of\nentries" |
666 | "has been reached.\nYou can't add more entries."), | 666 | "has been reached.\nYou can't add more entries."), |
667 | i18n("maximum number of entries")); | 667 | i18n("maximum number of entries")); |
668 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 668 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
669 | return; | 669 | return; |
670 | } | 670 | } |
671 | } | 671 | } |
672 | setVirgin(false); | 672 | setVirgin(false); |
673 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 673 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
674 | } | 674 | } |
675 | 675 | ||
676 | //US ENH : changed code to run with older MOC | 676 | //US ENH : changed code to run with older MOC |
677 | void PwM::editPwd_slot() | 677 | void PwM::editPwd_slot() |
678 | { | 678 | { |
679 | editPwd_slot3(0,0,0); | 679 | editPwd_slot3(0,0,0); |
680 | } | 680 | } |
681 | 681 | ||
682 | void PwM::editPwd_slot1(const QString *category) | 682 | void PwM::editPwd_slot1(const QString *category) |
683 | { | 683 | { |
684 | editPwd_slot3(category, 0, 0); | 684 | editPwd_slot3(category, 0, 0); |
685 | } | 685 | } |
686 | 686 | ||
687 | void PwM::editPwd_slot3(const QString *category, const int *index, | 687 | void PwM::editPwd_slot3(const QString *category, const int *index, |
688 | PwMDoc *_doc) | 688 | PwMDoc *_doc) |
689 | { | 689 | { |
690 | PwMDoc *doc; | 690 | PwMDoc *doc; |
691 | if (_doc) { | 691 | if (_doc) { |
692 | doc = _doc; | 692 | doc = _doc; |
693 | } else { | 693 | } else { |
694 | doc = curDoc(); | 694 | doc = curDoc(); |
695 | } | 695 | } |
696 | PWM_ASSERT(doc); | 696 | PWM_ASSERT(doc); |
697 | if (doc->isDocEmpty()) | 697 | if (doc->isDocEmpty()) |
698 | return; | 698 | return; |
699 | if (doc->isDeepLocked()) | 699 | if (doc->isDeepLocked()) |
700 | return; | 700 | return; |
701 | doc->timer()->getLock(DocTimer::id_autoLockTimer); | 701 | doc->timer()->getLock(DocTimer::id_autoLockTimer); |
702 | unsigned int curEntryIndex; | 702 | unsigned int curEntryIndex; |
703 | if (index) { | 703 | if (index) { |
704 | curEntryIndex = *index; | 704 | curEntryIndex = *index; |
705 | } else { | 705 | } else { |
706 | if (!(view->getCurEntryIndex(&curEntryIndex))) { | 706 | if (!(view->getCurEntryIndex(&curEntryIndex))) { |
707 | printDebug("couldn't get index. Maybe we have a binary entry here."); | 707 | printDebug("couldn't get index. Maybe we have a binary entry here."); |
708 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 708 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
709 | return; | 709 | return; |
710 | } | 710 | } |
711 | } | 711 | } |
712 | QString curCategory; | 712 | QString curCategory; |
713 | if (category) { | 713 | if (category) { |
714 | curCategory = *category; | 714 | curCategory = *category; |
715 | } else { | 715 | } else { |
716 | curCategory = view->getCurrentCategory(); | 716 | curCategory = view->getCurrentCategory(); |
717 | } | 717 | } |
718 | PwMDataItem currItem; | 718 | PwMDataItem currItem; |
719 | if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) { | 719 | if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) { |
720 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 720 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
721 | return; | 721 | return; |
722 | } | 722 | } |
723 | BUG_ON(currItem.binary); | 723 | BUG_ON(currItem.binary); |
724 | 724 | ||
725 | AddEntryWndImpl w; | 725 | AddEntryWndImpl w; |
726 | vector<string> catList; | 726 | vector<string> catList; |
727 | doc->getCategoryList(&catList); | 727 | doc->getCategoryList(&catList); |
728 | unsigned i, size = catList.size(); | 728 | unsigned i, size = catList.size(); |
729 | for (i = 0; i < size; ++i) { | 729 | for (i = 0; i < size; ++i) { |
730 | w.addCategory(catList[i].c_str()); | 730 | w.addCategory(catList[i].c_str()); |
731 | } | 731 | } |
732 | w.setCurrCategory(curCategory); | 732 | w.setCurrCategory(curCategory); |
733 | w.setDescription(currItem.desc.c_str()); | 733 | w.setDescription(currItem.desc.c_str()); |
734 | w.setUsername(currItem.name.c_str()); | 734 | w.setUsername(currItem.name.c_str()); |
735 | w.setPassword(currItem.pw.c_str()); | 735 | w.setPassword(currItem.pw.c_str()); |
736 | w.setUrl(currItem.url.c_str()); | 736 | w.setUrl(currItem.url.c_str()); |
737 | w.setLauncher(currItem.launcher.c_str()); | 737 | w.setLauncher(currItem.launcher.c_str()); |
738 | w.setComment(currItem.comment.c_str()); | 738 | w.setComment(currItem.comment.c_str()); |
739 | if (w.exec() == 1) { | 739 | if (w.exec() == 1) { |
740 | currItem.desc = w.getDescription().latin1(); | 740 | currItem.desc = w.getDescription().latin1(); |
741 | currItem.name = w.getUsername().latin1(); | 741 | currItem.name = w.getUsername().latin1(); |
742 | currItem.pw = w.getPassword().latin1(); | 742 | currItem.pw = w.getPassword().latin1(); |
743 | currItem.comment = w.getComment().latin1(); | 743 | currItem.comment = w.getComment().latin1(); |
744 | currItem.url = w.getUrl().latin1(); | 744 | currItem.url = w.getUrl().latin1(); |
745 | currItem.launcher = w.getLauncher().latin1(); | 745 | currItem.launcher = w.getLauncher().latin1(); |
746 | if (!doc->editEntry(curCategory, w.getCategory(), | 746 | if (!doc->editEntry(curCategory, w.getCategory(), |
747 | curEntryIndex, &currItem)) { | 747 | curEntryIndex, &currItem)) { |
748 | KMessageBox::error(this, | 748 | KMessageBox::error(this, |
749 | i18n("Couldn't edit the entry.\n" | 749 | i18n("Couldn't edit the entry.\n" |
750 | "Maybe you changed the category and\n" | 750 | "Maybe you changed the category and\n" |
751 | "this entry is already present\nin the new " | 751 | "this entry is already present\nin the new " |
752 | "category?"), | 752 | "category?"), |
753 | i18n("couldn't edit entry.")); | 753 | i18n("couldn't edit entry.")); |
754 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 754 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
755 | return; | 755 | return; |
756 | } | 756 | } |
757 | } | 757 | } |
758 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 758 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
759 | } | 759 | } |
760 | 760 | ||
761 | void PwM::deletePwd_slot() | 761 | void PwM::deletePwd_slot() |
762 | { | 762 | { |
763 | PWM_ASSERT(curDoc()); | 763 | PWM_ASSERT(curDoc()); |
764 | if (curDoc()->isDocEmpty()) | 764 | if (curDoc()->isDocEmpty()) |
765 | return; | 765 | return; |
766 | if (curDoc()->isDeepLocked()) | 766 | if (curDoc()->isDeepLocked()) |
767 | return; | 767 | return; |
768 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 768 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
769 | unsigned int curEntryIndex = 0; | 769 | unsigned int curEntryIndex = 0; |
770 | if (!(view->getCurEntryIndex(&curEntryIndex))) { | 770 | if (!(view->getCurEntryIndex(&curEntryIndex))) { |
771 | printDebug("couldn't get index"); | 771 | printDebug("couldn't get index"); |
772 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 772 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
773 | return; | 773 | return; |
774 | } | 774 | } |
775 | 775 | ||
776 | PwMDataItem currItem; | 776 | PwMDataItem currItem; |
777 | QString curCategory = view->getCurrentCategory(); | 777 | QString curCategory = view->getCurrentCategory(); |
778 | if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) { | 778 | if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) { |
779 | printDebug("couldn't get entry"); | 779 | printDebug("couldn't get entry"); |
780 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 780 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
781 | return; | 781 | return; |
782 | } | 782 | } |
783 | if (KMessageBox:: | 783 | if (KMessageBox:: |
784 | questionYesNo(this, | 784 | questionYesNo(this, |
785 | i18n | 785 | i18n |
786 | ("Do you really want to delete\nthe selected entry") + | 786 | ("Do you really want to delete\nthe selected entry") + |
787 | " \n\"" + QString(currItem.desc.c_str()) | 787 | " \n\"" + QString(currItem.desc.c_str()) |
788 | + "\" ?", i18n("delete?")) | 788 | + "\" ?", i18n("delete?")) |
789 | == KMessageBox::Yes) { | 789 | == KMessageBox::Yes) { |
790 | 790 | ||
791 | curDoc()->delEntry(curCategory, curEntryIndex); | 791 | curDoc()->delEntry(curCategory, curEntryIndex); |
792 | } | 792 | } |
793 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 793 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
794 | } | 794 | } |
795 | 795 | ||
796 | void PwM::changeMasterPwd_slot() | 796 | void PwM::changeMasterPwd_slot() |
797 | { | 797 | { |
798 | PWM_ASSERT(curDoc()); | 798 | PWM_ASSERT(curDoc()); |
799 | curDoc()->changeCurrentPw(); | 799 | curDoc()->changeCurrentPw(); |
800 | } | 800 | } |
801 | 801 | ||
802 | void PwM::lockWnd_slot() | 802 | void PwM::lockWnd_slot() |
803 | { | 803 | { |
804 | PWM_ASSERT(curDoc()); | 804 | PWM_ASSERT(curDoc()); |
805 | curDoc()->lockAll(true); | 805 | curDoc()->lockAll(true); |
806 | } | 806 | } |
807 | 807 | ||
808 | void PwM::deepLockWnd_slot() | 808 | void PwM::deepLockWnd_slot() |
809 | { | 809 | { |
810 | PWM_ASSERT(curDoc()); | 810 | PWM_ASSERT(curDoc()); |
811 | curDoc()->deepLock(); | 811 | curDoc()->deepLock(); |
812 | } | 812 | } |
813 | 813 | ||
814 | void PwM::unlockWnd_slot() | 814 | void PwM::unlockWnd_slot() |
815 | { | 815 | { |
816 | PWM_ASSERT(curDoc()); | 816 | PWM_ASSERT(curDoc()); |
817 | curDoc()->lockAll(false); | 817 | curDoc()->lockAll(false); |
818 | } | 818 | } |
819 | 819 | ||
820 | void PwM::config_slot() | 820 | void PwM::config_slot() |
821 | { | 821 | { |
822 | int oldStyle = conf()->confWndMainViewStyle(); | 822 | int oldStyle = conf()->confWndMainViewStyle(); |
823 | #ifdef PWM_EMBEDDED | 823 | #ifdef PWM_EMBEDDED |
824 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"pwmconfigdialog", true ); | 824 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"pwmconfigdialog", true ); |
825 | 825 | ||
826 | KCMPwmConfig* pwmcfg = new KCMPwmConfig( ConfigureDialog->getNewVBoxPage(i18n( "PwManager")) , "KCMPwmConfig" ); | 826 | KCMPwmConfig* pwmcfg = new KCMPwmConfig( ConfigureDialog->getNewVBoxPage(i18n( "PwManager")) , "KCMPwmConfig" ); |
827 | ConfigureDialog->addModule(pwmcfg ); | 827 | ConfigureDialog->addModule(pwmcfg ); |
828 | 828 | ||
829 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 829 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
830 | ConfigureDialog->addModule(kdelibcfg ); | 830 | ConfigureDialog->addModule(kdelibcfg ); |
831 | 831 | ||
832 | #ifndef DESKTOP_VERSION | 832 | #ifndef DESKTOP_VERSION |
833 | ConfigureDialog->showMaximized(); | 833 | ConfigureDialog->showMaximized(); |
834 | #endif | 834 | #endif |
835 | if ( ConfigureDialog->exec() ) | 835 | if ( ConfigureDialog->exec() ) |
836 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 836 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
837 | delete ConfigureDialog; | 837 | delete ConfigureDialog; |
838 | 838 | ||
839 | #else //PWM_EMBEDDED | 839 | #else //PWM_EMBEDDED |
840 | // display the configuration window (modal mode) | 840 | // display the configuration window (modal mode) |
841 | if (!conf()->showConfWnd(this)) | 841 | if (!conf()->showConfWnd(this)) |
842 | return; | 842 | return; |
843 | #endif | 843 | #endif |
844 | 844 | ||
845 | int newStyle = conf()->confWndMainViewStyle(); | 845 | int newStyle = conf()->confWndMainViewStyle(); |
846 | // reinitialize tray | 846 | // reinitialize tray |
847 | init->initTray(); | 847 | init->initTray(); |
848 | // reinitialize KWallet emulation | 848 | // reinitialize KWallet emulation |
849 | init->initKWalletEmu(); | 849 | init->initKWalletEmu(); |
850 | 850 | ||
851 | PwMDocList *_dl = PwMDoc::getOpenDocList(); | 851 | PwMDocList *_dl = PwMDoc::getOpenDocList(); |
852 | const vector<PwMDocList::listItem> *dl = _dl->getList(); | 852 | const vector<PwMDocList::listItem> *dl = _dl->getList(); |
853 | vector<PwMDocList::listItem>::const_iterator i = dl->begin(), | 853 | vector<PwMDocList::listItem>::const_iterator i = dl->begin(), |
854 | end = dl->end(); | 854 | end = dl->end(); |
855 | PwMDoc *doc; | 855 | PwMDoc *doc; |
856 | while (i != end) { | 856 | while (i != end) { |
857 | doc = (*i).doc; | 857 | doc = (*i).doc; |
858 | // unlock-without-mpw timeout | 858 | // unlock-without-mpw timeout |
859 | doc->timer()->start(DocTimer::id_mpwTimer); | 859 | doc->timer()->start(DocTimer::id_mpwTimer); |
860 | // auto-lock timeout | 860 | // auto-lock timeout |
861 | doc->timer()->start(DocTimer::id_autoLockTimer); | 861 | doc->timer()->start(DocTimer::id_autoLockTimer); |
862 | ++i; | 862 | ++i; |
863 | } | 863 | } |
864 | 864 | ||
865 | const QValueList<PwM *> *ml = init->mainWndList(); | 865 | const QValueList<PwM *> *ml = init->mainWndList(); |
866 | #ifndef PWM_EMBEDDED | 866 | #ifndef PWM_EMBEDDED |
867 | QValueList<PwM *>::const_iterator i2 = ml->begin(), | 867 | QValueList<PwM *>::const_iterator i2 = ml->begin(), |
868 | end2 = ml->end(); | 868 | end2 = ml->end(); |
869 | #else | 869 | #else |
870 | QValueList<PwM *>::ConstIterator i2 = ml->begin(), | 870 | QValueList<PwM *>::ConstIterator i2 = ml->begin(), |
871 | end2 = ml->end(); | 871 | end2 = ml->end(); |
872 | #endif | 872 | #endif |
873 | PwM *pwm; | 873 | PwM *pwm; |
874 | while (i2 != end2) { | 874 | while (i2 != end2) { |
875 | pwm = *i2; | 875 | pwm = *i2; |
876 | // reinitialize the window style. | 876 | // reinitialize the window style. |
877 | if (oldStyle != newStyle) | 877 | if (oldStyle != newStyle) |
878 | pwm->curView()->initStyle(newStyle); | 878 | pwm->curView()->initStyle(newStyle); |
879 | // set the new font | 879 | // set the new font |
880 | pwm->curView()->setFont(conf()->confGlobEntryFont()); | 880 | pwm->curView()->setFont(conf()->confGlobEntryFont()); |
881 | ++i2; | 881 | ++i2; |
882 | } | 882 | } |
883 | } | 883 | } |
884 | 884 | ||
885 | void PwM::activateMpButton(bool activate) | 885 | void PwM::activateMpButton(bool activate) |
886 | { | 886 | { |
887 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate); | 887 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate); |
888 | } | 888 | } |
889 | 889 | ||
890 | void PwM::closeEvent(QCloseEvent *e) | 890 | void PwM::closeEvent(QCloseEvent *e) |
891 | { | 891 | { |
892 | qDebug("PwM::closeEvent "); | 892 | qDebug("PwM::closeEvent "); |
893 | emit closed( this ); | 893 | emit closed( this ); |
894 | return; | 894 | return; |
895 | e->accept(); | 895 | e->accept(); |
896 | } | 896 | } |
897 | 897 | ||
898 | void PwM::docClosed(PwMDoc *doc) | 898 | void PwM::docClosed(PwMDoc *doc) |
899 | { | 899 | { |
900 | qDebug("PwM::docClosed "); | 900 | qDebug("PwM::docClosed "); |
901 | PARAM_UNUSED(doc); | 901 | PARAM_UNUSED(doc); |
902 | PWM_ASSERT(doc == curDoc()); | 902 | PWM_ASSERT(doc == curDoc()); |
903 | close(); | 903 | close(); |
904 | } | 904 | } |
905 | 905 | ||
906 | void PwM::find_slot() | 906 | void PwM::find_slot() |
907 | { | 907 | { |
908 | PWM_ASSERT(curDoc()); | 908 | PWM_ASSERT(curDoc()); |
909 | if (curDoc()->isDocEmpty()) | 909 | if (curDoc()->isDocEmpty()) |
910 | return; | 910 | return; |
911 | if (curDoc()->isDeepLocked()) | 911 | if (curDoc()->isDeepLocked()) |
912 | return; | 912 | return; |
913 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 913 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
914 | FindWndImpl findWnd(view); | 914 | FindWndImpl findWnd(view); |
915 | findWnd.exec(); | 915 | findWnd.exec(); |
916 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 916 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
917 | } | 917 | } |
918 | 918 | ||
919 | void PwM::exportToText() | 919 | void PwM::exportToText() |
920 | { | 920 | { |
921 | PWM_ASSERT(curDoc()); | 921 | PWM_ASSERT(curDoc()); |
922 | if (curDoc()->isDocEmpty()) { | 922 | if (curDoc()->isDocEmpty()) { |
923 | KMessageBox::information(this, | 923 | KMessageBox::information(this, |
924 | i18n | 924 | i18n |
925 | ("Sorry, there's nothing to export.\n" | 925 | ("Sorry, there's nothing to export.\n" |
926 | "Please first add some passwords."), | 926 | "Please first add some passwords."), |
927 | i18n("nothing to do")); | 927 | i18n("nothing to do")); |
928 | return; | 928 | return; |
929 | } | 929 | } |
930 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 930 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
931 | QString fn(KFileDialog::getSaveFileName(QString::null, | 931 | QString fn(KFileDialog::getSaveFileName(QString::null, |
932 | i18n("*|plain-text file"), | 932 | i18n("*|plain-text file"), |
933 | this)); | 933 | this)); |
934 | if (fn == "") { | 934 | if (fn == "") { |
935 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 935 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
936 | return; | 936 | return; |
937 | } | 937 | } |
938 | 938 | ||
939 | PwMerror ret = curDoc()->exportToText(&fn); | 939 | PwMerror ret = curDoc()->exportToText(&fn); |
940 | if (ret != e_success) { | 940 | if (ret != e_success) { |
941 | KMessageBox::error(this, | 941 | KMessageBox::error(this, |
942 | i18n("Error: Couldn't write to file.\n" | 942 | i18n("Error: Couldn't write to file.\n" |
943 | "Please check if you have permission to write\n" | 943 | "Please check if you have permission to write\n" |
944 | "to the file in that directory."), | 944 | "to the file in that directory."), |
945 | i18n("error while writing")); | 945 | i18n("error while writing")); |
946 | } else | 946 | } else |
947 | showStatMsg(i18n("Successfully exported data.")); | 947 | showStatMsg(i18n("Successfully exported data.")); |
948 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 948 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
949 | } | 949 | } |
950 | 950 | ||
951 | bool PwM::importFromText() | 951 | bool PwM::importFromText() |
952 | { | 952 | { |
953 | if (!isVirgin()) { | 953 | if (!isVirgin()) { |
954 | if (KMessageBox::questionYesNo(this, | 954 | if (KMessageBox::questionYesNo(this, |
955 | i18n("Do you want to import the data\n" | 955 | i18n("Do you want to import the data\n" |
956 | "into the current document? (If you\n" | 956 | "into the current document? (If you\n" |
957 | "select \"no\", a new document will be\n" | 957 | "select \"no\", a new document will be\n" |
958 | "opened.)"), | 958 | "opened.)"), |
959 | i18n("import into this document?")) | 959 | i18n("import into this document?")) |
960 | == KMessageBox::No) { | 960 | == KMessageBox::No) { |
961 | // import the data to a new window. | 961 | // import the data to a new window. |
962 | PwM *newInstance = init->createMainWnd(); | 962 | PwM *newInstance = init->createMainWnd(); |
963 | bool ok = newInstance->importFromText(); | 963 | bool ok = newInstance->importFromText(); |
964 | if (!ok) { | 964 | if (!ok) { |
965 | newInstance->setForceQuit(true); | 965 | newInstance->setForceQuit(true); |
966 | delete_and_null(newInstance); | 966 | delete_and_null(newInstance); |
967 | } | 967 | } |
968 | return ok; | 968 | return ok; |
969 | } | 969 | } |
970 | } | 970 | } |
971 | 971 | ||
972 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 972 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
973 | PwMerror ret; | 973 | PwMerror ret; |
974 | QString path(KFileDialog::getOpenFileName(QString::null, | 974 | QString path(KFileDialog::getOpenFileName(QString::null, |
975 | i18n("*|PWM-exported text file"), | 975 | i18n("*|PWM-exported text file"), |
976 | this)); | 976 | this)); |
977 | if (path == "") | 977 | if (path == "") |
978 | goto cancelImport; | 978 | goto cancelImport; |
979 | 979 | ||
980 | ret = curDoc()->importFromText(&path, 0); | 980 | ret = curDoc()->importFromText(&path, 0); |
981 | if (ret == e_fileFormat) { | 981 | if (ret == e_fileFormat) { |
982 | KMessageBox::error(this, | 982 | KMessageBox::error(this, |
983 | i18n("Could not read file-format.\n" | 983 | i18n("Could not read file-format.\n" |
984 | "This seems to be _not_ a valid file\n" | 984 | "This seems to be _not_ a valid file\n" |
985 | "exported by PwM."), | 985 | "exported by PwM."), |
986 | i18n("invalid file-format")); | 986 | i18n("invalid file-format")); |
987 | goto cancelImport; | 987 | goto cancelImport; |
988 | } else if (ret == e_invalidArg) { | 988 | } else if (ret == e_invalidArg) { |
989 | BUG(); | 989 | BUG(); |
990 | goto cancelImport; | 990 | goto cancelImport; |
991 | } else if (ret != e_success) { | 991 | } else if (ret != e_success) { |
992 | KMessageBox::error(this, | 992 | KMessageBox::error(this, |
993 | i18n("Could not import file!\n" | 993 | i18n("Could not import file!\n" |
994 | "Do you have permission to read this file?\n" | 994 | "Do you have permission to read this file?\n" |
995 | "Do you have enough free memory?"), | 995 | "Do you have enough free memory?"), |
996 | i18n("import failed")); | 996 | i18n("import failed")); |
997 | goto cancelImport; | 997 | goto cancelImport; |
998 | } | 998 | } |
999 | setVirgin(false); | 999 | setVirgin(false); |
1000 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1000 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1001 | return true; | 1001 | return true; |
1002 | 1002 | ||
1003 | cancelImport: | 1003 | cancelImport: |
1004 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1004 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1005 | return false; | 1005 | return false; |
1006 | } | 1006 | } |
1007 | 1007 | ||
1008 | void PwM::exportToGpasman() | 1008 | void PwM::exportToGpasman() |
1009 | { | 1009 | { |
1010 | PWM_ASSERT(curDoc()); | 1010 | PWM_ASSERT(curDoc()); |
1011 | if (curDoc()->isDocEmpty()) { | 1011 | if (curDoc()->isDocEmpty()) { |
1012 | KMessageBox::information(this, | 1012 | KMessageBox::information(this, |
1013 | i18n | 1013 | i18n |
1014 | ("Sorry, there's nothing to export.\n" | 1014 | ("Sorry, there's nothing to export.\n" |
1015 | "Please first add some passwords."), | 1015 | "Please first add some passwords."), |
1016 | i18n("nothing to do")); | 1016 | i18n("nothing to do")); |
1017 | return; | 1017 | return; |
1018 | } | 1018 | } |
1019 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1019 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1020 | QString fn(KFileDialog::getSaveFileName(QString::null, | 1020 | QString fn(KFileDialog::getSaveFileName(QString::null, |
1021 | i18n("*|Gpasman or Kpasman file"), | 1021 | i18n("*|Gpasman or Kpasman file"), |
1022 | this)); | 1022 | this)); |
1023 | if (fn == "") { | 1023 | if (fn == "") { |
1024 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1024 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1025 | return; | 1025 | return; |
1026 | } | 1026 | } |
1027 | 1027 | ||
1028 | PwMerror ret = curDoc()->exportToGpasman(&fn); | 1028 | PwMerror ret = curDoc()->exportToGpasman(&fn); |
1029 | if (ret != e_success) { | 1029 | if (ret != e_success) { |
1030 | if (ret == e_noPw) { | 1030 | if (ret == e_noPw) { |
1031 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1031 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1032 | return; | 1032 | return; |
1033 | } | 1033 | } |
1034 | KMessageBox::error(this, | 1034 | KMessageBox::error(this, |
1035 | i18n("Error: Couldn't write to file.\n" | 1035 | i18n("Error: Couldn't write to file.\n" |
1036 | "Please check if you have permission to write " | 1036 | "Please check if you have permission to write " |
1037 | "to the file in that directory."), | 1037 | "to the file in that directory."), |
1038 | i18n("error while writing")); | 1038 | i18n("error while writing")); |
1039 | } else | 1039 | } else |
1040 | showStatMsg(i18n("Successfully exported data.")); | 1040 | showStatMsg(i18n("Successfully exported data.")); |
1041 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1041 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1042 | } | 1042 | } |
1043 | 1043 | ||
1044 | 1044 | ||
1045 | 1045 | ||
1046 | void PwM::exportToCsv() | 1046 | void PwM::exportToCsv() |
1047 | { | 1047 | { |
1048 | PWM_ASSERT(curDoc()); | 1048 | PWM_ASSERT(curDoc()); |
1049 | if (curDoc()->isDocEmpty()) { | 1049 | if (curDoc()->isDocEmpty()) { |
1050 | KMessageBox::information(this, | 1050 | KMessageBox::information(this, |
1051 | i18n | 1051 | i18n |
1052 | ("Sorry, there is nothing to export;\n" | 1052 | ("Sorry, there is nothing to export;\n" |
1053 | "please add some passwords first."), | 1053 | "please add some passwords first."), |
1054 | i18n("Nothing to Do")); | 1054 | i18n("Nothing to Do")); |
1055 | return; | 1055 | return; |
1056 | } | 1056 | } |
1057 | 1057 | ||
1058 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1058 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1059 | QString fn(KFileDialog::getSaveFileName("*.csv", i18n("*|CSV Text File"), this)); | 1059 | QString fn(KFileDialog::getSaveFileName("*.csv", i18n("*|CSV Text File"), this)); |
1060 | if (fn.isEmpty()) { | 1060 | if (fn.isEmpty()) { |
1061 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1061 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1062 | return; | 1062 | return; |
1063 | } | 1063 | } |
1064 | 1064 | ||
1065 | Csv csv(this); | 1065 | Csv csv(this); |
1066 | if (!csv.exportData(fn, curDoc())) { | 1066 | if (!csv.exportData(fn, curDoc())) { |
1067 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1067 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1068 | showStatMsg(i18n("CSV file export failed.")); | 1068 | showStatMsg(i18n("CSV file export failed.")); |
1069 | return; | 1069 | return; |
1070 | } | 1070 | } |
1071 | showStatMsg(i18n("Successfully exported data.")); | 1071 | showStatMsg(i18n("Successfully exported data.")); |
1072 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1072 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1073 | } | 1073 | } |
1074 | 1074 | ||
1075 | bool PwM::importCsv() | 1075 | bool PwM::importCsv() |
1076 | { | 1076 | { |
1077 | Csv csv(this); | 1077 | Csv csv(this); |
1078 | if (!isVirgin()) { | 1078 | if (!isVirgin()) { |
1079 | if (KMessageBox::questionYesNo(this, | 1079 | if (KMessageBox::questionYesNo(this, |
1080 | i18n("Do you want to import the data\n" | 1080 | i18n("Do you want to import the data\n" |
1081 | "into the current document? (If you\n" | 1081 | "into the current document? (If you\n" |
1082 | "select \"no\", a new document will be\n" | 1082 | "select \"no\", a new document will be\n" |
1083 | "opened.)"), | 1083 | "opened.)"), |
1084 | i18n("Import into This Document?")) | 1084 | i18n("Import into This Document?")) |
1085 | == KMessageBox::No) { | 1085 | == KMessageBox::No) { |
1086 | // import the data to a new window. | 1086 | // import the data to a new window. |
1087 | PwM *newInstance = init->createMainWnd(); | 1087 | PwM *newInstance = init->createMainWnd(); |
1088 | bool ok = newInstance->importCsv(); | 1088 | bool ok = newInstance->importCsv(); |
1089 | if (!ok) { | 1089 | if (!ok) { |
1090 | newInstance->setForceQuit(true); | 1090 | newInstance->setForceQuit(true); |
1091 | delete_and_null(newInstance); | 1091 | delete_and_null(newInstance); |
1092 | } | 1092 | } |
1093 | return ok; | 1093 | return ok; |
1094 | } | 1094 | } |
1095 | } | 1095 | } |
1096 | 1096 | ||
1097 | QString filename = KFileDialog::getOpenFileName("*.csv", i18n("*|CSV Text File"), this); | 1097 | QString filename = KFileDialog::getOpenFileName("*.csv", i18n("*|CSV Text File"), this); |
1098 | if (filename.isEmpty()) | 1098 | if (filename.isEmpty()) |
1099 | return false; | 1099 | return false; |
1100 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1100 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1101 | if (!csv.importData(filename, curDoc())) { | 1101 | if (!csv.importData(filename, curDoc())) { |
1102 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1102 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1103 | showStatMsg(i18n("CSV file import failed.")); | 1103 | showStatMsg(i18n("CSV file import failed.")); |
1104 | return false; | 1104 | return false; |
1105 | } | 1105 | } |
1106 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1106 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1107 | KMessageBox::information(this, | 1107 | KMessageBox::information(this, |
1108 | i18n("Successfully imported the CSV data\n" | 1108 | i18n("Successfully imported the CSV data\n" |
1109 | "into the current document."), i18n("Successfully Imported")); | 1109 | "into the current document."), i18n("Successfully Imported")); |
1110 | showStatMsg(i18n("Successfully imported")); | 1110 | showStatMsg(i18n("Successfully imported")); |
1111 | setVirgin(false); | 1111 | setVirgin(false); |
1112 | return true; | 1112 | return true; |
1113 | } | 1113 | } |
1114 | 1114 | ||
1115 | 1115 | ||
1116 | void PwM::exportToKWallet() | 1116 | void PwM::exportToKWallet() |
1117 | { | 1117 | { |
1118 | #ifdef CONFIG_KWALLETIF | 1118 | #ifdef CONFIG_KWALLETIF |
1119 | if (!checkAndAskForKWalletEmu()) | 1119 | if (!checkAndAskForKWalletEmu()) |
1120 | return; | 1120 | return; |
1121 | PWM_ASSERT(curDoc()); | 1121 | PWM_ASSERT(curDoc()); |
1122 | if (curDoc()->isDocEmpty()) { | 1122 | if (curDoc()->isDocEmpty()) { |
1123 | KMessageBox::information(this, | 1123 | KMessageBox::information(this, |
1124 | i18n | 1124 | i18n |
1125 | ("Sorry, there's nothing to export.\n" | 1125 | ("Sorry, there's nothing to export.\n" |
1126 | "Please first add some passwords."), | 1126 | "Please first add some passwords."), |
1127 | i18n("nothing to do")); | 1127 | i18n("nothing to do")); |
1128 | init->initKWalletEmu(); | 1128 | init->initKWalletEmu(); |
1129 | return; | 1129 | return; |
1130 | } | 1130 | } |
1131 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1131 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1132 | KWalletIf walletIf(this); | 1132 | KWalletIf walletIf(this); |
1133 | if (walletIf.kwalletExport(curDoc())) { | 1133 | if (walletIf.kwalletExport(curDoc())) { |
1134 | KMessageBox::information(this, | 1134 | KMessageBox::information(this, |
1135 | i18n("Successfully exported the data of the current " | 1135 | i18n("Successfully exported the data of the current " |
1136 | "document to KWallet."), | 1136 | "document to KWallet."), |
1137 | i18n("Successfully exported data.")); | 1137 | i18n("Successfully exported data.")); |
1138 | showStatMsg(i18n("Successfully exported data.")); | 1138 | showStatMsg(i18n("Successfully exported data.")); |
1139 | } | 1139 | } |
1140 | init->initKWalletEmu(); | 1140 | init->initKWalletEmu(); |
1141 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1141 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1142 | #endif // CONFIG_KWALLETIF | 1142 | #endif // CONFIG_KWALLETIF |
1143 | } | 1143 | } |
1144 | 1144 | ||
1145 | bool PwM::importFromGpasman() | 1145 | bool PwM::importFromGpasman() |
1146 | { | 1146 | { |
1147 | if (!isVirgin()) { | 1147 | if (!isVirgin()) { |
1148 | if (KMessageBox::questionYesNo(this, | 1148 | if (KMessageBox::questionYesNo(this, |
1149 | i18n("Do you want to import the data\n" | 1149 | i18n("Do you want to import the data\n" |
1150 | "into the current document? (If you\n" | 1150 | "into the current document? (If you\n" |
1151 | "select \"no\", a new document will be\n" | 1151 | "select \"no\", a new document will be\n" |
1152 | "opened.)"), | 1152 | "opened.)"), |
1153 | i18n("import into this document?")) | 1153 | i18n("import into this document?")) |
1154 | == KMessageBox::No) { | 1154 | == KMessageBox::No) { |
1155 | // import the data to a new window. | 1155 | // import the data to a new window. |
1156 | PwM *newInstance = init->createMainWnd(); | 1156 | PwM *newInstance = init->createMainWnd(); |
1157 | bool ok = newInstance->importFromGpasman(); | 1157 | bool ok = newInstance->importFromGpasman(); |
1158 | if (!ok) { | 1158 | if (!ok) { |
1159 | newInstance->setForceQuit(true); | 1159 | newInstance->setForceQuit(true); |
1160 | delete_and_null(newInstance); | 1160 | delete_and_null(newInstance); |
1161 | } | 1161 | } |
1162 | return ok; | 1162 | return ok; |
1163 | } | 1163 | } |
1164 | } | 1164 | } |
1165 | 1165 | ||
1166 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1166 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1167 | PwMerror ret; | 1167 | PwMerror ret; |
1168 | QString path(KFileDialog::getOpenFileName(QString::null, | 1168 | QString path(KFileDialog::getOpenFileName(QString::null, |
1169 | i18n("*|Gpasman or Kpasman file"), this)); | 1169 | i18n("*|Gpasman or Kpasman file"), this)); |
1170 | if (path == "") | 1170 | if (path == "") |
1171 | goto cancelImport; | 1171 | goto cancelImport; |
1172 | ret = curDoc()->importFromGpasman(&path); | 1172 | ret = curDoc()->importFromGpasman(&path); |
1173 | if (ret == e_wrongPw) { | 1173 | if (ret == e_wrongPw) { |
1174 | if (KMessageBox::questionYesNo(this, | 1174 | if (KMessageBox::questionYesNo(this, |
1175 | i18n | 1175 | i18n |
1176 | ("This is probably the wrong master-password\n" | 1176 | ("This is probably the wrong master-password\n" |
1177 | "you have typed in.\n" | 1177 | "you have typed in.\n" |
1178 | "There is no real way to determine the\n" | 1178 | "There is no real way to determine the\n" |
1179 | "correctness of the password in the Gpasman\n" | 1179 | "correctness of the password in the Gpasman\n" |
1180 | "file-format. But I think this\n" | 1180 | "file-format. But I think this\n" |
1181 | "password ist wrong.\n" | 1181 | "password ist wrong.\n" |
1182 | "Do you want to continue nevertheless?"), | 1182 | "Do you want to continue nevertheless?"), |
1183 | i18n("password error")) | 1183 | i18n("password error")) |
1184 | == KMessageBox::No) { | 1184 | == KMessageBox::No) { |
1185 | goto cancelImport; | 1185 | goto cancelImport; |
1186 | } | 1186 | } |
1187 | } else if (ret != e_success) { | 1187 | } else if (ret != e_success) { |
1188 | KMessageBox::error(this, | 1188 | KMessageBox::error(this, |
1189 | i18n("Could not import file!\n" | 1189 | i18n("Could not import file!\n" |
1190 | "Do you have permission to read this file?"), | 1190 | "Do you have permission to read this file?"), |
1191 | i18n("import failed")); | 1191 | i18n("import failed")); |
1192 | goto cancelImport; | 1192 | goto cancelImport; |
1193 | } | 1193 | } |
1194 | setVirgin(false); | 1194 | setVirgin(false); |
1195 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1195 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1196 | return true; | 1196 | return true; |
1197 | 1197 | ||
1198 | cancelImport: | 1198 | cancelImport: |
1199 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1199 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1200 | return false; | 1200 | return false; |
1201 | } | 1201 | } |
1202 | 1202 | ||
1203 | #ifdef CONFIG_KWALLETIF | 1203 | #ifdef CONFIG_KWALLETIF |
1204 | bool PwM::checkAndAskForKWalletEmu() | 1204 | bool PwM::checkAndAskForKWalletEmu() |
1205 | { | 1205 | { |
1206 | if (init->kwalletEmu()) { | 1206 | if (init->kwalletEmu()) { |
1207 | /* KWallet emulation is enabled. We can't import/export | 1207 | /* KWallet emulation is enabled. We can't import/export |
1208 | * data from/to it, while emulation is active. | 1208 | * data from/to it, while emulation is active. |
1209 | */ | 1209 | */ |
1210 | if (KMessageBox::questionYesNo(this, | 1210 | if (KMessageBox::questionYesNo(this, |
1211 | i18n("KWallet emulation is enabled.\n" | 1211 | i18n("KWallet emulation is enabled.\n" |
1212 | "You can't import or export data from/to " | 1212 | "You can't import or export data from/to " |
1213 | "the original KWallet, while the emulation " | 1213 | "the original KWallet, while the emulation " |
1214 | "is active.\n" | 1214 | "is active.\n" |
1215 | "Do you want to tempoarly disable the KWallet emulation?"), | 1215 | "Do you want to tempoarly disable the KWallet emulation?"), |
1216 | i18n("Tempoarly disable KWallet emulation?")) | 1216 | i18n("Tempoarly disable KWallet emulation?")) |
1217 | == KMessageBox::Yes) { | 1217 | == KMessageBox::Yes) { |
1218 | init->initKWalletEmu(true); | 1218 | init->initKWalletEmu(true); |
1219 | PWM_ASSERT(!init->kwalletEmu()); | 1219 | PWM_ASSERT(!init->kwalletEmu()); |
1220 | return true; | 1220 | return true; |
1221 | } | 1221 | } |
1222 | return false; | 1222 | return false; |
1223 | } | 1223 | } |
1224 | return true; | 1224 | return true; |
1225 | } | 1225 | } |
1226 | #endif // CONFIG_KWALLETIF | 1226 | #endif // CONFIG_KWALLETIF |
1227 | 1227 | ||
1228 | bool PwM::importKWallet() | 1228 | bool PwM::importKWallet() |
1229 | { | 1229 | { |
1230 | #ifdef CONFIG_KWALLETIF | 1230 | #ifdef CONFIG_KWALLETIF |
1231 | if (!checkAndAskForKWalletEmu()) | 1231 | if (!checkAndAskForKWalletEmu()) |
1232 | return false; | 1232 | return false; |
1233 | KWalletIf walletIf(this); | 1233 | KWalletIf walletIf(this); |
1234 | if (!isVirgin()) { | 1234 | if (!isVirgin()) { |
1235 | if (KMessageBox::questionYesNo(this, | 1235 | if (KMessageBox::questionYesNo(this, |
1236 | i18n("Do you want to import the data " | 1236 | i18n("Do you want to import the data " |
1237 | "into the current document? (If you " | 1237 | "into the current document? (If you " |
1238 | "select \"no\", a new document will be " | 1238 | "select \"no\", a new document will be " |
1239 | "opened.)"), | 1239 | "opened.)"), |
1240 | i18n("import into this document?")) | 1240 | i18n("import into this document?")) |
1241 | == KMessageBox::No) { | 1241 | == KMessageBox::No) { |
1242 | // import the data to a new window. | 1242 | // import the data to a new window. |
1243 | PwM *newInstance = init->createMainWnd(); | 1243 | PwM *newInstance = init->createMainWnd(); |
1244 | bool ok = newInstance->importKWallet(); | 1244 | bool ok = newInstance->importKWallet(); |
1245 | if (!ok) { | 1245 | if (!ok) { |
1246 | newInstance->setForceQuit(true); | 1246 | newInstance->setForceQuit(true); |
1247 | delete_and_null(newInstance); | 1247 | delete_and_null(newInstance); |
1248 | goto exit_fail; | 1248 | goto exit_fail; |
1249 | } else { | 1249 | } else { |
1250 | goto exit_ok; | 1250 | goto exit_ok; |
1251 | } | 1251 | } |
1252 | } | 1252 | } |
1253 | } | 1253 | } |
1254 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1254 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1255 | if (!walletIf.kwalletImport(curDoc())) { | 1255 | if (!walletIf.kwalletImport(curDoc())) { |
1256 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1256 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1257 | showStatMsg(i18n("KWallet import failed")); | 1257 | showStatMsg(i18n("KWallet import failed")); |
1258 | goto exit_fail; | 1258 | goto exit_fail; |
1259 | } | 1259 | } |
1260 | KMessageBox::information(this, | 1260 | KMessageBox::information(this, |
1261 | i18n("Successfully imported the KWallet data " | 1261 | i18n("Successfully imported the KWallet data " |
1262 | "into the current document."), | 1262 | "into the current document."), |
1263 | i18n("successfully imported")); | 1263 | i18n("successfully imported")); |
1264 | showStatMsg(i18n("successfully imported")); | 1264 | showStatMsg(i18n("successfully imported")); |
1265 | setVirgin(false); | 1265 | setVirgin(false); |
1266 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1266 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1267 | 1267 | ||
1268 | exit_ok: | 1268 | exit_ok: |
1269 | init->initKWalletEmu(); | 1269 | init->initKWalletEmu(); |
1270 | return true; | 1270 | return true; |
1271 | 1271 | ||
1272 | exit_fail: | 1272 | exit_fail: |
1273 | init->initKWalletEmu(); | 1273 | init->initKWalletEmu(); |
1274 | #endif // CONFIG_KWALLETIF | 1274 | #endif // CONFIG_KWALLETIF |
1275 | return false; | 1275 | return false; |
1276 | } | 1276 | } |
1277 | 1277 | ||
1278 | void PwM::print_slot() | 1278 | void PwM::print_slot() |
1279 | { | 1279 | { |
1280 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1280 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1281 | #ifndef PWM_EMBEDDED | 1281 | #ifndef PWM_EMBEDDED |
1282 | PwMPrint p(curDoc(), this); | 1282 | PwMPrint p(curDoc(), this); |
1283 | p.printNow(); | 1283 | p.printNow(); |
1284 | #else | 1284 | #else |
1285 | qDebug("PwM::print_slot , PRINTING IS NOT IMPLEMENTED"); | 1285 | qDebug("PwM::print_slot , PRINTING IS NOT IMPLEMENTED"); |
1286 | #endif | 1286 | #endif |
1287 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1287 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1288 | } | 1288 | } |
1289 | 1289 | ||
1290 | void PwM::genNewCard_slot() | 1290 | void PwM::genNewCard_slot() |
1291 | { | 1291 | { |
1292 | #ifdef CONFIG_KEYCARD | 1292 | #ifdef CONFIG_KEYCARD |
1293 | init->keycard()->genNewCard(); | 1293 | init->keycard()->genNewCard(); |
1294 | #endif | 1294 | #endif |
1295 | } | 1295 | } |
1296 | 1296 | ||
1297 | void PwM::eraseCard_slot() | 1297 | void PwM::eraseCard_slot() |
1298 | { | 1298 | { |
1299 | #ifdef CONFIG_KEYCARD | 1299 | #ifdef CONFIG_KEYCARD |
1300 | init->keycard()->eraseCard(); | 1300 | init->keycard()->eraseCard(); |
1301 | #endif | 1301 | #endif |
1302 | } | 1302 | } |
1303 | 1303 | ||
1304 | void PwM::readCardId_slot() | 1304 | void PwM::readCardId_slot() |
1305 | { | 1305 | { |
1306 | #ifdef CONFIG_KEYCARD | 1306 | #ifdef CONFIG_KEYCARD |
1307 | init->keycard()->displayKey(); | 1307 | init->keycard()->displayKey(); |
1308 | #endif | 1308 | #endif |
1309 | } | 1309 | } |
1310 | 1310 | ||
1311 | void PwM::makeCardBackup_slot() | 1311 | void PwM::makeCardBackup_slot() |
1312 | { | 1312 | { |
1313 | #ifdef CONFIG_KEYCARD | 1313 | #ifdef CONFIG_KEYCARD |
1314 | init->keycard()->makeBackupImage(); | 1314 | init->keycard()->makeBackupImage(); |
1315 | #endif | 1315 | #endif |
1316 | } | 1316 | } |
1317 | 1317 | ||
1318 | void PwM::replayCardBackup_slot() | 1318 | void PwM::replayCardBackup_slot() |
1319 | { | 1319 | { |
1320 | #ifdef CONFIG_KEYCARD | 1320 | #ifdef CONFIG_KEYCARD |
1321 | init->keycard()->replayBackupImage(); | 1321 | init->keycard()->replayBackupImage(); |
1322 | #endif | 1322 | #endif |
1323 | } | 1323 | } |
1324 | 1324 | ||
1325 | void PwM::execLauncher_slot() | 1325 | void PwM::execLauncher_slot() |
1326 | { | 1326 | { |
1327 | PWM_ASSERT(curDoc()); | 1327 | PWM_ASSERT(curDoc()); |
1328 | if (curDoc()->isDeepLocked()) | 1328 | if (curDoc()->isDeepLocked()) |
1329 | return; | 1329 | return; |
1330 | unsigned int curEntryIndex; | 1330 | unsigned int curEntryIndex; |
1331 | if (!view->getCurEntryIndex(&curEntryIndex)) | 1331 | if (!view->getCurEntryIndex(&curEntryIndex)) |
1332 | return; | 1332 | return; |
1333 | bool ret = curDoc()->execLauncher(view->getCurrentCategory(), | 1333 | bool ret = curDoc()->execLauncher(view->getCurrentCategory(), |
1334 | curEntryIndex); | 1334 | curEntryIndex); |
1335 | if (ret) | 1335 | if (ret) |
1336 | showStatMsg(i18n("Executed the \"Launcher\".")); | 1336 | showStatMsg(i18n("Executed the \"Launcher\".")); |
1337 | else | 1337 | else |
1338 | showStatMsg(i18n("ERROR: Couldn't execute the \"Launcher\"!")); | 1338 | showStatMsg(i18n("ERROR: Couldn't execute the \"Launcher\"!")); |
1339 | } | 1339 | } |
1340 | 1340 | ||
1341 | void PwM::goToURL_slot() | 1341 | void PwM::goToURL_slot() |
1342 | { | 1342 | { |
1343 | PWM_ASSERT(curDoc()); | 1343 | PWM_ASSERT(curDoc()); |
1344 | if (curDoc()->isDeepLocked()) | 1344 | if (curDoc()->isDeepLocked()) |
1345 | return; | 1345 | return; |
1346 | unsigned int curEntryIndex; | 1346 | unsigned int curEntryIndex; |
1347 | if (!view->getCurEntryIndex(&curEntryIndex)) | 1347 | if (!view->getCurEntryIndex(&curEntryIndex)) |
1348 | return; | 1348 | return; |
1349 | bool ret = curDoc()->goToURL(view->getCurrentCategory(), | 1349 | bool ret = curDoc()->goToURL(view->getCurrentCategory(), |
1350 | curEntryIndex); | 1350 | curEntryIndex); |
1351 | if (ret) | 1351 | if (ret) |
1352 | showStatMsg(i18n("started browser with current URL.")); | 1352 | showStatMsg(i18n("started browser with current URL.")); |
1353 | else | 1353 | else |
1354 | showStatMsg(i18n("ERROR: Couldn't start browser! Maybe invalid URL?")); | 1354 | showStatMsg(i18n("ERROR: Couldn't start browser! Maybe invalid URL?")); |
1355 | } | 1355 | } |
1356 | 1356 | ||
1357 | void PwM::copyToClipboard(const QString &s) | 1357 | void PwM::copyToClipboard(const QString &s) |
1358 | { | 1358 | { |
1359 | QClipboard *cb = QApplication::clipboard(); | 1359 | QClipboard *cb = QApplication::clipboard(); |
1360 | #ifndef PWM_EMBEDDED | 1360 | #ifndef PWM_EMBEDDED |
1361 | if (cb->supportsSelection()) | 1361 | if (cb->supportsSelection()) |
1362 | cb->setText(s, QClipboard::Selection); | 1362 | cb->setText(s, QClipboard::Selection); |
1363 | cb->setText(s, QClipboard::Clipboard); | 1363 | cb->setText(s, QClipboard::Clipboard); |
1364 | #else | 1364 | #else |
1365 | cb->setText(s); | 1365 | cb->setText(s); |
1366 | 1366 | ||
1367 | #endif | 1367 | #endif |
1368 | 1368 | ||
1369 | } | 1369 | } |
1370 | 1370 | ||
1371 | 1371 | ||
1372 | void PwM::showStatMsg(const QString &msg) | 1372 | void PwM::showStatMsg(const QString &msg) |
1373 | { | 1373 | { |
1374 | #ifdef DESKTOP_VERSION | 1374 | #ifdef DESKTOP_VERSION |
1375 | statusBar()->message(msg, STATUSBAR_MSG_TIMEOUT * 1000); | 1375 | statusBar()->message(msg, STATUSBAR_MSG_TIMEOUT * 1000); |
1376 | #else | 1376 | #else |
1377 | qDebug("Statusbar : %s",msg.latin1()); | 1377 | qDebug("Statusbar : %s",msg.latin1()); |
1378 | Global::statusMessage(msg); | 1378 | Global::statusMessage(msg); |
1379 | #endif | 1379 | #endif |
1380 | } | 1380 | } |
1381 | 1381 | ||
1382 | void PwM::focusInEvent(QFocusEvent *e) | 1382 | void PwM::focusInEvent(QFocusEvent *e) |
1383 | { | 1383 | { |
1384 | if (e->gotFocus()) { | 1384 | if (e->gotFocus()) { |
1385 | emit gotFocus(this); | 1385 | emit gotFocus(this); |
1386 | } else if (e->lostFocus()) { | 1386 | } else if (e->lostFocus()) { |
1387 | emit lostFocus(this); | 1387 | emit lostFocus(this); |
1388 | } | 1388 | } |
1389 | } | 1389 | } |
1390 | 1390 | ||
1391 | 1391 | ||
1392 | #ifdef PWM_EMBEDDED | 1392 | #ifdef PWM_EMBEDDED |
1393 | 1393 | ||
1394 | void PwM::whatsnew_slot() | 1394 | void PwM::whatsnew_slot() |
1395 | { | 1395 | { |
1396 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 1396 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
1397 | } | 1397 | } |
1398 | 1398 | ||
1399 | void PwM::showLicense_slot() | 1399 | void PwM::showLicense_slot() |
1400 | { | 1400 | { |
1401 | KApplication::showLicence(); | 1401 | KApplication::showLicence(); |
1402 | } | 1402 | } |
1403 | 1403 | ||
1404 | void PwM::faq_slot() | 1404 | void PwM::faq_slot() |
1405 | { | 1405 | { |
1406 | KApplication::showFile( "PWM/Pi FAQ", "kdepim/pwmanager/pwmanagerFAQ.txt" ); | 1406 | KApplication::showFile( "PWM/Pi FAQ", "kdepim/pwmanager/pwmanagerFAQ.txt" ); |
1407 | } | 1407 | } |
1408 | 1408 | ||
1409 | void PwM::syncHowTo_slot() | 1409 | void PwM::syncHowTo_slot() |
1410 | { | 1410 | { |
1411 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 1411 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
1412 | } | 1412 | } |
1413 | 1413 | ||
1414 | 1414 | ||
1415 | void PwM::createAboutData_slot() | 1415 | void PwM::createAboutData_slot() |
1416 | { | 1416 | { |
1417 | QString version; | 1417 | QString version; |
1418 | #include <../version> | 1418 | #include <../version> |
1419 | ; | 1419 | ; |
1420 | QMessageBox::about( this, "About PwManager/Pi", | 1420 | QMessageBox::about( this, "About PwManager/Pi", |
1421 | "PwManager/Platform-independent\n" | 1421 | "PwManager/Platform-independent\n" |
1422 | "(PWM/Pi) " +version + " - " + | 1422 | "(PWM/Pi) " +version + " - " + |
1423 | #ifdef DESKTOP_VERSION | 1423 | #ifdef DESKTOP_VERSION |
1424 | "Desktop Edition\n" | 1424 | "Desktop Edition\n" |
1425 | #else | 1425 | #else |
1426 | "PDA-Edition\n" | 1426 | "PDA-Edition\n" |
1427 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 1427 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
1428 | #endif | 1428 | #endif |
1429 | 1429 | ||
1430 | "(c) 2004 Ulf Schenk\n" | 1430 | "(c) 2004 Ulf Schenk\n" |
1431 | "(c) 2004 Lutz Rogowski\n" | 1431 | "(c) 2004 Lutz Rogowski\n" |
1432 | "(c) 1997-2004, The KDE PIM Team\n" | 1432 | "(c) 1997-2004, The KDE PIM Team\n" |
1433 | 1433 | ||
1434 | "(c) Michael Buesch - main programming\nand current maintainer\nmbuesch@freenet.de\n" | 1434 | "(c) Michael Buesch - main programming\nand current maintainer\nmbuesch@freenet.de\n" |
1435 | "Matt Scifo - mscifo@o1.com\n" | 1435 | "Matt Scifo - mscifo@o1.com\n" |
1436 | "Elias Probst - elias.probst@gmx.de\n" | 1436 | "Elias Probst - elias.probst@gmx.de\n" |
1437 | "George Staikos - staikos@kde.org\n" | 1437 | "George Staikos - staikos@kde.org\n" |
1438 | "Matthew Palmer - mjp16@uow.edu.au\n" | 1438 | "Matthew Palmer - mjp16@uow.edu.au\n" |
1439 | "Olivier Sessink - gpasman@nl.linux.org\n" | 1439 | "Olivier Sessink - gpasman@nl.linux.org\n" |
1440 | "The libgcrypt developers -\nBlowfish and SHA1 algorithms\nftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/\n" | 1440 | "The libgcrypt developers -\nBlowfish and SHA1 algorithms\nftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/\n" |
1441 | "Troy Engel - tengel@sonic.net\n" | 1441 | "Troy Engel - tengel@sonic.net\n" |
1442 | "Wickey - wickey@gmx.at\n" | 1442 | "Wickey - wickey@gmx.at\n" |
1443 | "Ian MacGregor - original documentation author.\n" | 1443 | "Ian MacGregor - original documentation author.\n" |
1444 | ); | 1444 | ); |
1445 | } | 1445 | } |
1446 | 1446 | ||
1447 | 1447 | ||
1448 | //this are the overwritten callbackmethods from the syncinterface | 1448 | //this are the overwritten callbackmethods from the syncinterface |
1449 | bool PwM::sync(KSyncManager* manager, QString filename, int mode) | 1449 | bool PwM::sync(KSyncManager* manager, QString filename, int mode) |
1450 | { | 1450 | { |
1451 | PWM_ASSERT(curDoc()); | 1451 | PWM_ASSERT(curDoc()); |
1452 | 1452 | ||
1453 | bool ret = curDoc()->sync(manager, filename, mode); | 1453 | bool ret = curDoc()->sync(manager, filename, mode); |
1454 | 1454 | ||
1455 | qDebug("PwM::sync save now: ret=%i", ret); | 1455 | qDebug("PwM::sync save now: ret=%i", ret); |
1456 | 1456 | ||
1457 | if (ret == true) { | 1457 | if (ret == true) { |
1458 | //US BUG: what can we call here to update the view of the current doc? | 1458 | //US BUG: what can we call here to update the view of the current doc? |
1459 | //mViewManager->refreshView(); | 1459 | //mViewManager->refreshView(); |
1460 | 1460 | ||
1461 | //US curDoc()->sync sets the dirtyFlag in case the sync was successfull. | 1461 | //US curDoc()->sync sets the dirtyFlag in case the sync was successfull. |
1462 | save(); | 1462 | save(); |
1463 | } | 1463 | } |
1464 | 1464 | ||
1465 | return ret; | 1465 | return ret; |
1466 | } | 1466 | } |
1467 | |||
1468 | void PwM::removeSyncInfo( QString syncProfile) | ||
1469 | { | ||
1470 | qDebug("PWM::not implemented: removeSyncInfo for profile %s ", syncProfile.latin1()); | ||
1471 | } | ||
1472 | |||
1467 | #endif | 1473 | #endif |
1468 | 1474 | ||
1469 | 1475 | ||
1470 | #ifndef PWM_EMBEDDED | 1476 | #ifndef PWM_EMBEDDED |
1471 | #include "pwm.moc" | 1477 | #include "pwm.moc" |
1472 | #endif | 1478 | #endif |
diff --git a/pwmanager/pwmanager/pwm.h b/pwmanager/pwmanager/pwm.h index 5822d59..fb34bca 100644 --- a/pwmanager/pwmanager/pwm.h +++ b/pwmanager/pwmanager/pwm.h | |||
@@ -1,297 +1,298 @@ | |||
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 | /** (de)activate the "change master pw" button in the menu-bar */ | 168 | /** (de)activate the "change master pw" button in the menu-bar */ |
169 | void activateMpButton(bool activate = true); | 169 | void activateMpButton(bool activate = true); |
170 | /** generate a new chipcard */ | 170 | /** generate a new chipcard */ |
171 | void genNewCard_slot(); | 171 | void genNewCard_slot(); |
172 | /** completely erase the current card */ | 172 | /** completely erase the current card */ |
173 | void eraseCard_slot(); | 173 | void eraseCard_slot(); |
174 | /** returns the ID number of the current card */ | 174 | /** returns the ID number of the current card */ |
175 | void readCardId_slot(); | 175 | void readCardId_slot(); |
176 | /** make backup image of the current card */ | 176 | /** make backup image of the current card */ |
177 | void makeCardBackup_slot(); | 177 | void makeCardBackup_slot(); |
178 | /** write backup image to current card */ | 178 | /** write backup image to current card */ |
179 | void replayCardBackup_slot(); | 179 | void replayCardBackup_slot(); |
180 | 180 | ||
181 | #ifdef PWM_EMBEDDED | 181 | #ifdef PWM_EMBEDDED |
182 | void whatsnew_slot(); | 182 | void whatsnew_slot(); |
183 | void showLicense_slot(); | 183 | void showLicense_slot(); |
184 | void faq_slot(); | 184 | void faq_slot(); |
185 | void createAboutData_slot(); | 185 | void createAboutData_slot(); |
186 | void syncHowTo_slot(); | 186 | void syncHowTo_slot(); |
187 | #endif | 187 | #endif |
188 | 188 | ||
189 | protected: | 189 | protected: |
190 | /** is this window virgin? */ | 190 | /** is this window virgin? */ |
191 | bool isVirgin() | 191 | bool isVirgin() |
192 | { return virgin; } | 192 | { return virgin; } |
193 | /** add/remove virginity */ | 193 | /** add/remove virginity */ |
194 | void setVirgin(bool v); | 194 | void setVirgin(bool v); |
195 | /** initialize the menubar */ | 195 | /** initialize the menubar */ |
196 | void initMenubar(); | 196 | void initMenubar(); |
197 | /** initialize the toolbar */ | 197 | /** initialize the toolbar */ |
198 | void initToolbar(); | 198 | void initToolbar(); |
199 | /** initialize the window-metrics */ | 199 | /** initialize the window-metrics */ |
200 | void initMetrics(); | 200 | void initMetrics(); |
201 | /** close-event */ | 201 | /** close-event */ |
202 | void closeEvent(QCloseEvent *e); | 202 | void closeEvent(QCloseEvent *e); |
203 | /** creates a new PwM-ListView and returns it */ | 203 | /** creates a new PwM-ListView and returns it */ |
204 | PwMView * makeNewListView(PwMDoc *doc); | 204 | PwMView * makeNewListView(PwMDoc *doc); |
205 | /** Window hide-event */ | 205 | /** Window hide-event */ |
206 | void hideEvent(QHideEvent *); | 206 | void hideEvent(QHideEvent *); |
207 | /** is this window minimized? */ | 207 | /** is this window minimized? */ |
208 | bool isMinimized() | 208 | bool isMinimized() |
209 | { | 209 | { |
210 | #ifndef PWM_EMBEDDED | 210 | #ifndef PWM_EMBEDDED |
211 | #if KDE_VERSION >= KDE_MAKE_VERSION(3, 2, 0) | 211 | #if KDE_VERSION >= KDE_MAKE_VERSION(3, 2, 0) |
212 | return KWin::windowInfo(winId()).isMinimized(); | 212 | return KWin::windowInfo(winId()).isMinimized(); |
213 | #else // KDE_VERSION | 213 | #else // KDE_VERSION |
214 | return KWin::info(winId()).isIconified(); | 214 | return KWin::info(winId()).isIconified(); |
215 | #endif // KDE_VERSION | 215 | #endif // KDE_VERSION |
216 | #else | 216 | #else |
217 | return false; | 217 | return false; |
218 | #endif | 218 | #endif |
219 | } | 219 | } |
220 | /** window got the focus */ | 220 | /** window got the focus */ |
221 | void focusInEvent(QFocusEvent *e); | 221 | void focusInEvent(QFocusEvent *e); |
222 | /** update the caption string */ | 222 | /** update the caption string */ |
223 | void updateCaption(); | 223 | void updateCaption(); |
224 | #ifdef CONFIG_KWALLETIF | 224 | #ifdef CONFIG_KWALLETIF |
225 | /** check if kwalletemu is enabled and ask the user what to do */ | 225 | /** check if kwalletemu is enabled and ask the user what to do */ |
226 | bool checkAndAskForKWalletEmu(); | 226 | bool checkAndAskForKWalletEmu(); |
227 | #endif // CONFIG_KWALLETIF | 227 | #endif // CONFIG_KWALLETIF |
228 | 228 | ||
229 | protected slots: | 229 | protected slots: |
230 | /** doc got closed */ | 230 | /** doc got closed */ |
231 | void docClosed(PwMDoc *doc); | 231 | void docClosed(PwMDoc *doc); |
232 | 232 | ||
233 | signals: | 233 | signals: |
234 | /** window got closed (by user or someone else) */ | 234 | /** window got closed (by user or someone else) */ |
235 | void closed(PwM *wnd); | 235 | void closed(PwM *wnd); |
236 | /** window got the focus (was brought to foreground) */ | 236 | /** window got the focus (was brought to foreground) */ |
237 | void gotFocus(PwM *wnd); | 237 | void gotFocus(PwM *wnd); |
238 | /** window lost the focus */ | 238 | /** window lost the focus */ |
239 | void lostFocus(PwM *wnd); | 239 | void lostFocus(PwM *wnd); |
240 | 240 | ||
241 | protected: | 241 | protected: |
242 | /** pointer to the view active in this KMainWindow */ | 242 | /** pointer to the view active in this KMainWindow */ |
243 | PwMView *view; | 243 | PwMView *view; |
244 | /** pointer to the init class */ | 244 | /** pointer to the init class */ |
245 | PwMInit *init; | 245 | PwMInit *init; |
246 | /** has this window already lost its virginity? | 246 | /** has this window already lost its virginity? |
247 | * Means is there an open working document | 247 | * Means is there an open working document |
248 | */ | 248 | */ |
249 | bool virgin; | 249 | bool virgin; |
250 | /** "file" popup-menu */ | 250 | /** "file" popup-menu */ |
251 | KPopupMenu *filePopup; | 251 | KPopupMenu *filePopup; |
252 | 252 | ||
253 | /** "manage" popup-menu */ | 253 | /** "manage" popup-menu */ |
254 | KPopupMenu *managePopup; | 254 | KPopupMenu *managePopup; |
255 | #ifdef CONFIG_KEYCARD | 255 | #ifdef CONFIG_KEYCARD |
256 | /** "chipcard" popup-menu */ | 256 | /** "chipcard" popup-menu */ |
257 | KPopupMenu *chipcardPopup; | 257 | KPopupMenu *chipcardPopup; |
258 | #endif // CONFIG_KEYCARD | 258 | #endif // CONFIG_KEYCARD |
259 | /** "view" popup-menu */ | 259 | /** "view" popup-menu */ |
260 | KPopupMenu *viewPopup; | 260 | KPopupMenu *viewPopup; |
261 | /** "options" popup-menu */ | 261 | /** "options" popup-menu */ |
262 | KPopupMenu *optionsPopup; | 262 | KPopupMenu *optionsPopup; |
263 | /** "help" popup-menu */ | 263 | /** "help" popup-menu */ |
264 | KPopupMenu *helpPopup; | 264 | KPopupMenu *helpPopup; |
265 | /** "export" popup-menu */ | 265 | /** "export" popup-menu */ |
266 | KPopupMenu *exportPopup; | 266 | KPopupMenu *exportPopup; |
267 | /** "import" popup-menu */ | 267 | /** "import" popup-menu */ |
268 | KPopupMenu *importPopup; | 268 | KPopupMenu *importPopup; |
269 | /** force quit this window? */ | 269 | /** force quit this window? */ |
270 | bool forceQuit; | 270 | bool forceQuit; |
271 | /** force minimize this window to the tray */ | 271 | /** force minimize this window to the tray */ |
272 | bool forceMinimizeToTray; | 272 | bool forceMinimizeToTray; |
273 | 273 | ||
274 | 274 | ||
275 | 275 | ||
276 | 276 | ||
277 | private: | 277 | private: |
278 | #ifdef PWM_EMBEDDED | 278 | #ifdef PWM_EMBEDDED |
279 | //this are the overwritten callbackmethods from the syncinterface | 279 | //this are the overwritten callbackmethods from the syncinterface |
280 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 280 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
281 | virtual void removeSyncInfo( QString syncProfile); | ||
281 | 282 | ||
282 | // LR ******************************* | 283 | // LR ******************************* |
283 | // sync stuff! | 284 | // sync stuff! |
284 | QPopupMenu *syncPopup; | 285 | QPopupMenu *syncPopup; |
285 | KSyncManager* syncManager; | 286 | KSyncManager* syncManager; |
286 | #endif | 287 | #endif |
287 | 288 | ||
288 | 289 | ||
289 | 290 | ||
290 | 291 | ||
291 | 292 | ||
292 | 293 | ||
293 | 294 | ||
294 | 295 | ||
295 | }; | 296 | }; |
296 | 297 | ||
297 | #endif | 298 | #endif |
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp index cf8690f..fd17ce5 100644 --- a/pwmanager/pwmanager/pwmdoc.cpp +++ b/pwmanager/pwmanager/pwmdoc.cpp | |||
@@ -1771,1728 +1771,1731 @@ bool PwMDoc::unlockAll_tempoary(bool revert) | |||
1771 | return true; | 1771 | return true; |
1772 | } else if (!wasDeepLocked) { | 1772 | } else if (!wasDeepLocked) { |
1773 | if (!getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW) && | 1773 | if (!getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW) && |
1774 | currentPw != "") { | 1774 | currentPw != "") { |
1775 | /* we can't unlock without mpw, so | 1775 | /* we can't unlock without mpw, so |
1776 | * we need to ask for it. | 1776 | * we need to ask for it. |
1777 | */ | 1777 | */ |
1778 | QString pw; | 1778 | QString pw; |
1779 | while (1) { | 1779 | while (1) { |
1780 | pw = requestMpw(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); | 1780 | pw = requestMpw(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); |
1781 | if (pw == "") { | 1781 | if (pw == "") { |
1782 | return false; | 1782 | return false; |
1783 | } else if (pw == currentPw) { | 1783 | } else if (pw == currentPw) { |
1784 | break; | 1784 | break; |
1785 | } | 1785 | } |
1786 | wrongMpwMsgBox(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); | 1786 | wrongMpwMsgBox(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); |
1787 | } | 1787 | } |
1788 | } | 1788 | } |
1789 | } | 1789 | } |
1790 | timer()->stop(DocTimer::id_autoLockTimer); | 1790 | timer()->stop(DocTimer::id_autoLockTimer); |
1791 | oldLockStates = new vector< vector<bool> >; | 1791 | oldLockStates = new vector< vector<bool> >; |
1792 | vector<bool> tmp_vec; | 1792 | vector<bool> tmp_vec; |
1793 | vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), | 1793 | vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), |
1794 | catEnd = dti.dta.end(), | 1794 | catEnd = dti.dta.end(), |
1795 | catI = catBegin; | 1795 | catI = catBegin; |
1796 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; | 1796 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; |
1797 | while (catI != catEnd) { | 1797 | while (catI != catEnd) { |
1798 | entrBegin = catI->d.begin(); | 1798 | entrBegin = catI->d.begin(); |
1799 | entrEnd = catI->d.end(); | 1799 | entrEnd = catI->d.end(); |
1800 | entrI = entrBegin; | 1800 | entrI = entrBegin; |
1801 | while (entrI != entrEnd) { | 1801 | while (entrI != entrEnd) { |
1802 | if (!wasDeepLocked) { | 1802 | if (!wasDeepLocked) { |
1803 | tmp_vec.push_back(entrI->lockStat); | 1803 | tmp_vec.push_back(entrI->lockStat); |
1804 | } | 1804 | } |
1805 | entrI->lockStat = false; | 1805 | entrI->lockStat = false; |
1806 | ++entrI; | 1806 | ++entrI; |
1807 | } | 1807 | } |
1808 | if (!wasDeepLocked) { | 1808 | if (!wasDeepLocked) { |
1809 | oldLockStates->push_back(tmp_vec); | 1809 | oldLockStates->push_back(tmp_vec); |
1810 | tmp_vec.clear(); | 1810 | tmp_vec.clear(); |
1811 | } | 1811 | } |
1812 | ++catI; | 1812 | ++catI; |
1813 | } | 1813 | } |
1814 | printDebug("tempoary unlocked dta."); | 1814 | printDebug("tempoary unlocked dta."); |
1815 | } | 1815 | } |
1816 | 1816 | ||
1817 | return true; | 1817 | return true; |
1818 | } | 1818 | } |
1819 | 1819 | ||
1820 | PwMerror PwMDoc::deepLock(bool lock, bool saveToFile) | 1820 | PwMerror PwMDoc::deepLock(bool lock, bool saveToFile) |
1821 | { | 1821 | { |
1822 | PwMerror ret; | 1822 | PwMerror ret; |
1823 | /* NOTE: saveDoc() depends on this function to return | 1823 | /* NOTE: saveDoc() depends on this function to return |
1824 | * e_success if saveToFile == false | 1824 | * e_success if saveToFile == false |
1825 | */ | 1825 | */ |
1826 | 1826 | ||
1827 | if (lock) { | 1827 | if (lock) { |
1828 | if (isDeepLocked()) | 1828 | if (isDeepLocked()) |
1829 | return e_lock; | 1829 | return e_lock; |
1830 | if (saveToFile) { | 1830 | if (saveToFile) { |
1831 | if (isDocEmpty()) | 1831 | if (isDocEmpty()) |
1832 | return e_docIsEmpty; | 1832 | return e_docIsEmpty; |
1833 | ret = saveDoc(conf()->confGlobCompression()); | 1833 | ret = saveDoc(conf()->confGlobCompression()); |
1834 | if (ret == e_filename) { | 1834 | if (ret == e_filename) { |
1835 | /* the doc wasn't saved to a file | 1835 | /* the doc wasn't saved to a file |
1836 | * by the user, yet. | 1836 | * by the user, yet. |
1837 | */ | 1837 | */ |
1838 | cantDeeplock_notSavedMsgBox(); | 1838 | cantDeeplock_notSavedMsgBox(); |
1839 | return e_docNotSaved; | 1839 | return e_docNotSaved; |
1840 | } else if (ret != e_success) { | 1840 | } else if (ret != e_success) { |
1841 | return e_lock; | 1841 | return e_lock; |
1842 | } | 1842 | } |
1843 | } | 1843 | } |
1844 | timer()->stop(DocTimer::id_autoLockTimer); | 1844 | timer()->stop(DocTimer::id_autoLockTimer); |
1845 | clearDoc(); | 1845 | clearDoc(); |
1846 | PwMDataItem d; | 1846 | PwMDataItem d; |
1847 | d.desc = IS_DEEPLOCKED_SHORTMSG.latin1(); | 1847 | d.desc = IS_DEEPLOCKED_SHORTMSG.latin1(); |
1848 | d.comment = IS_DEEPLOCKED_MSG.latin1(); | 1848 | d.comment = IS_DEEPLOCKED_MSG.latin1(); |
1849 | d.listViewPos = 0; | 1849 | d.listViewPos = 0; |
1850 | addEntry(DEFAULT_CATEGORY, &d, true); | 1850 | addEntry(DEFAULT_CATEGORY, &d, true); |
1851 | lockAt(DEFAULT_CATEGORY, 0, true); | 1851 | lockAt(DEFAULT_CATEGORY, 0, true); |
1852 | unsetDocStatFlag(DOC_STAT_DISK_DIRTY); | 1852 | unsetDocStatFlag(DOC_STAT_DISK_DIRTY); |
1853 | setDocStatFlag(DOC_STAT_DEEPLOCKED); | 1853 | setDocStatFlag(DOC_STAT_DEEPLOCKED); |
1854 | } else { | 1854 | } else { |
1855 | if (!isDeepLocked()) | 1855 | if (!isDeepLocked()) |
1856 | return e_lock; | 1856 | return e_lock; |
1857 | ret = openDoc(&filename, (conf()->confGlobUnlockOnOpen()) | 1857 | ret = openDoc(&filename, (conf()->confGlobUnlockOnOpen()) |
1858 | ? 0 : 1); | 1858 | ? 0 : 1); |
1859 | if (ret == e_wrongPw) { | 1859 | if (ret == e_wrongPw) { |
1860 | return e_wrongPw; | 1860 | return e_wrongPw; |
1861 | } else if (ret != e_success) { | 1861 | } else if (ret != e_success) { |
1862 | printDebug(string("PwMDoc::deepLock(false): ERR! openDoc() == ") | 1862 | printDebug(string("PwMDoc::deepLock(false): ERR! openDoc() == ") |
1863 | + tostr(static_cast<int>(ret))); | 1863 | + tostr(static_cast<int>(ret))); |
1864 | return e_lock; | 1864 | return e_lock; |
1865 | } | 1865 | } |
1866 | unsetDocStatFlag(DOC_STAT_DEEPLOCKED); | 1866 | unsetDocStatFlag(DOC_STAT_DEEPLOCKED); |
1867 | timer()->start(DocTimer::id_autoLockTimer); | 1867 | timer()->start(DocTimer::id_autoLockTimer); |
1868 | } | 1868 | } |
1869 | 1869 | ||
1870 | emitDataChanged(this); | 1870 | emitDataChanged(this); |
1871 | return e_success; | 1871 | return e_success; |
1872 | } | 1872 | } |
1873 | 1873 | ||
1874 | void PwMDoc::_deepUnlock() | 1874 | void PwMDoc::_deepUnlock() |
1875 | { | 1875 | { |
1876 | deepLock(false); | 1876 | deepLock(false); |
1877 | } | 1877 | } |
1878 | 1878 | ||
1879 | void PwMDoc::clearDoc() | 1879 | void PwMDoc::clearDoc() |
1880 | { | 1880 | { |
1881 | dti.clear(); | 1881 | dti.clear(); |
1882 | PwMCategoryItem d; | 1882 | PwMCategoryItem d; |
1883 | d.name = DEFAULT_CATEGORY.latin1(); | 1883 | d.name = DEFAULT_CATEGORY.latin1(); |
1884 | dti.dta.push_back(d); | 1884 | dti.dta.push_back(d); |
1885 | currentPw = ""; | 1885 | currentPw = ""; |
1886 | unsetDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); | 1886 | unsetDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); |
1887 | } | 1887 | } |
1888 | 1888 | ||
1889 | void PwMDoc::changeCurrentPw() | 1889 | void PwMDoc::changeCurrentPw() |
1890 | { | 1890 | { |
1891 | if (currentPw == "") | 1891 | if (currentPw == "") |
1892 | return; // doc hasn't been saved. No mpw available. | 1892 | return; // doc hasn't been saved. No mpw available. |
1893 | bool useChipcard = getDocStatFlag(DOC_STAT_USE_CHIPCARD); | 1893 | bool useChipcard = getDocStatFlag(DOC_STAT_USE_CHIPCARD); |
1894 | QString pw = requestMpwChange(¤tPw, &useChipcard); | 1894 | QString pw = requestMpwChange(¤tPw, &useChipcard); |
1895 | if (pw == "") | 1895 | if (pw == "") |
1896 | return; | 1896 | return; |
1897 | if (useChipcard) | 1897 | if (useChipcard) |
1898 | setDocStatFlag(DOC_STAT_USE_CHIPCARD); | 1898 | setDocStatFlag(DOC_STAT_USE_CHIPCARD); |
1899 | else | 1899 | else |
1900 | unsetDocStatFlag(DOC_STAT_USE_CHIPCARD); | 1900 | unsetDocStatFlag(DOC_STAT_USE_CHIPCARD); |
1901 | setCurrentPw(pw); | 1901 | setCurrentPw(pw); |
1902 | } | 1902 | } |
1903 | 1903 | ||
1904 | void PwMDoc::setListViewPos(const QString &category, unsigned int index, | 1904 | void PwMDoc::setListViewPos(const QString &category, unsigned int index, |
1905 | int pos) | 1905 | int pos) |
1906 | { | 1906 | { |
1907 | unsigned int cat = 0; | 1907 | unsigned int cat = 0; |
1908 | 1908 | ||
1909 | if (!findCategory(category, &cat)) { | 1909 | if (!findCategory(category, &cat)) { |
1910 | BUG(); | 1910 | BUG(); |
1911 | return; | 1911 | return; |
1912 | } | 1912 | } |
1913 | setListViewPos(cat, index, pos); | 1913 | setListViewPos(cat, index, pos); |
1914 | } | 1914 | } |
1915 | 1915 | ||
1916 | void PwMDoc::setListViewPos(unsigned int category, unsigned int index, | 1916 | void PwMDoc::setListViewPos(unsigned int category, unsigned int index, |
1917 | int pos) | 1917 | int pos) |
1918 | { | 1918 | { |
1919 | dti.dta[category].d[index].listViewPos = pos; | 1919 | dti.dta[category].d[index].listViewPos = pos; |
1920 | 1920 | ||
1921 | /* FIXME workaround: don't flag dirty, because this function sometimes | 1921 | /* FIXME workaround: don't flag dirty, because this function sometimes |
1922 | * get's called when it shouldn't. It's because PwMView assumes | 1922 | * get's called when it shouldn't. It's because PwMView assumes |
1923 | * the user resorted the UI on behalf of signal layoutChanged(). | 1923 | * the user resorted the UI on behalf of signal layoutChanged(). |
1924 | * This is somewhat broken and incorrect, but I've no other | 1924 | * This is somewhat broken and incorrect, but I've no other |
1925 | * solution for now. | 1925 | * solution for now. |
1926 | */ | 1926 | */ |
1927 | //setDocStatFlag(DOC_STAT_DISK_DIRTY); | 1927 | //setDocStatFlag(DOC_STAT_DISK_DIRTY); |
1928 | } | 1928 | } |
1929 | 1929 | ||
1930 | int PwMDoc::getListViewPos(const QString &category, unsigned int index) | 1930 | int PwMDoc::getListViewPos(const QString &category, unsigned int index) |
1931 | { | 1931 | { |
1932 | unsigned int cat = 0; | 1932 | unsigned int cat = 0; |
1933 | 1933 | ||
1934 | if (!findCategory(category, &cat)) { | 1934 | if (!findCategory(category, &cat)) { |
1935 | BUG(); | 1935 | BUG(); |
1936 | return -1; | 1936 | return -1; |
1937 | } | 1937 | } |
1938 | 1938 | ||
1939 | return dti.dta[cat].d[index].listViewPos; | 1939 | return dti.dta[cat].d[index].listViewPos; |
1940 | } | 1940 | } |
1941 | 1941 | ||
1942 | void PwMDoc::findEntry(unsigned int category, PwMDataItem find, unsigned int searchIn, | 1942 | void PwMDoc::findEntry(unsigned int category, PwMDataItem find, unsigned int searchIn, |
1943 | vector<unsigned int> *foundPositions, bool breakAfterFound, | 1943 | vector<unsigned int> *foundPositions, bool breakAfterFound, |
1944 | bool caseSensitive, bool exactWordMatch, bool sortByLvp) | 1944 | bool caseSensitive, bool exactWordMatch, bool sortByLvp) |
1945 | { | 1945 | { |
1946 | PWM_ASSERT(foundPositions); | 1946 | PWM_ASSERT(foundPositions); |
1947 | PWM_ASSERT(searchIn); | 1947 | PWM_ASSERT(searchIn); |
1948 | foundPositions->clear(); | 1948 | foundPositions->clear(); |
1949 | 1949 | ||
1950 | unsigned int i, entries = numEntries(category); | 1950 | unsigned int i, entries = numEntries(category); |
1951 | for (i = 0; i < entries; ++i) { | 1951 | for (i = 0; i < entries; ++i) { |
1952 | if (searchIn & SEARCH_IN_DESC) { | 1952 | if (searchIn & SEARCH_IN_DESC) { |
1953 | if (!compareString(find.desc, dti.dta[category].d[i].desc, | 1953 | if (!compareString(find.desc, dti.dta[category].d[i].desc, |
1954 | caseSensitive, exactWordMatch)) { | 1954 | caseSensitive, exactWordMatch)) { |
1955 | continue; | 1955 | continue; |
1956 | } | 1956 | } |
1957 | } | 1957 | } |
1958 | if (searchIn & SEARCH_IN_NAME) { | 1958 | if (searchIn & SEARCH_IN_NAME) { |
1959 | if (!compareString(find.name, dti.dta[category].d[i].name, | 1959 | if (!compareString(find.name, dti.dta[category].d[i].name, |
1960 | caseSensitive, exactWordMatch)) { | 1960 | caseSensitive, exactWordMatch)) { |
1961 | continue; | 1961 | continue; |
1962 | } | 1962 | } |
1963 | } | 1963 | } |
1964 | if (searchIn & SEARCH_IN_PW) { | 1964 | if (searchIn & SEARCH_IN_PW) { |
1965 | bool wasLocked = isLocked(category, i); | 1965 | bool wasLocked = isLocked(category, i); |
1966 | getDataChangedLock(); | 1966 | getDataChangedLock(); |
1967 | lockAt(category, i, false); | 1967 | lockAt(category, i, false); |
1968 | if (!compareString(find.pw, dti.dta[category].d[i].pw, | 1968 | if (!compareString(find.pw, dti.dta[category].d[i].pw, |
1969 | caseSensitive, exactWordMatch)) { | 1969 | caseSensitive, exactWordMatch)) { |
1970 | lockAt(category, i, wasLocked); | 1970 | lockAt(category, i, wasLocked); |
1971 | putDataChangedLock(); | 1971 | putDataChangedLock(); |
1972 | continue; | 1972 | continue; |
1973 | } | 1973 | } |
1974 | lockAt(category, i, wasLocked); | 1974 | lockAt(category, i, wasLocked); |
1975 | putDataChangedLock(); | 1975 | putDataChangedLock(); |
1976 | } | 1976 | } |
1977 | if (searchIn & SEARCH_IN_COMMENT) { | 1977 | if (searchIn & SEARCH_IN_COMMENT) { |
1978 | if (!compareString(find.comment, dti.dta[category].d[i].comment, | 1978 | if (!compareString(find.comment, dti.dta[category].d[i].comment, |
1979 | caseSensitive, exactWordMatch)) { | 1979 | caseSensitive, exactWordMatch)) { |
1980 | continue; | 1980 | continue; |
1981 | } | 1981 | } |
1982 | } | 1982 | } |
1983 | if (searchIn & SEARCH_IN_URL) { | 1983 | if (searchIn & SEARCH_IN_URL) { |
1984 | if (!compareString(find.url, dti.dta[category].d[i].url, | 1984 | if (!compareString(find.url, dti.dta[category].d[i].url, |
1985 | caseSensitive, exactWordMatch)) { | 1985 | caseSensitive, exactWordMatch)) { |
1986 | continue; | 1986 | continue; |
1987 | } | 1987 | } |
1988 | } | 1988 | } |
1989 | if (searchIn & SEARCH_IN_LAUNCHER) { | 1989 | if (searchIn & SEARCH_IN_LAUNCHER) { |
1990 | if (!compareString(find.launcher, dti.dta[category].d[i].launcher, | 1990 | if (!compareString(find.launcher, dti.dta[category].d[i].launcher, |
1991 | caseSensitive, exactWordMatch)) { | 1991 | caseSensitive, exactWordMatch)) { |
1992 | continue; | 1992 | continue; |
1993 | } | 1993 | } |
1994 | } | 1994 | } |
1995 | 1995 | ||
1996 | // all selected "searchIn" matched. | 1996 | // all selected "searchIn" matched. |
1997 | foundPositions->push_back(i); | 1997 | foundPositions->push_back(i); |
1998 | if (breakAfterFound) | 1998 | if (breakAfterFound) |
1999 | break; | 1999 | break; |
2000 | } | 2000 | } |
2001 | 2001 | ||
2002 | if (sortByLvp && foundPositions->size() > 1) { | 2002 | if (sortByLvp && foundPositions->size() > 1) { |
2003 | vector< pair<unsigned int /* foundPosition (real doc pos) */, | 2003 | vector< pair<unsigned int /* foundPosition (real doc pos) */, |
2004 | unsigned int /* lvp-pos */> > tmp_vec; | 2004 | unsigned int /* lvp-pos */> > tmp_vec; |
2005 | 2005 | ||
2006 | unsigned int i, items = foundPositions->size(); | 2006 | unsigned int i, items = foundPositions->size(); |
2007 | pair<unsigned int, unsigned int> tmp_pair; | 2007 | pair<unsigned int, unsigned int> tmp_pair; |
2008 | for (i = 0; i < items; ++i) { | 2008 | for (i = 0; i < items; ++i) { |
2009 | tmp_pair.first = (*foundPositions)[i]; | 2009 | tmp_pair.first = (*foundPositions)[i]; |
2010 | tmp_pair.second = dti.dta[category].d[(*foundPositions)[i]].listViewPos; | 2010 | tmp_pair.second = dti.dta[category].d[(*foundPositions)[i]].listViewPos; |
2011 | tmp_vec.push_back(tmp_pair); | 2011 | tmp_vec.push_back(tmp_pair); |
2012 | } | 2012 | } |
2013 | sort(tmp_vec.begin(), tmp_vec.end(), dta_lvp_greater()); | 2013 | sort(tmp_vec.begin(), tmp_vec.end(), dta_lvp_greater()); |
2014 | foundPositions->clear(); | 2014 | foundPositions->clear(); |
2015 | for (i = 0; i < items; ++i) { | 2015 | for (i = 0; i < items; ++i) { |
2016 | foundPositions->push_back(tmp_vec[i].first); | 2016 | foundPositions->push_back(tmp_vec[i].first); |
2017 | } | 2017 | } |
2018 | } | 2018 | } |
2019 | } | 2019 | } |
2020 | 2020 | ||
2021 | void PwMDoc::findEntry(const QString &category, PwMDataItem find, unsigned int searchIn, | 2021 | void PwMDoc::findEntry(const QString &category, PwMDataItem find, unsigned int searchIn, |
2022 | vector<unsigned int> *foundPositions, bool breakAfterFound, | 2022 | vector<unsigned int> *foundPositions, bool breakAfterFound, |
2023 | bool caseSensitive, bool exactWordMatch, bool sortByLvp) | 2023 | bool caseSensitive, bool exactWordMatch, bool sortByLvp) |
2024 | { | 2024 | { |
2025 | PWM_ASSERT(foundPositions); | 2025 | PWM_ASSERT(foundPositions); |
2026 | unsigned int cat = 0; | 2026 | unsigned int cat = 0; |
2027 | 2027 | ||
2028 | if (!findCategory(category, &cat)) { | 2028 | if (!findCategory(category, &cat)) { |
2029 | foundPositions->clear(); | 2029 | foundPositions->clear(); |
2030 | return; | 2030 | return; |
2031 | } | 2031 | } |
2032 | 2032 | ||
2033 | findEntry(cat, find, searchIn, foundPositions, breakAfterFound, | 2033 | findEntry(cat, find, searchIn, foundPositions, breakAfterFound, |
2034 | caseSensitive, exactWordMatch, sortByLvp); | 2034 | caseSensitive, exactWordMatch, sortByLvp); |
2035 | } | 2035 | } |
2036 | 2036 | ||
2037 | bool PwMDoc::compareString(const string &s1, const string &s2, bool caseSensitive, | 2037 | bool PwMDoc::compareString(const string &s1, const string &s2, bool caseSensitive, |
2038 | bool exactWordMatch) | 2038 | bool exactWordMatch) |
2039 | { | 2039 | { |
2040 | QString _s1(s1.c_str()); | 2040 | QString _s1(s1.c_str()); |
2041 | QString _s2(s2.c_str()); | 2041 | QString _s2(s2.c_str()); |
2042 | if (!caseSensitive) { | 2042 | if (!caseSensitive) { |
2043 | _s1 = _s1.lower(); | 2043 | _s1 = _s1.lower(); |
2044 | _s2 = _s2.lower(); | 2044 | _s2 = _s2.lower(); |
2045 | } | 2045 | } |
2046 | if (exactWordMatch ? (_s1 == _s2) : (_s2.find(_s1) != -1)) | 2046 | if (exactWordMatch ? (_s1 == _s2) : (_s2.find(_s1) != -1)) |
2047 | return true; | 2047 | return true; |
2048 | return false; | 2048 | return false; |
2049 | } | 2049 | } |
2050 | 2050 | ||
2051 | bool PwMDoc::findCategory(const QString &name, unsigned int *index) | 2051 | bool PwMDoc::findCategory(const QString &name, unsigned int *index) |
2052 | { | 2052 | { |
2053 | vector<PwMCategoryItem>::iterator i = dti.dta.begin(), | 2053 | vector<PwMCategoryItem>::iterator i = dti.dta.begin(), |
2054 | end = dti.dta.end(); | 2054 | end = dti.dta.end(); |
2055 | while (i != end) { | 2055 | while (i != end) { |
2056 | if ((*i).name == name.latin1()) { | 2056 | if ((*i).name == name.latin1()) { |
2057 | if (index) { | 2057 | if (index) { |
2058 | *index = i - dti.dta.begin(); | 2058 | *index = i - dti.dta.begin(); |
2059 | } | 2059 | } |
2060 | return true; | 2060 | return true; |
2061 | } | 2061 | } |
2062 | ++i; | 2062 | ++i; |
2063 | } | 2063 | } |
2064 | return false; | 2064 | return false; |
2065 | } | 2065 | } |
2066 | 2066 | ||
2067 | bool PwMDoc::renameCategory(const QString &category, const QString &newName) | 2067 | bool PwMDoc::renameCategory(const QString &category, const QString &newName) |
2068 | { | 2068 | { |
2069 | unsigned int cat = 0; | 2069 | unsigned int cat = 0; |
2070 | 2070 | ||
2071 | if (!findCategory(category, &cat)) | 2071 | if (!findCategory(category, &cat)) |
2072 | return false; | 2072 | return false; |
2073 | 2073 | ||
2074 | return renameCategory(cat, newName); | 2074 | return renameCategory(cat, newName); |
2075 | } | 2075 | } |
2076 | 2076 | ||
2077 | bool PwMDoc::renameCategory(unsigned int category, const QString &newName, | 2077 | bool PwMDoc::renameCategory(unsigned int category, const QString &newName, |
2078 | bool dontFlagDirty) | 2078 | bool dontFlagDirty) |
2079 | { | 2079 | { |
2080 | if (category > numCategories() - 1) | 2080 | if (category > numCategories() - 1) |
2081 | return false; | 2081 | return false; |
2082 | 2082 | ||
2083 | dti.dta[category].name = newName.latin1(); | 2083 | dti.dta[category].name = newName.latin1(); |
2084 | if (!dontFlagDirty) | 2084 | if (!dontFlagDirty) |
2085 | flagDirty(); | 2085 | flagDirty(); |
2086 | 2086 | ||
2087 | return true; | 2087 | return true; |
2088 | } | 2088 | } |
2089 | 2089 | ||
2090 | bool PwMDoc::delCategory(const QString &category) | 2090 | bool PwMDoc::delCategory(const QString &category) |
2091 | { | 2091 | { |
2092 | unsigned int cat = 0; | 2092 | unsigned int cat = 0; |
2093 | 2093 | ||
2094 | if (!findCategory(category, &cat)) | 2094 | if (!findCategory(category, &cat)) |
2095 | return false; | 2095 | return false; |
2096 | 2096 | ||
2097 | return delCategory(cat); | 2097 | return delCategory(cat); |
2098 | } | 2098 | } |
2099 | 2099 | ||
2100 | bool PwMDoc::delCategory(unsigned int category, bool dontFlagDirty) | 2100 | bool PwMDoc::delCategory(unsigned int category, bool dontFlagDirty) |
2101 | { | 2101 | { |
2102 | if (category > numCategories() - 1) | 2102 | if (category > numCategories() - 1) |
2103 | return false; | 2103 | return false; |
2104 | 2104 | ||
2105 | // We don't delete it, if it is the last existing | 2105 | // We don't delete it, if it is the last existing |
2106 | // category! Instead we rename it to "Default". | 2106 | // category! Instead we rename it to "Default". |
2107 | if (numCategories() > 1) { | 2107 | if (numCategories() > 1) { |
2108 | dti.dta.erase(dti.dta.begin() + category); | 2108 | dti.dta.erase(dti.dta.begin() + category); |
2109 | } else { | 2109 | } else { |
2110 | renameCategory(category, DEFAULT_CATEGORY, dontFlagDirty); | 2110 | renameCategory(category, DEFAULT_CATEGORY, dontFlagDirty); |
2111 | return true; | 2111 | return true; |
2112 | } | 2112 | } |
2113 | if (!dontFlagDirty) | 2113 | if (!dontFlagDirty) |
2114 | flagDirty(); | 2114 | flagDirty(); |
2115 | 2115 | ||
2116 | return true; | 2116 | return true; |
2117 | } | 2117 | } |
2118 | 2118 | ||
2119 | void PwMDoc::delAllEmptyCat(bool dontFlagDirty) | 2119 | void PwMDoc::delAllEmptyCat(bool dontFlagDirty) |
2120 | { | 2120 | { |
2121 | vector<PwMCategoryItem>::iterator begin = dti.dta.begin(), | 2121 | vector<PwMCategoryItem>::iterator begin = dti.dta.begin(), |
2122 | end = dti.dta.end(), | 2122 | end = dti.dta.end(), |
2123 | i = begin; | 2123 | i = begin; |
2124 | while (i != end) { | 2124 | while (i != end) { |
2125 | if (i->d.empty()) { | 2125 | if (i->d.empty()) { |
2126 | delCategory(begin - i, dontFlagDirty); | 2126 | delCategory(begin - i, dontFlagDirty); |
2127 | } | 2127 | } |
2128 | ++i; | 2128 | ++i; |
2129 | } | 2129 | } |
2130 | } | 2130 | } |
2131 | 2131 | ||
2132 | void PwMDoc::getCategoryList(vector<string> *list) | 2132 | void PwMDoc::getCategoryList(vector<string> *list) |
2133 | { | 2133 | { |
2134 | PWM_ASSERT(list); | 2134 | PWM_ASSERT(list); |
2135 | list->clear(); | 2135 | list->clear(); |
2136 | vector<PwMCategoryItem>::iterator i = dti.dta.begin(), | 2136 | vector<PwMCategoryItem>::iterator i = dti.dta.begin(), |
2137 | end = dti.dta.end(); | 2137 | end = dti.dta.end(); |
2138 | while (i != end) { | 2138 | while (i != end) { |
2139 | list->push_back(i->name); | 2139 | list->push_back(i->name); |
2140 | ++i; | 2140 | ++i; |
2141 | } | 2141 | } |
2142 | } | 2142 | } |
2143 | 2143 | ||
2144 | void PwMDoc::getCategoryList(QStringList *list) | 2144 | void PwMDoc::getCategoryList(QStringList *list) |
2145 | { | 2145 | { |
2146 | PWM_ASSERT(list); | 2146 | PWM_ASSERT(list); |
2147 | list->clear(); | 2147 | list->clear(); |
2148 | vector<PwMCategoryItem>::iterator i = dti.dta.begin(), | 2148 | vector<PwMCategoryItem>::iterator i = dti.dta.begin(), |
2149 | end = dti.dta.end(); | 2149 | end = dti.dta.end(); |
2150 | while (i != end) { | 2150 | while (i != end) { |
2151 | #ifndef PWM_EMBEDDED | 2151 | #ifndef PWM_EMBEDDED |
2152 | list->push_back(i->name.c_str()); | 2152 | list->push_back(i->name.c_str()); |
2153 | #else | 2153 | #else |
2154 | list->append(i->name.c_str()); | 2154 | list->append(i->name.c_str()); |
2155 | #endif | 2155 | #endif |
2156 | ++i; | 2156 | ++i; |
2157 | } | 2157 | } |
2158 | } | 2158 | } |
2159 | 2159 | ||
2160 | void PwMDoc::getEntryList(const QString &category, QStringList *list) | 2160 | void PwMDoc::getEntryList(const QString &category, QStringList *list) |
2161 | { | 2161 | { |
2162 | PWM_ASSERT(list); | 2162 | PWM_ASSERT(list); |
2163 | unsigned int cat = 0; | 2163 | unsigned int cat = 0; |
2164 | if (!findCategory(category, &cat)) { | 2164 | if (!findCategory(category, &cat)) { |
2165 | list->clear(); | 2165 | list->clear(); |
2166 | return; | 2166 | return; |
2167 | } | 2167 | } |
2168 | getEntryList(cat, list); | 2168 | getEntryList(cat, list); |
2169 | } | 2169 | } |
2170 | 2170 | ||
2171 | void PwMDoc::getEntryList(const QString &category, vector<string> *list) | 2171 | void PwMDoc::getEntryList(const QString &category, vector<string> *list) |
2172 | { | 2172 | { |
2173 | PWM_ASSERT(list); | 2173 | PWM_ASSERT(list); |
2174 | unsigned int cat = 0; | 2174 | unsigned int cat = 0; |
2175 | if (!findCategory(category, &cat)) { | 2175 | if (!findCategory(category, &cat)) { |
2176 | list->clear(); | 2176 | list->clear(); |
2177 | return; | 2177 | return; |
2178 | } | 2178 | } |
2179 | getEntryList(cat, list); | 2179 | getEntryList(cat, list); |
2180 | } | 2180 | } |
2181 | 2181 | ||
2182 | void PwMDoc::getEntryList(unsigned int category, vector<string> *list) | 2182 | void PwMDoc::getEntryList(unsigned int category, vector<string> *list) |
2183 | { | 2183 | { |
2184 | PWM_ASSERT(list); | 2184 | PWM_ASSERT(list); |
2185 | list->clear(); | 2185 | list->clear(); |
2186 | vector<PwMDataItem>::iterator begin = dti.dta[category].d.begin(), | 2186 | vector<PwMDataItem>::iterator begin = dti.dta[category].d.begin(), |
2187 | end = dti.dta[category].d.end(), | 2187 | end = dti.dta[category].d.end(), |
2188 | i = begin; | 2188 | i = begin; |
2189 | while (i != end) { | 2189 | while (i != end) { |
2190 | list->push_back(i->desc); | 2190 | list->push_back(i->desc); |
2191 | ++i; | 2191 | ++i; |
2192 | } | 2192 | } |
2193 | } | 2193 | } |
2194 | 2194 | ||
2195 | void PwMDoc::getEntryList(unsigned int category, QStringList *list) | 2195 | void PwMDoc::getEntryList(unsigned int category, QStringList *list) |
2196 | { | 2196 | { |
2197 | PWM_ASSERT(list); | 2197 | PWM_ASSERT(list); |
2198 | list->clear(); | 2198 | list->clear(); |
2199 | vector<PwMDataItem>::iterator begin = dti.dta[category].d.begin(), | 2199 | vector<PwMDataItem>::iterator begin = dti.dta[category].d.begin(), |
2200 | end = dti.dta[category].d.end(), | 2200 | end = dti.dta[category].d.end(), |
2201 | i = begin; | 2201 | i = begin; |
2202 | while (i != end) { | 2202 | while (i != end) { |
2203 | #ifndef PWM_EMBEDDED | 2203 | #ifndef PWM_EMBEDDED |
2204 | list->push_back(i->desc.c_str()); | 2204 | list->push_back(i->desc.c_str()); |
2205 | #else | 2205 | #else |
2206 | list->append(i->desc.c_str()); | 2206 | list->append(i->desc.c_str()); |
2207 | #endif | 2207 | #endif |
2208 | ++i; | 2208 | ++i; |
2209 | } | 2209 | } |
2210 | } | 2210 | } |
2211 | 2211 | ||
2212 | bool PwMDoc::execLauncher(const QString &category, unsigned int entryIndex) | 2212 | bool PwMDoc::execLauncher(const QString &category, unsigned int entryIndex) |
2213 | { | 2213 | { |
2214 | unsigned int cat = 0; | 2214 | unsigned int cat = 0; |
2215 | 2215 | ||
2216 | if (!findCategory(category, &cat)) | 2216 | if (!findCategory(category, &cat)) |
2217 | return false; | 2217 | return false; |
2218 | 2218 | ||
2219 | return execLauncher(cat, entryIndex); | 2219 | return execLauncher(cat, entryIndex); |
2220 | } | 2220 | } |
2221 | 2221 | ||
2222 | bool PwMDoc::execLauncher(unsigned int category, unsigned int entryIndex) | 2222 | bool PwMDoc::execLauncher(unsigned int category, unsigned int entryIndex) |
2223 | { | 2223 | { |
2224 | #ifndef _WIN32_ | 2224 | #ifndef _WIN32_ |
2225 | if (geteuid() == 0) { | 2225 | if (geteuid() == 0) { |
2226 | rootAlertMsgBox(); | 2226 | rootAlertMsgBox(); |
2227 | return false; | 2227 | return false; |
2228 | } | 2228 | } |
2229 | #endif | 2229 | #endif |
2230 | QString command(dti.dta[category].d[entryIndex].launcher.c_str()); | 2230 | QString command(dti.dta[category].d[entryIndex].launcher.c_str()); |
2231 | bool wasLocked = isLocked(category, entryIndex); | 2231 | bool wasLocked = isLocked(category, entryIndex); |
2232 | 2232 | ||
2233 | if (command.find("$p") != -1) { | 2233 | if (command.find("$p") != -1) { |
2234 | /* the user requested the password to be included | 2234 | /* the user requested the password to be included |
2235 | * into the command. We have to ask for the password, | 2235 | * into the command. We have to ask for the password, |
2236 | * if it's locked. We do that by unlocking the entry | 2236 | * if it's locked. We do that by unlocking the entry |
2237 | */ | 2237 | */ |
2238 | if (!lockAt(category, entryIndex, false)) | 2238 | if (!lockAt(category, entryIndex, false)) |
2239 | return false; | 2239 | return false; |
2240 | } | 2240 | } |
2241 | #ifndef PWM_EMBEDDED | 2241 | #ifndef PWM_EMBEDDED |
2242 | command.replace("$d", dti.dta[category].d[entryIndex].desc.c_str()); | 2242 | command.replace("$d", dti.dta[category].d[entryIndex].desc.c_str()); |
2243 | command.replace("$n", dti.dta[category].d[entryIndex].name.c_str()); | 2243 | command.replace("$n", dti.dta[category].d[entryIndex].name.c_str()); |
2244 | command.replace("$p", dti.dta[category].d[entryIndex].pw.c_str()); | 2244 | command.replace("$p", dti.dta[category].d[entryIndex].pw.c_str()); |
2245 | command.replace("$u", dti.dta[category].d[entryIndex].url.c_str()); | 2245 | command.replace("$u", dti.dta[category].d[entryIndex].url.c_str()); |
2246 | command.replace("$c", dti.dta[category].d[entryIndex].comment.c_str()); | 2246 | command.replace("$c", dti.dta[category].d[entryIndex].comment.c_str()); |
2247 | #else | 2247 | #else |
2248 | command.replace(QRegExp("$d"), dti.dta[category].d[entryIndex].desc.c_str()); | 2248 | command.replace(QRegExp("$d"), dti.dta[category].d[entryIndex].desc.c_str()); |
2249 | command.replace(QRegExp("$n"), dti.dta[category].d[entryIndex].name.c_str()); | 2249 | command.replace(QRegExp("$n"), dti.dta[category].d[entryIndex].name.c_str()); |
2250 | command.replace(QRegExp("$p"), dti.dta[category].d[entryIndex].pw.c_str()); | 2250 | command.replace(QRegExp("$p"), dti.dta[category].d[entryIndex].pw.c_str()); |
2251 | command.replace(QRegExp("$u"), dti.dta[category].d[entryIndex].url.c_str()); | 2251 | command.replace(QRegExp("$u"), dti.dta[category].d[entryIndex].url.c_str()); |
2252 | command.replace(QRegExp("$c"), dti.dta[category].d[entryIndex].comment.c_str()); | 2252 | command.replace(QRegExp("$c"), dti.dta[category].d[entryIndex].comment.c_str()); |
2253 | #endif | 2253 | #endif |
2254 | command.append(" &"); | 2254 | command.append(" &"); |
2255 | 2255 | ||
2256 | QString customXterm(conf()->confGlobXtermCommand()); | 2256 | QString customXterm(conf()->confGlobXtermCommand()); |
2257 | if (!customXterm.isEmpty()) | 2257 | if (!customXterm.isEmpty()) |
2258 | command = customXterm + " " + command; | 2258 | command = customXterm + " " + command; |
2259 | 2259 | ||
2260 | system(command.latin1()); | 2260 | system(command.latin1()); |
2261 | 2261 | ||
2262 | lockAt(category, entryIndex, wasLocked); | 2262 | lockAt(category, entryIndex, wasLocked); |
2263 | return true; | 2263 | return true; |
2264 | } | 2264 | } |
2265 | 2265 | ||
2266 | bool PwMDoc::goToURL(const QString &category, unsigned int entryIndex) | 2266 | bool PwMDoc::goToURL(const QString &category, unsigned int entryIndex) |
2267 | { | 2267 | { |
2268 | unsigned int cat = 0; | 2268 | unsigned int cat = 0; |
2269 | 2269 | ||
2270 | if (!findCategory(category, &cat)) | 2270 | if (!findCategory(category, &cat)) |
2271 | return false; | 2271 | return false; |
2272 | 2272 | ||
2273 | return goToURL(cat, entryIndex); | 2273 | return goToURL(cat, entryIndex); |
2274 | } | 2274 | } |
2275 | 2275 | ||
2276 | bool PwMDoc::goToURL(unsigned int category, unsigned int entryIndex) | 2276 | bool PwMDoc::goToURL(unsigned int category, unsigned int entryIndex) |
2277 | { | 2277 | { |
2278 | #ifndef _WIN32_ | 2278 | #ifndef _WIN32_ |
2279 | if (geteuid() == 0) { | 2279 | if (geteuid() == 0) { |
2280 | rootAlertMsgBox(); | 2280 | rootAlertMsgBox(); |
2281 | return false; | 2281 | return false; |
2282 | } | 2282 | } |
2283 | #endif | 2283 | #endif |
2284 | QString url(dti.dta[category].d[entryIndex].url.c_str()); | 2284 | QString url(dti.dta[category].d[entryIndex].url.c_str()); |
2285 | if (url.isEmpty()) | 2285 | if (url.isEmpty()) |
2286 | return false; | 2286 | return false; |
2287 | 2287 | ||
2288 | QString customBrowser(conf()->confGlobBrowserCommand()); | 2288 | QString customBrowser(conf()->confGlobBrowserCommand()); |
2289 | if (!customBrowser.isEmpty()) { | 2289 | if (!customBrowser.isEmpty()) { |
2290 | browserProc.clearArguments(); | 2290 | browserProc.clearArguments(); |
2291 | browserProc << customBrowser << url; | 2291 | browserProc << customBrowser << url; |
2292 | if (browserProc.start(KProcess::DontCare)) | 2292 | if (browserProc.start(KProcess::DontCare)) |
2293 | return true; | 2293 | return true; |
2294 | } | 2294 | } |
2295 | 2295 | ||
2296 | browserProc.clearArguments(); | 2296 | browserProc.clearArguments(); |
2297 | browserProc << "konqueror" << url; | 2297 | browserProc << "konqueror" << url; |
2298 | if (browserProc.start(KProcess::DontCare)) | 2298 | if (browserProc.start(KProcess::DontCare)) |
2299 | return true; | 2299 | return true; |
2300 | 2300 | ||
2301 | browserProc.clearArguments(); | 2301 | browserProc.clearArguments(); |
2302 | browserProc << "mozilla" << url; | 2302 | browserProc << "mozilla" << url; |
2303 | if (browserProc.start(KProcess::DontCare)) | 2303 | if (browserProc.start(KProcess::DontCare)) |
2304 | return true; | 2304 | return true; |
2305 | 2305 | ||
2306 | browserProc.clearArguments(); | 2306 | browserProc.clearArguments(); |
2307 | browserProc << "opera" << url; | 2307 | browserProc << "opera" << url; |
2308 | if (browserProc.start(KProcess::DontCare)) | 2308 | if (browserProc.start(KProcess::DontCare)) |
2309 | return true; | 2309 | return true; |
2310 | return false; | 2310 | return false; |
2311 | } | 2311 | } |
2312 | 2312 | ||
2313 | PwMerror PwMDoc::exportToText(const QString *file) | 2313 | PwMerror PwMDoc::exportToText(const QString *file) |
2314 | { | 2314 | { |
2315 | PWM_ASSERT(file); | 2315 | PWM_ASSERT(file); |
2316 | if (QFile::exists(*file)) { | 2316 | if (QFile::exists(*file)) { |
2317 | if (!QFile::remove(*file)) | 2317 | if (!QFile::remove(*file)) |
2318 | return e_accessFile; | 2318 | return e_accessFile; |
2319 | } | 2319 | } |
2320 | QFile f(*file); | 2320 | QFile f(*file); |
2321 | if (!f.open(IO_ReadWrite)) | 2321 | if (!f.open(IO_ReadWrite)) |
2322 | return e_openFile; | 2322 | return e_openFile; |
2323 | 2323 | ||
2324 | if (!unlockAll_tempoary()) { | 2324 | if (!unlockAll_tempoary()) { |
2325 | f.close(); | 2325 | f.close(); |
2326 | return e_lock; | 2326 | return e_lock; |
2327 | } | 2327 | } |
2328 | 2328 | ||
2329 | // write header | 2329 | // write header |
2330 | string header = i18n("Password table generated by\nPwM v").latin1(); | 2330 | string header = i18n("Password table generated by\nPwM v").latin1(); |
2331 | header += PACKAGE_VER; | 2331 | header += PACKAGE_VER; |
2332 | header += i18n("\non ").latin1(); | 2332 | header += i18n("\non ").latin1(); |
2333 | QDate currDate = QDate::currentDate(); | 2333 | QDate currDate = QDate::currentDate(); |
2334 | QTime currTime = QTime::currentTime(); | 2334 | QTime currTime = QTime::currentTime(); |
2335 | 2335 | ||
2336 | #ifndef PWM_EMBEDDED | 2336 | #ifndef PWM_EMBEDDED |
2337 | header += currDate.toString("ddd MMMM d ").latin1(); | 2337 | header += currDate.toString("ddd MMMM d ").latin1(); |
2338 | header += currTime.toString("hh:mm:ss ").latin1(); | 2338 | header += currTime.toString("hh:mm:ss ").latin1(); |
2339 | #else | 2339 | #else |
2340 | QString dfs = KGlobal::locale()->dateFormatShort(); | 2340 | QString dfs = KGlobal::locale()->dateFormatShort(); |
2341 | bool ampm = KGlobal::locale()->use12Clock(); | 2341 | bool ampm = KGlobal::locale()->use12Clock(); |
2342 | KGlobal::locale()->setDateFormatShort("%A %B %d"); | 2342 | KGlobal::locale()->setDateFormatShort("%A %B %d"); |
2343 | KGlobal::locale()->setHore24Format(true); | 2343 | KGlobal::locale()->setHore24Format(true); |
2344 | 2344 | ||
2345 | header += KGlobal::locale()->formatDate(currDate, true, KLocale::Userdefined).latin1(); | 2345 | header += KGlobal::locale()->formatDate(currDate, true, KLocale::Userdefined).latin1(); |
2346 | header += KGlobal::locale()->formatTime(currTime, true).latin1(); | 2346 | header += KGlobal::locale()->formatTime(currTime, true).latin1(); |
2347 | KGlobal::locale()->setDateFormatShort(dfs); | 2347 | KGlobal::locale()->setDateFormatShort(dfs); |
2348 | KGlobal::locale()->setHore24Format(!ampm); | 2348 | KGlobal::locale()->setHore24Format(!ampm); |
2349 | 2349 | ||
2350 | #endif | 2350 | #endif |
2351 | header += tostr(currDate.year()); | 2351 | header += tostr(currDate.year()); |
2352 | header += "\n==============================\n\n"; | 2352 | header += "\n==============================\n\n"; |
2353 | 2353 | ||
2354 | 2354 | ||
2355 | #ifndef PWM_EMBEDDED | 2355 | #ifndef PWM_EMBEDDED |
2356 | if (f.writeBlock(header.c_str(), header.length()) != (Q_LONG)header.length()) { | 2356 | if (f.writeBlock(header.c_str(), header.length()) != (Q_LONG)header.length()) { |
2357 | unlockAll_tempoary(true); | 2357 | unlockAll_tempoary(true); |
2358 | f.close(); | 2358 | f.close(); |
2359 | return e_writeFile; | 2359 | return e_writeFile; |
2360 | } | 2360 | } |
2361 | #else | 2361 | #else |
2362 | if (f.writeBlock(header.c_str(), header.length()) != (long)header.length()) { | 2362 | if (f.writeBlock(header.c_str(), header.length()) != (long)header.length()) { |
2363 | unlockAll_tempoary(true); | 2363 | unlockAll_tempoary(true); |
2364 | f.close(); | 2364 | f.close(); |
2365 | return e_writeFile; | 2365 | return e_writeFile; |
2366 | } | 2366 | } |
2367 | #endif | 2367 | #endif |
2368 | unsigned int i, numCat = numCategories(); | 2368 | unsigned int i, numCat = numCategories(); |
2369 | unsigned int j, numEnt; | 2369 | unsigned int j, numEnt; |
2370 | string exp; | 2370 | string exp; |
2371 | for (i = 0; i < numCat; ++i) { | 2371 | for (i = 0; i < numCat; ++i) { |
2372 | numEnt = numEntries(i); | 2372 | numEnt = numEntries(i); |
2373 | 2373 | ||
2374 | exp = "\n== Category: "; | 2374 | exp = "\n== Category: "; |
2375 | exp += dti.dta[i].name; | 2375 | exp += dti.dta[i].name; |
2376 | exp += " ==\n"; | 2376 | exp += " ==\n"; |
2377 | #ifndef PWM_EMBEDDED | 2377 | #ifndef PWM_EMBEDDED |
2378 | if (f.writeBlock(exp.c_str(), exp.length()) != (Q_LONG)exp.length()) { | 2378 | if (f.writeBlock(exp.c_str(), exp.length()) != (Q_LONG)exp.length()) { |
2379 | unlockAll_tempoary(true); | 2379 | unlockAll_tempoary(true); |
2380 | f.close(); | 2380 | f.close(); |
2381 | return e_writeFile; | 2381 | return e_writeFile; |
2382 | } | 2382 | } |
2383 | #else | 2383 | #else |
2384 | if (f.writeBlock(exp.c_str(), exp.length()) != (long)exp.length()) { | 2384 | if (f.writeBlock(exp.c_str(), exp.length()) != (long)exp.length()) { |
2385 | unlockAll_tempoary(true); | 2385 | unlockAll_tempoary(true); |
2386 | f.close(); | 2386 | f.close(); |
2387 | return e_writeFile; | 2387 | return e_writeFile; |
2388 | } | 2388 | } |
2389 | #endif | 2389 | #endif |
2390 | for (j = 0; j < numEnt; ++j) { | 2390 | for (j = 0; j < numEnt; ++j) { |
2391 | exp = "\n-- "; | 2391 | exp = "\n-- "; |
2392 | exp += dti.dta[i].d[j].desc; | 2392 | exp += dti.dta[i].d[j].desc; |
2393 | exp += " --\n"; | 2393 | exp += " --\n"; |
2394 | 2394 | ||
2395 | exp += i18n("Username: ").latin1(); | 2395 | exp += i18n("Username: ").latin1(); |
2396 | exp += dti.dta[i].d[j].name; | 2396 | exp += dti.dta[i].d[j].name; |
2397 | exp += "\n"; | 2397 | exp += "\n"; |
2398 | 2398 | ||
2399 | exp += i18n("Password: ").latin1(); | 2399 | exp += i18n("Password: ").latin1(); |
2400 | exp += dti.dta[i].d[j].pw; | 2400 | exp += dti.dta[i].d[j].pw; |
2401 | exp += "\n"; | 2401 | exp += "\n"; |
2402 | 2402 | ||
2403 | exp += i18n("Comment: ").latin1(); | 2403 | exp += i18n("Comment: ").latin1(); |
2404 | exp += dti.dta[i].d[j].comment; | 2404 | exp += dti.dta[i].d[j].comment; |
2405 | exp += "\n"; | 2405 | exp += "\n"; |
2406 | 2406 | ||
2407 | exp += i18n("URL: ").latin1(); | 2407 | exp += i18n("URL: ").latin1(); |
2408 | exp += dti.dta[i].d[j].url; | 2408 | exp += dti.dta[i].d[j].url; |
2409 | exp += "\n"; | 2409 | exp += "\n"; |
2410 | 2410 | ||
2411 | exp += i18n("Launcher: ").latin1(); | 2411 | exp += i18n("Launcher: ").latin1(); |
2412 | exp += dti.dta[i].d[j].launcher; | 2412 | exp += dti.dta[i].d[j].launcher; |
2413 | exp += "\n"; | 2413 | exp += "\n"; |
2414 | 2414 | ||
2415 | #ifndef PWM_EMBEDDED | 2415 | #ifndef PWM_EMBEDDED |
2416 | if (f.writeBlock(exp.c_str(), exp.length()) != (Q_LONG)exp.length()) { | 2416 | if (f.writeBlock(exp.c_str(), exp.length()) != (Q_LONG)exp.length()) { |
2417 | unlockAll_tempoary(true); | 2417 | unlockAll_tempoary(true); |
2418 | f.close(); | 2418 | f.close(); |
2419 | return e_writeFile; | 2419 | return e_writeFile; |
2420 | } | 2420 | } |
2421 | #else | 2421 | #else |
2422 | if (f.writeBlock(exp.c_str(), exp.length()) != (long)exp.length()) { | 2422 | if (f.writeBlock(exp.c_str(), exp.length()) != (long)exp.length()) { |
2423 | unlockAll_tempoary(true); | 2423 | unlockAll_tempoary(true); |
2424 | f.close(); | 2424 | f.close(); |
2425 | return e_writeFile; | 2425 | return e_writeFile; |
2426 | } | 2426 | } |
2427 | #endif | 2427 | #endif |
2428 | } | 2428 | } |
2429 | } | 2429 | } |
2430 | unlockAll_tempoary(true); | 2430 | unlockAll_tempoary(true); |
2431 | f.close(); | 2431 | f.close(); |
2432 | 2432 | ||
2433 | return e_success; | 2433 | return e_success; |
2434 | } | 2434 | } |
2435 | 2435 | ||
2436 | PwMerror PwMDoc::importFromText(const QString *file, int format) | 2436 | PwMerror PwMDoc::importFromText(const QString *file, int format) |
2437 | { | 2437 | { |
2438 | PWM_ASSERT(file); | 2438 | PWM_ASSERT(file); |
2439 | if (format == 0) | 2439 | if (format == 0) |
2440 | return importText_PwM(file); | 2440 | return importText_PwM(file); |
2441 | else if (format == -1) { | 2441 | else if (format == -1) { |
2442 | // probe for all formats | 2442 | // probe for all formats |
2443 | if (importText_PwM(file) == e_success) | 2443 | if (importText_PwM(file) == e_success) |
2444 | return e_success; | 2444 | return e_success; |
2445 | dti.clear(); | 2445 | dti.clear(); |
2446 | emitDataChanged(this); | 2446 | emitDataChanged(this); |
2447 | // add next format here... | 2447 | // add next format here... |
2448 | return e_fileFormat; | 2448 | return e_fileFormat; |
2449 | } | 2449 | } |
2450 | return e_invalidArg; | 2450 | return e_invalidArg; |
2451 | } | 2451 | } |
2452 | 2452 | ||
2453 | PwMerror PwMDoc::importText_PwM(const QString *file) | 2453 | PwMerror PwMDoc::importText_PwM(const QString *file) |
2454 | { | 2454 | { |
2455 | #ifndef PWM_EMBEDDED | 2455 | #ifndef PWM_EMBEDDED |
2456 | PWM_ASSERT(file); | 2456 | PWM_ASSERT(file); |
2457 | FILE *f; | 2457 | FILE *f; |
2458 | int tmp; | 2458 | int tmp; |
2459 | ssize_t ret; | 2459 | ssize_t ret; |
2460 | string curCat; | 2460 | string curCat; |
2461 | unsigned int entriesRead = 0; | 2461 | unsigned int entriesRead = 0; |
2462 | PwMDataItem currItem; | 2462 | PwMDataItem currItem; |
2463 | f = fopen(file->latin1(), "r"); | 2463 | f = fopen(file->latin1(), "r"); |
2464 | if (!f) | 2464 | if (!f) |
2465 | return e_openFile; | 2465 | return e_openFile; |
2466 | size_t ch_tmp_size = 1024; | 2466 | size_t ch_tmp_size = 1024; |
2467 | char *ch_tmp = (char*)malloc(ch_tmp_size); | 2467 | char *ch_tmp = (char*)malloc(ch_tmp_size); |
2468 | if (!ch_tmp) { | 2468 | if (!ch_tmp) { |
2469 | fclose(f); | 2469 | fclose(f); |
2470 | return e_outOfMem; | 2470 | return e_outOfMem; |
2471 | } | 2471 | } |
2472 | 2472 | ||
2473 | // - check header | 2473 | // - check header |
2474 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) // skip first line. | 2474 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) // skip first line. |
2475 | goto formatError; | 2475 | goto formatError; |
2476 | // check version-string and return version in "ch_tmp". | 2476 | // check version-string and return version in "ch_tmp". |
2477 | if (fscanf(f, "PwM v%s", ch_tmp) != 1) { | 2477 | if (fscanf(f, "PwM v%s", ch_tmp) != 1) { |
2478 | // header not recognized as PwM generated header | 2478 | // header not recognized as PwM generated header |
2479 | goto formatError; | 2479 | goto formatError; |
2480 | } | 2480 | } |
2481 | // set filepointer behind version-string-line previously checked | 2481 | // set filepointer behind version-string-line previously checked |
2482 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) | 2482 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) |
2483 | goto formatError; | 2483 | goto formatError; |
2484 | // skip next line containing the build-date | 2484 | // skip next line containing the build-date |
2485 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) | 2485 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) |
2486 | goto formatError; | 2486 | goto formatError; |
2487 | // read header termination line | 2487 | // read header termination line |
2488 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) | 2488 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) |
2489 | goto formatError; | 2489 | goto formatError; |
2490 | if (strcmp(ch_tmp, "==============================\n")) | 2490 | if (strcmp(ch_tmp, "==============================\n")) |
2491 | goto formatError; | 2491 | goto formatError; |
2492 | 2492 | ||
2493 | // - read entries | 2493 | // - read entries |
2494 | do { | 2494 | do { |
2495 | // find beginning of next category | 2495 | // find beginning of next category |
2496 | do { | 2496 | do { |
2497 | tmp = fgetc(f); | 2497 | tmp = fgetc(f); |
2498 | } while (tmp == '\n' && tmp != EOF); | 2498 | } while (tmp == '\n' && tmp != EOF); |
2499 | if (tmp == EOF) | 2499 | if (tmp == EOF) |
2500 | break; | 2500 | break; |
2501 | 2501 | ||
2502 | // decrement filepos by one | 2502 | // decrement filepos by one |
2503 | fseek(f, -1, SEEK_CUR); | 2503 | fseek(f, -1, SEEK_CUR); |
2504 | // read cat-name | 2504 | // read cat-name |
2505 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) | 2505 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) |
2506 | goto formatError; | 2506 | goto formatError; |
2507 | // check cat-name format | 2507 | // check cat-name format |
2508 | if (memcmp(ch_tmp, "== Category: ", 13) != 0) | 2508 | if (memcmp(ch_tmp, "== Category: ", 13) != 0) |
2509 | goto formatError; | 2509 | goto formatError; |
2510 | if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " ==", 3) != 0) | 2510 | if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " ==", 3) != 0) |
2511 | goto formatError; | 2511 | goto formatError; |
2512 | // copy cat-name | 2512 | // copy cat-name |
2513 | curCat.assign(ch_tmp + 13, strlen(ch_tmp) - 1 - 16); | 2513 | curCat.assign(ch_tmp + 13, strlen(ch_tmp) - 1 - 16); |
2514 | 2514 | ||
2515 | do { | 2515 | do { |
2516 | // find beginning of next entry | 2516 | // find beginning of next entry |
2517 | do { | 2517 | do { |
2518 | tmp = fgetc(f); | 2518 | tmp = fgetc(f); |
2519 | } while (tmp == '\n' && tmp != EOF && tmp != '='); | 2519 | } while (tmp == '\n' && tmp != EOF && tmp != '='); |
2520 | if (tmp == EOF) | 2520 | if (tmp == EOF) |
2521 | break; | 2521 | break; |
2522 | if (tmp == '=') { | 2522 | if (tmp == '=') { |
2523 | fseek(f, -1, SEEK_CUR); | 2523 | fseek(f, -1, SEEK_CUR); |
2524 | break; | 2524 | break; |
2525 | } | 2525 | } |
2526 | // decrement filepos by one | 2526 | // decrement filepos by one |
2527 | fseek(f, -1, SEEK_CUR); | 2527 | fseek(f, -1, SEEK_CUR); |
2528 | // read desc-line | 2528 | // read desc-line |
2529 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) | 2529 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) |
2530 | goto formatError; | 2530 | goto formatError; |
2531 | // check desc-line format | 2531 | // check desc-line format |
2532 | if (memcmp(ch_tmp, "-- ", 3) != 0) | 2532 | if (memcmp(ch_tmp, "-- ", 3) != 0) |
2533 | goto formatError; | 2533 | goto formatError; |
2534 | if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " --", 3) != 0) | 2534 | if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " --", 3) != 0) |
2535 | goto formatError; | 2535 | goto formatError; |
2536 | // add desc-line | 2536 | // add desc-line |
2537 | currItem.desc.assign(ch_tmp + 3, strlen(ch_tmp) - 1 - 6); | 2537 | currItem.desc.assign(ch_tmp + 3, strlen(ch_tmp) - 1 - 6); |
2538 | 2538 | ||
2539 | // read username-line | 2539 | // read username-line |
2540 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) | 2540 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) |
2541 | goto formatError; | 2541 | goto formatError; |
2542 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.name)) | 2542 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.name)) |
2543 | goto formatError; | 2543 | goto formatError; |
2544 | 2544 | ||
2545 | // read pw-line | 2545 | // read pw-line |
2546 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) | 2546 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) |
2547 | goto formatError; | 2547 | goto formatError; |
2548 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.pw)) | 2548 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.pw)) |
2549 | goto formatError; | 2549 | goto formatError; |
2550 | 2550 | ||
2551 | // read comment-line | 2551 | // read comment-line |
2552 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) | 2552 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) |
2553 | goto formatError; | 2553 | goto formatError; |
2554 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.comment)) | 2554 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.comment)) |
2555 | goto formatError; | 2555 | goto formatError; |
2556 | 2556 | ||
2557 | // read URL-line | 2557 | // read URL-line |
2558 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) | 2558 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) |
2559 | goto formatError; | 2559 | goto formatError; |
2560 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.url)) | 2560 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.url)) |
2561 | goto formatError; | 2561 | goto formatError; |
2562 | 2562 | ||
2563 | // read launcher-line | 2563 | // read launcher-line |
2564 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) | 2564 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) |
2565 | goto formatError; | 2565 | goto formatError; |
2566 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.launcher)) | 2566 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.launcher)) |
2567 | goto formatError; | 2567 | goto formatError; |
2568 | 2568 | ||
2569 | currItem.lockStat = true; | 2569 | currItem.lockStat = true; |
2570 | currItem.listViewPos = -1; | 2570 | currItem.listViewPos = -1; |
2571 | addEntry(curCat.c_str(), &currItem, true); | 2571 | addEntry(curCat.c_str(), &currItem, true); |
2572 | ++entriesRead; | 2572 | ++entriesRead; |
2573 | } while (1); | 2573 | } while (1); |
2574 | } while (1); | 2574 | } while (1); |
2575 | if (!entriesRead) | 2575 | if (!entriesRead) |
2576 | goto formatError; | 2576 | goto formatError; |
2577 | 2577 | ||
2578 | free(ch_tmp); | 2578 | free(ch_tmp); |
2579 | fclose(f); | 2579 | fclose(f); |
2580 | flagDirty(); | 2580 | flagDirty(); |
2581 | return e_success; | 2581 | return e_success; |
2582 | 2582 | ||
2583 | formatError: | 2583 | formatError: |
2584 | free(ch_tmp); | 2584 | free(ch_tmp); |
2585 | fclose(f); | 2585 | fclose(f); |
2586 | return e_fileFormat; | 2586 | return e_fileFormat; |
2587 | #else | 2587 | #else |
2588 | PWM_ASSERT(file); | 2588 | PWM_ASSERT(file); |
2589 | QFile f(file->latin1()); | 2589 | QFile f(file->latin1()); |
2590 | int tmp; | 2590 | int tmp; |
2591 | ssize_t ret; | 2591 | ssize_t ret; |
2592 | string curCat; | 2592 | string curCat; |
2593 | unsigned int entriesRead = 0; | 2593 | unsigned int entriesRead = 0; |
2594 | PwMDataItem currItem; | 2594 | PwMDataItem currItem; |
2595 | bool res = f.open(IO_ReadOnly); | 2595 | bool res = f.open(IO_ReadOnly); |
2596 | if (res == false) | 2596 | if (res == false) |
2597 | return e_openFile; | 2597 | return e_openFile; |
2598 | 2598 | ||
2599 | unsigned int ch_tmp_size = 1024; | 2599 | unsigned int ch_tmp_size = 1024; |
2600 | char *ch_tmp = (char*)malloc(ch_tmp_size); | 2600 | char *ch_tmp = (char*)malloc(ch_tmp_size); |
2601 | if (!ch_tmp) { | 2601 | if (!ch_tmp) { |
2602 | f.close(); | 2602 | f.close(); |
2603 | return e_outOfMem; | 2603 | return e_outOfMem; |
2604 | } | 2604 | } |
2605 | 2605 | ||
2606 | // - check header | 2606 | // - check header |
2607 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) // skip first line. | 2607 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) // skip first line. |
2608 | goto formatError; | 2608 | goto formatError; |
2609 | 2609 | ||
2610 | //US read fileversion first, then check if ok. | 2610 | //US read fileversion first, then check if ok. |
2611 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) | 2611 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) |
2612 | goto formatError; | 2612 | goto formatError; |
2613 | 2613 | ||
2614 | // check version-string and return version in "ch_tmp". | 2614 | // check version-string and return version in "ch_tmp". |
2615 | //US if (fscanf(f, "PwM v%s", ch_tmp) != 1) { | 2615 | //US if (fscanf(f, "PwM v%s", ch_tmp) != 1) { |
2616 | //US // header not recognized as PwM generated header | 2616 | //US // header not recognized as PwM generated header |
2617 | //US goto formatError; | 2617 | //US goto formatError; |
2618 | //US} | 2618 | //US} |
2619 | //US set filepointer behind version-string-line previously checked | 2619 | //US set filepointer behind version-string-line previously checked |
2620 | //US if (f.readLine(ch_tmp, ch_tmp_size) == -1) | 2620 | //US if (f.readLine(ch_tmp, ch_tmp_size) == -1) |
2621 | //US goto formatError; | 2621 | //US goto formatError; |
2622 | // skip next line containing the build-date | 2622 | // skip next line containing the build-date |
2623 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) | 2623 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) |
2624 | goto formatError; | 2624 | goto formatError; |
2625 | // read header termination line | 2625 | // read header termination line |
2626 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) | 2626 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) |
2627 | goto formatError; | 2627 | goto formatError; |
2628 | if (strcmp(ch_tmp, "==============================\n")) | 2628 | if (strcmp(ch_tmp, "==============================\n")) |
2629 | goto formatError; | 2629 | goto formatError; |
2630 | 2630 | ||
2631 | // - read entries | 2631 | // - read entries |
2632 | do { | 2632 | do { |
2633 | // find beginning of next category | 2633 | // find beginning of next category |
2634 | do { | 2634 | do { |
2635 | tmp = f.getch(); | 2635 | tmp = f.getch(); |
2636 | } while (tmp == '\n' && tmp != EOF); | 2636 | } while (tmp == '\n' && tmp != EOF); |
2637 | if (tmp == EOF) | 2637 | if (tmp == EOF) |
2638 | break; | 2638 | break; |
2639 | 2639 | ||
2640 | // decrement filepos by one | 2640 | // decrement filepos by one |
2641 | f.at(f.at()-1); | 2641 | f.at(f.at()-1); |
2642 | // read cat-name | 2642 | // read cat-name |
2643 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) | 2643 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) |
2644 | goto formatError; | 2644 | goto formatError; |
2645 | // check cat-name format | 2645 | // check cat-name format |
2646 | if (memcmp(ch_tmp, "== Category: ", 13) != 0) | 2646 | if (memcmp(ch_tmp, "== Category: ", 13) != 0) |
2647 | goto formatError; | 2647 | goto formatError; |
2648 | if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " ==", 3) != 0) | 2648 | if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " ==", 3) != 0) |
2649 | goto formatError; | 2649 | goto formatError; |
2650 | // copy cat-name | 2650 | // copy cat-name |
2651 | curCat.assign(ch_tmp + 13, strlen(ch_tmp) - 1 - 16); | 2651 | curCat.assign(ch_tmp + 13, strlen(ch_tmp) - 1 - 16); |
2652 | 2652 | ||
2653 | do { | 2653 | do { |
2654 | // find beginning of next entry | 2654 | // find beginning of next entry |
2655 | do { | 2655 | do { |
2656 | tmp = f.getch(); | 2656 | tmp = f.getch(); |
2657 | } while (tmp == '\n' && tmp != EOF && tmp != '='); | 2657 | } while (tmp == '\n' && tmp != EOF && tmp != '='); |
2658 | if (tmp == EOF) | 2658 | if (tmp == EOF) |
2659 | break; | 2659 | break; |
2660 | if (tmp == '=') { | 2660 | if (tmp == '=') { |
2661 | f.at(f.at()-1); | 2661 | f.at(f.at()-1); |
2662 | break; | 2662 | break; |
2663 | } | 2663 | } |
2664 | // decrement filepos by one | 2664 | // decrement filepos by one |
2665 | f.at(f.at()-1); | 2665 | f.at(f.at()-1); |
2666 | // read desc-line | 2666 | // read desc-line |
2667 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) | 2667 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) |
2668 | goto formatError; | 2668 | goto formatError; |
2669 | // check desc-line format | 2669 | // check desc-line format |
2670 | if (memcmp(ch_tmp, "-- ", 3) != 0) | 2670 | if (memcmp(ch_tmp, "-- ", 3) != 0) |
2671 | goto formatError; | 2671 | goto formatError; |
2672 | if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " --", 3) != 0) | 2672 | if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " --", 3) != 0) |
2673 | goto formatError; | 2673 | goto formatError; |
2674 | // add desc-line | 2674 | // add desc-line |
2675 | currItem.desc.assign(ch_tmp + 3, strlen(ch_tmp) - 1 - 6); | 2675 | currItem.desc.assign(ch_tmp + 3, strlen(ch_tmp) - 1 - 6); |
2676 | 2676 | ||
2677 | // read username-line | 2677 | // read username-line |
2678 | if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) | 2678 | if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) |
2679 | goto formatError; | 2679 | goto formatError; |
2680 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.name)) | 2680 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.name)) |
2681 | goto formatError; | 2681 | goto formatError; |
2682 | 2682 | ||
2683 | // read pw-line | 2683 | // read pw-line |
2684 | if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) | 2684 | if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) |
2685 | goto formatError; | 2685 | goto formatError; |
2686 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.pw)) | 2686 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.pw)) |
2687 | goto formatError; | 2687 | goto formatError; |
2688 | 2688 | ||
2689 | // read comment-line | 2689 | // read comment-line |
2690 | if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) | 2690 | if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) |
2691 | goto formatError; | 2691 | goto formatError; |
2692 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.comment)) | 2692 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.comment)) |
2693 | goto formatError; | 2693 | goto formatError; |
2694 | 2694 | ||
2695 | // read URL-line | 2695 | // read URL-line |
2696 | if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) | 2696 | if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) |
2697 | goto formatError; | 2697 | goto formatError; |
2698 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.url)) | 2698 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.url)) |
2699 | goto formatError; | 2699 | goto formatError; |
2700 | 2700 | ||
2701 | // read launcher-line | 2701 | // read launcher-line |
2702 | if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) | 2702 | if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) |
2703 | goto formatError; | 2703 | goto formatError; |
2704 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.launcher)) | 2704 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.launcher)) |
2705 | goto formatError; | 2705 | goto formatError; |
2706 | 2706 | ||
2707 | currItem.lockStat = true; | 2707 | currItem.lockStat = true; |
2708 | currItem.listViewPos = -1; | 2708 | currItem.listViewPos = -1; |
2709 | addEntry(curCat.c_str(), &currItem, true); | 2709 | addEntry(curCat.c_str(), &currItem, true); |
2710 | ++entriesRead; | 2710 | ++entriesRead; |
2711 | } while (1); | 2711 | } while (1); |
2712 | } while (1); | 2712 | } while (1); |
2713 | if (!entriesRead) | 2713 | if (!entriesRead) |
2714 | goto formatError; | 2714 | goto formatError; |
2715 | 2715 | ||
2716 | free(ch_tmp); | 2716 | free(ch_tmp); |
2717 | f.close(); | 2717 | f.close(); |
2718 | flagDirty(); | 2718 | flagDirty(); |
2719 | return e_success; | 2719 | return e_success; |
2720 | 2720 | ||
2721 | formatError: | 2721 | formatError: |
2722 | free(ch_tmp); | 2722 | free(ch_tmp); |
2723 | f.close(); | 2723 | f.close(); |
2724 | return e_fileFormat; | 2724 | return e_fileFormat; |
2725 | 2725 | ||
2726 | #endif | 2726 | #endif |
2727 | 2727 | ||
2728 | } | 2728 | } |
2729 | 2729 | ||
2730 | bool PwMDoc::textExtractEntry_PwM(const char *in, ssize_t in_size, string *out) | 2730 | bool PwMDoc::textExtractEntry_PwM(const char *in, ssize_t in_size, string *out) |
2731 | { | 2731 | { |
2732 | PWM_ASSERT(in && out); | 2732 | PWM_ASSERT(in && out); |
2733 | ssize_t i = 0, len = in_size - 1; | 2733 | ssize_t i = 0, len = in_size - 1; |
2734 | while (i < len) { | 2734 | while (i < len) { |
2735 | if (in[i] == ':') | 2735 | if (in[i] == ':') |
2736 | break; | 2736 | break; |
2737 | ++i; | 2737 | ++i; |
2738 | } | 2738 | } |
2739 | i += 2; | 2739 | i += 2; |
2740 | *out = ""; | 2740 | *out = ""; |
2741 | out->append(in + i, in_size - i - 1); | 2741 | out->append(in + i, in_size - i - 1); |
2742 | return true; | 2742 | return true; |
2743 | } | 2743 | } |
2744 | 2744 | ||
2745 | PwMerror PwMDoc::exportToGpasman(const QString *file) | 2745 | PwMerror PwMDoc::exportToGpasman(const QString *file) |
2746 | { | 2746 | { |
2747 | PWM_ASSERT(file); | 2747 | PWM_ASSERT(file); |
2748 | GpasmanFile gp; | 2748 | GpasmanFile gp; |
2749 | int ret; | 2749 | int ret; |
2750 | 2750 | ||
2751 | if (!unlockAll_tempoary()) | 2751 | if (!unlockAll_tempoary()) |
2752 | return e_lock; | 2752 | return e_lock; |
2753 | 2753 | ||
2754 | QString gpmPassword; | 2754 | QString gpmPassword; |
2755 | while (1) { | 2755 | while (1) { |
2756 | gpmPassword = requestNewMpw(0); | 2756 | gpmPassword = requestNewMpw(0); |
2757 | if (gpmPassword == "") { | 2757 | if (gpmPassword == "") { |
2758 | unlockAll_tempoary(true); | 2758 | unlockAll_tempoary(true); |
2759 | return e_noPw; | 2759 | return e_noPw; |
2760 | } | 2760 | } |
2761 | if (gpmPassword.length() < 4) { | 2761 | if (gpmPassword.length() < 4) { |
2762 | gpmPwLenErrMsgBox(); | 2762 | gpmPwLenErrMsgBox(); |
2763 | } else { | 2763 | } else { |
2764 | break; | 2764 | break; |
2765 | } | 2765 | } |
2766 | } | 2766 | } |
2767 | 2767 | ||
2768 | ret = gp.save_init(file->latin1(), gpmPassword.latin1()); | 2768 | ret = gp.save_init(file->latin1(), gpmPassword.latin1()); |
2769 | if (ret != 1) { | 2769 | if (ret != 1) { |
2770 | unlockAll_tempoary(true); | 2770 | unlockAll_tempoary(true); |
2771 | return e_accessFile; | 2771 | return e_accessFile; |
2772 | } | 2772 | } |
2773 | 2773 | ||
2774 | char *entry[4]; | 2774 | char *entry[4]; |
2775 | unsigned int numCat = numCategories(), i; | 2775 | unsigned int numCat = numCategories(), i; |
2776 | unsigned int numEntr, j; | 2776 | unsigned int numEntr, j; |
2777 | int descLen, nameLen, pwLen, commentLen; | 2777 | int descLen, nameLen, pwLen, commentLen; |
2778 | for (i = 0; i < numCat; ++i) { | 2778 | for (i = 0; i < numCat; ++i) { |
2779 | numEntr = numEntries(i); | 2779 | numEntr = numEntries(i); |
2780 | for (j = 0; j < numEntr; ++j) { | 2780 | for (j = 0; j < numEntr; ++j) { |
2781 | descLen = dti.dta[i].d[j].desc.length(); | 2781 | descLen = dti.dta[i].d[j].desc.length(); |
2782 | nameLen = dti.dta[i].d[j].name.length(); | 2782 | nameLen = dti.dta[i].d[j].name.length(); |
2783 | pwLen = dti.dta[i].d[j].pw.length(); | 2783 | pwLen = dti.dta[i].d[j].pw.length(); |
2784 | commentLen = dti.dta[i].d[j].comment.length(); | 2784 | commentLen = dti.dta[i].d[j].comment.length(); |
2785 | entry[0] = new char[descLen + 1]; | 2785 | entry[0] = new char[descLen + 1]; |
2786 | entry[1] = new char[nameLen + 1]; | 2786 | entry[1] = new char[nameLen + 1]; |
2787 | entry[2] = new char[pwLen + 1]; | 2787 | entry[2] = new char[pwLen + 1]; |
2788 | entry[3] = new char[commentLen + 1]; | 2788 | entry[3] = new char[commentLen + 1]; |
2789 | strcpy(entry[0], descLen == 0 ? " " : dti.dta[i].d[j].desc.c_str()); | 2789 | strcpy(entry[0], descLen == 0 ? " " : dti.dta[i].d[j].desc.c_str()); |
2790 | strcpy(entry[1], nameLen == 0 ? " " : dti.dta[i].d[j].name.c_str()); | 2790 | strcpy(entry[1], nameLen == 0 ? " " : dti.dta[i].d[j].name.c_str()); |
2791 | strcpy(entry[2], pwLen == 0 ? " " : dti.dta[i].d[j].pw.c_str()); | 2791 | strcpy(entry[2], pwLen == 0 ? " " : dti.dta[i].d[j].pw.c_str()); |
2792 | strcpy(entry[3], commentLen == 0 ? " " : dti.dta[i].d[j].comment.c_str()); | 2792 | strcpy(entry[3], commentLen == 0 ? " " : dti.dta[i].d[j].comment.c_str()); |
2793 | entry[0][descLen == 0 ? descLen + 1 : descLen] = '\0'; | 2793 | entry[0][descLen == 0 ? descLen + 1 : descLen] = '\0'; |
2794 | entry[1][nameLen == 0 ? nameLen + 1 : nameLen] = '\0'; | 2794 | entry[1][nameLen == 0 ? nameLen + 1 : nameLen] = '\0'; |
2795 | entry[2][pwLen == 0 ? pwLen + 1 : pwLen] = '\0'; | 2795 | entry[2][pwLen == 0 ? pwLen + 1 : pwLen] = '\0'; |
2796 | entry[3][commentLen == 0 ? commentLen + 1 : commentLen] = '\0'; | 2796 | entry[3][commentLen == 0 ? commentLen + 1 : commentLen] = '\0'; |
2797 | 2797 | ||
2798 | ret = gp.save_entry(entry); | 2798 | ret = gp.save_entry(entry); |
2799 | if (ret == -1){ | 2799 | if (ret == -1){ |
2800 | delete [] entry[0]; | 2800 | delete [] entry[0]; |
2801 | delete [] entry[1]; | 2801 | delete [] entry[1]; |
2802 | delete [] entry[2]; | 2802 | delete [] entry[2]; |
2803 | delete [] entry[3]; | 2803 | delete [] entry[3]; |
2804 | gp.save_finalize(); | 2804 | gp.save_finalize(); |
2805 | unlockAll_tempoary(true); | 2805 | unlockAll_tempoary(true); |
2806 | return e_writeFile; | 2806 | return e_writeFile; |
2807 | } | 2807 | } |
2808 | 2808 | ||
2809 | delete [] entry[0]; | 2809 | delete [] entry[0]; |
2810 | delete [] entry[1]; | 2810 | delete [] entry[1]; |
2811 | delete [] entry[2]; | 2811 | delete [] entry[2]; |
2812 | delete [] entry[3]; | 2812 | delete [] entry[3]; |
2813 | } | 2813 | } |
2814 | } | 2814 | } |
2815 | unlockAll_tempoary(true); | 2815 | unlockAll_tempoary(true); |
2816 | if (gp.save_finalize() == -1) | 2816 | if (gp.save_finalize() == -1) |
2817 | return e_writeFile; | 2817 | return e_writeFile; |
2818 | 2818 | ||
2819 | return e_success; | 2819 | return e_success; |
2820 | } | 2820 | } |
2821 | 2821 | ||
2822 | PwMerror PwMDoc::importFromGpasman(const QString *file) | 2822 | PwMerror PwMDoc::importFromGpasman(const QString *file) |
2823 | { | 2823 | { |
2824 | PWM_ASSERT(file); | 2824 | PWM_ASSERT(file); |
2825 | QString pw = requestMpw(false); | 2825 | QString pw = requestMpw(false); |
2826 | if (pw == "") | 2826 | if (pw == "") |
2827 | return e_noPw; | 2827 | return e_noPw; |
2828 | GpasmanFile gp; | 2828 | GpasmanFile gp; |
2829 | int ret, i; | 2829 | int ret, i; |
2830 | PwMerror ret2; | 2830 | PwMerror ret2; |
2831 | char *entry[4]; | 2831 | char *entry[4]; |
2832 | PwMDataItem tmpData; | 2832 | PwMDataItem tmpData; |
2833 | ret = gp.load_init(file->latin1(), pw.latin1()); | 2833 | ret = gp.load_init(file->latin1(), pw.latin1()); |
2834 | if (ret != 1) | 2834 | if (ret != 1) |
2835 | return e_accessFile; | 2835 | return e_accessFile; |
2836 | 2836 | ||
2837 | do { | 2837 | do { |
2838 | ret = gp.load_entry(entry); | 2838 | ret = gp.load_entry(entry); |
2839 | if(ret != 1) | 2839 | if(ret != 1) |
2840 | break; | 2840 | break; |
2841 | tmpData.desc = entry[0]; | 2841 | tmpData.desc = entry[0]; |
2842 | tmpData.name = entry[1]; | 2842 | tmpData.name = entry[1]; |
2843 | tmpData.pw = entry[2]; | 2843 | tmpData.pw = entry[2]; |
2844 | tmpData.comment = entry[3]; | 2844 | tmpData.comment = entry[3]; |
2845 | tmpData.lockStat = true; | 2845 | tmpData.lockStat = true; |
2846 | tmpData.listViewPos = -1; | 2846 | tmpData.listViewPos = -1; |
2847 | ret2 = addEntry(DEFAULT_CATEGORY, &tmpData, true); | 2847 | ret2 = addEntry(DEFAULT_CATEGORY, &tmpData, true); |
2848 | for (i = 0; i < 4; ++i) | 2848 | for (i = 0; i < 4; ++i) |
2849 | free(entry[i]); | 2849 | free(entry[i]); |
2850 | if (ret2 == e_maxAllowedEntr) { | 2850 | if (ret2 == e_maxAllowedEntr) { |
2851 | gp.load_finalize(); | 2851 | gp.load_finalize(); |
2852 | return e_maxAllowedEntr; | 2852 | return e_maxAllowedEntr; |
2853 | } | 2853 | } |
2854 | } while (1); | 2854 | } while (1); |
2855 | gp.load_finalize(); | 2855 | gp.load_finalize(); |
2856 | if (isDocEmpty()) | 2856 | if (isDocEmpty()) |
2857 | return e_wrongPw; // we assume this. | 2857 | return e_wrongPw; // we assume this. |
2858 | 2858 | ||
2859 | flagDirty(); | 2859 | flagDirty(); |
2860 | return e_success; | 2860 | return e_success; |
2861 | } | 2861 | } |
2862 | 2862 | ||
2863 | 2863 | ||
2864 | //US: we use the stl sort algorythm to sort all elements in the order | 2864 | //US: we use the stl sort algorythm to sort all elements in the order |
2865 | //of its listViewPos (in the order 1,2,3,5,...,x,-1, -1, -1 | 2865 | //of its listViewPos (in the order 1,2,3,5,...,x,-1, -1, -1 |
2866 | struct PwMDataItemListViewPosSort | 2866 | struct PwMDataItemListViewPosSort |
2867 | { | 2867 | { |
2868 | bool operator()(PwMDataItem* rpStart, PwMDataItem* rpEnd) | 2868 | bool operator()(PwMDataItem* rpStart, PwMDataItem* rpEnd) |
2869 | { | 2869 | { |
2870 | //qDebug("pwMDoc::PwMDataItemListViewPosSort()"); | 2870 | //qDebug("pwMDoc::PwMDataItemListViewPosSort()"); |
2871 | if ((rpEnd)->listViewPos < 0) | 2871 | if ((rpEnd)->listViewPos < 0) |
2872 | return false; | 2872 | return false; |
2873 | else | 2873 | else |
2874 | return (rpStart)->listViewPos < (rpEnd)->listViewPos; | 2874 | return (rpStart)->listViewPos < (rpEnd)->listViewPos; |
2875 | } | 2875 | } |
2876 | }; | 2876 | }; |
2877 | 2877 | ||
2878 | void PwMDoc::ensureLvp() | 2878 | void PwMDoc::ensureLvp() |
2879 | { | 2879 | { |
2880 | if (isDocEmpty()) | 2880 | if (isDocEmpty()) |
2881 | return; | 2881 | return; |
2882 | 2882 | ||
2883 | //US ENH BUG: when using syncronizing, this way of sorting | 2883 | //US ENH BUG: when using syncronizing, this way of sorting |
2884 | //is not sufficient, because there might be empty spaces | 2884 | //is not sufficient, because there might be empty spaces |
2885 | // at the beginning. But the old algorythm only can add elements | 2885 | // at the beginning. But the old algorythm only can add elements |
2886 | //to the end.The result are crashes because of list overflows | 2886 | //to the end.The result are crashes because of list overflows |
2887 | //we need something to fill all gaps. | 2887 | //we need something to fill all gaps. |
2888 | vector<PwMDataItem*> sorted; | 2888 | vector<PwMDataItem*> sorted; |
2889 | vector< PwMDataItem*>::iterator sortedBegin, | 2889 | vector< PwMDataItem*>::iterator sortedBegin, |
2890 | sortedEnd, | 2890 | sortedEnd, |
2891 | sortedI; | 2891 | sortedI; |
2892 | vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), | 2892 | vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), |
2893 | catEnd = dti.dta.end(), | 2893 | catEnd = dti.dta.end(), |
2894 | catI = catBegin; | 2894 | catI = catBegin; |
2895 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; | 2895 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; |
2896 | int lvpTop, tmpLvp; | 2896 | int lvpTop, tmpLvp; |
2897 | 2897 | ||
2898 | //qDebug("collect:"); | 2898 | //qDebug("collect:"); |
2899 | 2899 | ||
2900 | while (catI != catEnd) { | 2900 | while (catI != catEnd) { |
2901 | lvpTop = -1; | 2901 | lvpTop = -1; |
2902 | sorted.clear(); | 2902 | sorted.clear(); |
2903 | 2903 | ||
2904 | entrBegin = catI->d.begin(); | 2904 | entrBegin = catI->d.begin(); |
2905 | entrEnd = catI->d.end(); | 2905 | entrEnd = catI->d.end(); |
2906 | entrI = entrBegin; | 2906 | entrI = entrBegin; |
2907 | 2907 | ||
2908 | //US: we use the stl sort algorythm to sort all elements in the order | 2908 | //US: we use the stl sort algorythm to sort all elements in the order |
2909 | //of its listViewPos (in the order 1,2,2,3,5,...,x,-1, -1, -1 | 2909 | //of its listViewPos (in the order 1,2,2,3,5,...,x,-1, -1, -1 |
2910 | while (entrI != entrEnd) { | 2910 | while (entrI != entrEnd) { |
2911 | //qDebug("found: %s, pos=%i", (*entrI).desc.c_str(), (*entrI).listViewPos); | 2911 | //qDebug("found: %s, pos=%i", (*entrI).desc.c_str(), (*entrI).listViewPos); |
2912 | sorted.push_back((PwMDataItem*)&(*entrI)); | 2912 | sorted.push_back((PwMDataItem*)&(*entrI)); |
2913 | ++entrI; | 2913 | ++entrI; |
2914 | } | 2914 | } |
2915 | 2915 | ||
2916 | sortedBegin = sorted.begin(); | 2916 | sortedBegin = sorted.begin(); |
2917 | sortedEnd = sorted.end(); | 2917 | sortedEnd = sorted.end(); |
2918 | 2918 | ||
2919 | sort(sortedBegin, sortedEnd, PwMDataItemListViewPosSort()); | 2919 | sort(sortedBegin, sortedEnd, PwMDataItemListViewPosSort()); |
2920 | 2920 | ||
2921 | // qDebug("resort:"); | 2921 | // qDebug("resort:"); |
2922 | //now we have all sorted in a collection | 2922 | //now we have all sorted in a collection |
2923 | //Now start with the sorted and reset listviewpos. | 2923 | //Now start with the sorted and reset listviewpos. |
2924 | sortedBegin = sorted.begin(); | 2924 | sortedBegin = sorted.begin(); |
2925 | sortedEnd = sorted.end(); | 2925 | sortedEnd = sorted.end(); |
2926 | sortedI = sortedBegin; | 2926 | sortedI = sortedBegin; |
2927 | 2927 | ||
2928 | while (sortedI != sortedEnd) { | 2928 | while (sortedI != sortedEnd) { |
2929 | // qDebug("reset defined: %s, from pos=%i to pos=%i", (*sortedI)->desc.c_str(), (*sortedI)->listViewPos, lvpTop+1); | 2929 | // qDebug("reset defined: %s, from pos=%i to pos=%i", (*sortedI)->desc.c_str(), (*sortedI)->listViewPos, lvpTop+1); |
2930 | (*sortedI)->listViewPos = ++lvpTop; | 2930 | (*sortedI)->listViewPos = ++lvpTop; |
2931 | ++sortedI; | 2931 | ++sortedI; |
2932 | } | 2932 | } |
2933 | 2933 | ||
2934 | /*/debug | 2934 | /*/debug |
2935 | entrBegin = catI->d.begin(); | 2935 | entrBegin = catI->d.begin(); |
2936 | entrEnd = catI->d.end(); | 2936 | entrEnd = catI->d.end(); |
2937 | entrI = entrBegin; | 2937 | entrI = entrBegin; |
2938 | 2938 | ||
2939 | while (entrI != entrEnd) { | 2939 | while (entrI != entrEnd) { |
2940 | qDebug("check: %s, pos=%i", (*entrI).desc.c_str(), (*entrI).listViewPos); | 2940 | qDebug("check: %s, pos=%i", (*entrI).desc.c_str(), (*entrI).listViewPos); |
2941 | ++entrI; | 2941 | ++entrI; |
2942 | } | 2942 | } |
2943 | */ | 2943 | */ |
2944 | 2944 | ||
2945 | ++catI; | 2945 | ++catI; |
2946 | } | 2946 | } |
2947 | } | 2947 | } |
2948 | 2948 | ||
2949 | QString PwMDoc::getTitle() | 2949 | QString PwMDoc::getTitle() |
2950 | { | 2950 | { |
2951 | /* NOTE: We have to ensure, that the returned title | 2951 | /* NOTE: We have to ensure, that the returned title |
2952 | * is unique and not reused somewhere else while | 2952 | * is unique and not reused somewhere else while |
2953 | * this document is valid (open). | 2953 | * this document is valid (open). |
2954 | */ | 2954 | */ |
2955 | QString title(getFilename()); | 2955 | QString title(getFilename()); |
2956 | 2956 | ||
2957 | //US ENH: The whole filename on PDAs is too long. So use only the last characters | 2957 | //US ENH: The whole filename on PDAs is too long. So use only the last characters |
2958 | if (QApplication::desktop()->width() < 640) | 2958 | if (QApplication::desktop()->width() < 640) |
2959 | { | 2959 | { |
2960 | if (title.length() > 30) | 2960 | if (title.length() > 30) |
2961 | title = "..." + title.right(30); | 2961 | title = "..." + title.right(30); |
2962 | 2962 | ||
2963 | } | 2963 | } |
2964 | 2964 | ||
2965 | 2965 | ||
2966 | if (title.isEmpty()) { | 2966 | if (title.isEmpty()) { |
2967 | if (unnamedNum == 0) { | 2967 | if (unnamedNum == 0) { |
2968 | unnamedNum = PwMDocList::getNewUnnamedNumber(); | 2968 | unnamedNum = PwMDocList::getNewUnnamedNumber(); |
2969 | PWM_ASSERT(unnamedNum != 0); | 2969 | PWM_ASSERT(unnamedNum != 0); |
2970 | } | 2970 | } |
2971 | title = DEFAULT_TITLE; | 2971 | title = DEFAULT_TITLE; |
2972 | title += " "; | 2972 | title += " "; |
2973 | title += tostr(unnamedNum).c_str(); | 2973 | title += tostr(unnamedNum).c_str(); |
2974 | } | 2974 | } |
2975 | return title; | 2975 | return title; |
2976 | } | 2976 | } |
2977 | 2977 | ||
2978 | bool PwMDoc::tryDelete() | 2978 | bool PwMDoc::tryDelete() |
2979 | { | 2979 | { |
2980 | 2980 | ||
2981 | if (deleted) | 2981 | if (deleted) |
2982 | return true; | 2982 | return true; |
2983 | int ret; | 2983 | int ret; |
2984 | if (isDirty()) { | 2984 | if (isDirty()) { |
2985 | ret = dirtyAskSave(getTitle()); | 2985 | ret = dirtyAskSave(getTitle()); |
2986 | if (ret == 0) { // save to disk | 2986 | if (ret == 0) { // save to disk |
2987 | if (!saveDocUi(this)) | 2987 | if (!saveDocUi(this)) |
2988 | goto out_ignore; | 2988 | goto out_ignore; |
2989 | } else if (ret == 1) { // don't save and delete | 2989 | } else if (ret == 1) { // don't save and delete |
2990 | goto out_accept; | 2990 | goto out_accept; |
2991 | } else { // cancel operation | 2991 | } else { // cancel operation |
2992 | goto out_ignore; | 2992 | goto out_ignore; |
2993 | } | 2993 | } |
2994 | } | 2994 | } |
2995 | out_accept: | 2995 | out_accept: |
2996 | deleted = true; | 2996 | deleted = true; |
2997 | delete this; | 2997 | delete this; |
2998 | return true; | 2998 | return true; |
2999 | out_ignore: | 2999 | out_ignore: |
3000 | return false; | 3000 | return false; |
3001 | } | 3001 | } |
3002 | 3002 | ||
3003 | 3003 | ||
3004 | 3004 | ||
3005 | #ifdef PWM_EMBEDDED | 3005 | #ifdef PWM_EMBEDDED |
3006 | //US ENH: this is the magic function that syncronizes the this doc with the remote doc | 3006 | //US ENH: this is the magic function that syncronizes the this doc with the remote doc |
3007 | //US it could have been defined as static, but I did not want to. | 3007 | //US it could have been defined as static, but I did not want to. |
3008 | PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* syncRemote, int mode ) | 3008 | PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* syncRemote, int mode ) |
3009 | { | 3009 | { |
3010 | int addedPasswordsLocal = 0; | 3010 | int addedPasswordsLocal = 0; |
3011 | int addedPasswordsRemote = 0; | 3011 | int addedPasswordsRemote = 0; |
3012 | int deletedPasswordsRemote = 0; | 3012 | int deletedPasswordsRemote = 0; |
3013 | int deletedPasswordsLocal = 0; | 3013 | int deletedPasswordsLocal = 0; |
3014 | int changedLocal = 0; | 3014 | int changedLocal = 0; |
3015 | int changedRemote = 0; | 3015 | int changedRemote = 0; |
3016 | 3016 | ||
3017 | PwMSyncItem* syncItemLocal; | 3017 | PwMSyncItem* syncItemLocal; |
3018 | PwMSyncItem* syncItemRemote; | 3018 | PwMSyncItem* syncItemRemote; |
3019 | 3019 | ||
3020 | QString mCurrentSyncName = manager->getCurrentSyncName(); | 3020 | QString mCurrentSyncName = manager->getCurrentSyncName(); |
3021 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3021 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3022 | 3022 | ||
3023 | bool fullDateRange = false; | 3023 | bool fullDateRange = false; |
3024 | int take; | 3024 | int take; |
3025 | // local->resetTempSyncStat(); | 3025 | // local->resetTempSyncStat(); |
3026 | QDateTime mLastSync = QDateTime::currentDateTime(); | 3026 | QDateTime mLastSync = QDateTime::currentDateTime(); |
3027 | QDateTime modifiedSync = mLastSync; | 3027 | QDateTime modifiedSync = mLastSync; |
3028 | 3028 | ||
3029 | unsigned int index; | 3029 | unsigned int index; |
3030 | //Step 1. Find syncinfo in Local file and create if not existent. | 3030 | //Step 1. Find syncinfo in Local file and create if not existent. |
3031 | bool found = syncLocal->findSyncData(mCurrentSyncDevice, &index); | 3031 | bool found = syncLocal->findSyncData(mCurrentSyncDevice, &index); |
3032 | if (found == false) | 3032 | if (found == false) |
3033 | { | 3033 | { |
3034 | PwMSyncItem newSyncItemLocal; | 3034 | PwMSyncItem newSyncItemLocal; |
3035 | newSyncItemLocal.syncName = mCurrentSyncDevice.latin1(); | 3035 | newSyncItemLocal.syncName = mCurrentSyncDevice.latin1(); |
3036 | newSyncItemLocal.lastSyncDate = mLastSync; | 3036 | newSyncItemLocal.lastSyncDate = mLastSync; |
3037 | syncLocal->addSyncDataEntry(&newSyncItemLocal, true); | 3037 | syncLocal->addSyncDataEntry(&newSyncItemLocal, true); |
3038 | found = syncLocal->findSyncData(mCurrentSyncDevice, &index); | 3038 | found = syncLocal->findSyncData(mCurrentSyncDevice, &index); |
3039 | if (found == false) { | 3039 | if (found == false) { |
3040 | qDebug("PwMDoc::syncronize : newly created local sync data could not be found"); | 3040 | qDebug("PwMDoc::syncronize : newly created local sync data could not be found"); |
3041 | return e_syncError; | 3041 | return e_syncError; |
3042 | } | 3042 | } |
3043 | } | 3043 | } |
3044 | 3044 | ||
3045 | syncItemLocal = syncLocal->getSyncDataEntry(index); | 3045 | syncItemLocal = syncLocal->getSyncDataEntry(index); |
3046 | qDebug("Last Sync Local %s ", syncItemLocal->lastSyncDate.toString().latin1()); | 3046 | qDebug("Last Sync Local %s ", syncItemLocal->lastSyncDate.toString().latin1()); |
3047 | 3047 | ||
3048 | //Step 2. Find syncinfo in remote file and create if not existent. | 3048 | //Step 2. Find syncinfo in remote file and create if not existent. |
3049 | found = syncRemote->findSyncData(mCurrentSyncName, &index); | 3049 | found = syncRemote->findSyncData(mCurrentSyncName, &index); |
3050 | if (found == false) | 3050 | if (found == false) |
3051 | { | 3051 | { |
3052 | qDebug("FULLDATE 1"); | 3052 | qDebug("FULLDATE 1"); |
3053 | fullDateRange = true; | 3053 | fullDateRange = true; |
3054 | PwMSyncItem newSyncItemRemote; | 3054 | PwMSyncItem newSyncItemRemote; |
3055 | newSyncItemRemote.syncName = mCurrentSyncName.latin1(); | 3055 | newSyncItemRemote.syncName = mCurrentSyncName.latin1(); |
3056 | newSyncItemRemote.lastSyncDate = mLastSync; | 3056 | newSyncItemRemote.lastSyncDate = mLastSync; |
3057 | syncRemote->addSyncDataEntry(&newSyncItemRemote, true); | 3057 | syncRemote->addSyncDataEntry(&newSyncItemRemote, true); |
3058 | found = syncRemote->findSyncData(mCurrentSyncName, &index); | 3058 | found = syncRemote->findSyncData(mCurrentSyncName, &index); |
3059 | if (found == false) { | 3059 | if (found == false) { |
3060 | qDebug("PwMDoc::syncronize : newly created remote sync data could not be found"); | 3060 | qDebug("PwMDoc::syncronize : newly created remote sync data could not be found"); |
3061 | return e_syncError; | 3061 | return e_syncError; |
3062 | } | 3062 | } |
3063 | } | 3063 | } |
3064 | 3064 | ||
3065 | syncItemRemote = syncRemote->getSyncDataEntry(index); | 3065 | syncItemRemote = syncRemote->getSyncDataEntry(index); |
3066 | qDebug("Last Sync Remote %s ", syncItemRemote->lastSyncDate.toString().latin1()); | 3066 | qDebug("Last Sync Remote %s ", syncItemRemote->lastSyncDate.toString().latin1()); |
3067 | //and remove the found entry here. We will reenter it later again. | 3067 | //and remove the found entry here. We will reenter it later again. |
3068 | //US syncRemote->delSyncDataEntry(index, true); | 3068 | //US syncRemote->delSyncDataEntry(index, true); |
3069 | 3069 | ||
3070 | 3070 | ||
3071 | if ( syncItemLocal->lastSyncDate == mLastSync ) { | 3071 | if ( syncItemLocal->lastSyncDate == mLastSync ) { |
3072 | qDebug("FULLDATE 2"); | 3072 | qDebug("FULLDATE 2"); |
3073 | fullDateRange = true; | 3073 | fullDateRange = true; |
3074 | } | 3074 | } |
3075 | 3075 | ||
3076 | if ( ! fullDateRange ) { | 3076 | if ( ! fullDateRange ) { |
3077 | if ( syncItemLocal->lastSyncDate != syncItemRemote->lastSyncDate ) { | 3077 | if ( syncItemLocal->lastSyncDate != syncItemRemote->lastSyncDate ) { |
3078 | 3078 | ||
3079 | fullDateRange = true; | 3079 | fullDateRange = true; |
3080 | qDebug("FULLDATE 3 %s %s", syncItemLocal->lastSyncDate.toString().latin1() , syncItemRemote->lastSyncDate.toString().latin1() ); | 3080 | qDebug("FULLDATE 3 %s %s", syncItemLocal->lastSyncDate.toString().latin1() , syncItemRemote->lastSyncDate.toString().latin1() ); |
3081 | } | 3081 | } |
3082 | } | 3082 | } |
3083 | // fullDateRange = true; // debug only! | 3083 | // fullDateRange = true; // debug only! |
3084 | if ( fullDateRange ) | 3084 | if ( fullDateRange ) |
3085 | mLastSync = QDateTime::currentDateTime().addDays( -100*365); | 3085 | mLastSync = QDateTime::currentDateTime().addDays( -100*365); |
3086 | else | 3086 | else |
3087 | mLastSync = syncItemLocal->lastSyncDate; | 3087 | mLastSync = syncItemLocal->lastSyncDate; |
3088 | 3088 | ||
3089 | 3089 | ||
3090 | qDebug("*************************** "); | 3090 | qDebug("*************************** "); |
3091 | qDebug("mLastSync %s ",mLastSync.toString().latin1() ); | 3091 | qDebug("mLastSync %s ",mLastSync.toString().latin1() ); |
3092 | QStringList er = syncRemote->getIDEntryList(); | 3092 | QStringList er = syncRemote->getIDEntryList(); |
3093 | PwMDataItem* inRemote ;//= er.first(); | 3093 | PwMDataItem* inRemote ;//= er.first(); |
3094 | PwMDataItem* inLocal; | 3094 | PwMDataItem* inLocal; |
3095 | unsigned int catLocal, indexLocal; | 3095 | unsigned int catLocal, indexLocal; |
3096 | unsigned int catRemote, indexRemote; | 3096 | unsigned int catRemote, indexRemote; |
3097 | 3097 | ||
3098 | QString uid; | 3098 | QString uid; |
3099 | manager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 3099 | manager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
3100 | 3100 | ||
3101 | int modulo = (er.count()/10)+1; | 3101 | int modulo = (er.count()/10)+1; |
3102 | unsigned int incCounter = 0; | 3102 | unsigned int incCounter = 0; |
3103 | while ( incCounter < er.count()) { | 3103 | while ( incCounter < er.count()) { |
3104 | if (manager->isProgressBarCanceled()) | 3104 | if (manager->isProgressBarCanceled()) |
3105 | return e_syncError; | 3105 | return e_syncError; |
3106 | if ( incCounter % modulo == 0 ) | 3106 | if ( incCounter % modulo == 0 ) |
3107 | manager->showProgressBar(incCounter); | 3107 | manager->showProgressBar(incCounter); |
3108 | 3108 | ||
3109 | uid = er[ incCounter ]; | 3109 | uid = er[ incCounter ]; |
3110 | qDebug("sync uid %s from remote file", uid.latin1()); | 3110 | qDebug("sync uid %s from remote file", uid.latin1()); |
3111 | 3111 | ||
3112 | qApp->processEvents(); | 3112 | qApp->processEvents(); |
3113 | 3113 | ||
3114 | inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); | 3114 | inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); |
3115 | inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); | 3115 | inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); |
3116 | PWM_ASSERT(inRemote); | 3116 | PWM_ASSERT(inRemote); |
3117 | if ( inLocal != 0 ) { // maybe conflict - same uid in both files | 3117 | if ( inLocal != 0 ) { // maybe conflict - same uid in both files |
3118 | if ( (take = takePwMDataItem( inLocal, inRemote, mLastSync, mode, fullDateRange) ) ) { | 3118 | if ( (take = takePwMDataItem( inLocal, inRemote, mLastSync, mode, fullDateRange) ) ) { |
3119 | qDebug("take %d %s ", take, inLocal->desc.c_str()); | 3119 | qDebug("take %d %s ", take, inLocal->desc.c_str()); |
3120 | if ( take == 3 ) | 3120 | if ( take == 3 ) |
3121 | return e_syncError; | 3121 | return e_syncError; |
3122 | if ( take == 1 ) {// take local | 3122 | if ( take == 1 ) {// take local |
3123 | int oldlistpos = inRemote->listViewPos; | 3123 | int oldlistpos = inRemote->listViewPos; |
3124 | (*inRemote) = (*inLocal); | 3124 | (*inRemote) = (*inLocal); |
3125 | inRemote->listViewPos = oldlistpos; | 3125 | inRemote->listViewPos = oldlistpos; |
3126 | ++changedRemote; | 3126 | ++changedRemote; |
3127 | } else { // take == 2 take remote | 3127 | } else { // take == 2 take remote |
3128 | int oldlistpos = inLocal->listViewPos; | 3128 | int oldlistpos = inLocal->listViewPos; |
3129 | (*inLocal) = (*inRemote); | 3129 | (*inLocal) = (*inRemote); |
3130 | inLocal->listViewPos = oldlistpos; | 3130 | inLocal->listViewPos = oldlistpos; |
3131 | ++changedLocal; | 3131 | ++changedLocal; |
3132 | } | 3132 | } |
3133 | } | 3133 | } |
3134 | } else { // no conflict | 3134 | } else { // no conflict |
3135 | if ( inRemote->meta.update > mLastSync || mode == 5 ) { | 3135 | if ( inRemote->meta.update > mLastSync || mode == 5 ) { |
3136 | inRemote->meta.update = modifiedSync; | 3136 | inRemote->meta.update = modifiedSync; |
3137 | 3137 | ||
3138 | //first check if we have a matching category in the local file | 3138 | //first check if we have a matching category in the local file |
3139 | const string* remotecat = syncRemote->getCategory(catRemote); | 3139 | const string* remotecat = syncRemote->getCategory(catRemote); |
3140 | syncLocal->addEntry(remotecat->c_str(), inRemote, true, false); | 3140 | syncLocal->addEntry(remotecat->c_str(), inRemote, true, false); |
3141 | 3141 | ||
3142 | ++addedPasswordsLocal; | 3142 | ++addedPasswordsLocal; |
3143 | } else { | 3143 | } else { |
3144 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 3144 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
3145 | syncRemote->delEntry(catRemote, indexRemote, true); | 3145 | syncRemote->delEntry(catRemote, indexRemote, true); |
3146 | ++deletedPasswordsRemote; | 3146 | ++deletedPasswordsRemote; |
3147 | } | 3147 | } |
3148 | } | 3148 | } |
3149 | 3149 | ||
3150 | ++incCounter; | 3150 | ++incCounter; |
3151 | } | 3151 | } |
3152 | 3152 | ||
3153 | 3153 | ||
3154 | er.clear(); | 3154 | er.clear(); |
3155 | QStringList el = syncLocal->getIDEntryList(); | 3155 | QStringList el = syncLocal->getIDEntryList(); |
3156 | modulo = (el.count()/10)+1; | 3156 | modulo = (el.count()/10)+1; |
3157 | 3157 | ||
3158 | manager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 3158 | manager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
3159 | incCounter = 0; | 3159 | incCounter = 0; |
3160 | while ( incCounter < el.count()) { | 3160 | while ( incCounter < el.count()) { |
3161 | qApp->processEvents(); | 3161 | qApp->processEvents(); |
3162 | if (manager->isProgressBarCanceled()) | 3162 | if (manager->isProgressBarCanceled()) |
3163 | return e_syncError; | 3163 | return e_syncError; |
3164 | if ( incCounter % modulo == 0 ) | 3164 | if ( incCounter % modulo == 0 ) |
3165 | manager->showProgressBar(incCounter); | 3165 | manager->showProgressBar(incCounter); |
3166 | uid = el[ incCounter ]; | 3166 | uid = el[ incCounter ]; |
3167 | qDebug("sync uid %s from local file", uid.latin1()); | 3167 | qDebug("sync uid %s from local file", uid.latin1()); |
3168 | 3168 | ||
3169 | inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); | 3169 | inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); |
3170 | inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); | 3170 | inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); |
3171 | PWM_ASSERT(inLocal); | 3171 | PWM_ASSERT(inLocal); |
3172 | 3172 | ||
3173 | if ( inRemote == 0 ) { | 3173 | if ( inRemote == 0 ) { |
3174 | if ( inLocal->meta.update < mLastSync && mode != 4 ) { | 3174 | if ( inLocal->meta.update < mLastSync && mode != 4 ) { |
3175 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 3175 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
3176 | syncLocal->delEntry(catLocal, indexLocal, true); | 3176 | syncLocal->delEntry(catLocal, indexLocal, true); |
3177 | ++deletedPasswordsLocal; | 3177 | ++deletedPasswordsLocal; |
3178 | } else { | 3178 | } else { |
3179 | if ( ! manager->mWriteBackExistingOnly ) { | 3179 | if ( ! manager->mWriteBackExistingOnly ) { |
3180 | ++addedPasswordsRemote; | 3180 | ++addedPasswordsRemote; |
3181 | inLocal->meta.update = modifiedSync; | 3181 | inLocal->meta.update = modifiedSync; |
3182 | 3182 | ||
3183 | //first check if we have a matching category in the remote file | 3183 | //first check if we have a matching category in the remote file |
3184 | const string* localcat = syncLocal->getCategory(catLocal); | 3184 | const string* localcat = syncLocal->getCategory(catLocal); |
3185 | 3185 | ||
3186 | PwMDataItem newEntry; | 3186 | PwMDataItem newEntry; |
3187 | newEntry = *inLocal; | 3187 | newEntry = *inLocal; |
3188 | inRemote = &newEntry; | 3188 | inRemote = &newEntry; |
3189 | 3189 | ||
3190 | //USsyncRemote->insertAddressee( inRemote, false ); | 3190 | //USsyncRemote->insertAddressee( inRemote, false ); |
3191 | syncRemote->addEntry(localcat->c_str(), inRemote, true, false); | 3191 | syncRemote->addEntry(localcat->c_str(), inRemote, true, false); |
3192 | 3192 | ||
3193 | } | 3193 | } |
3194 | } | 3194 | } |
3195 | 3195 | ||
3196 | } | 3196 | } |
3197 | ++incCounter; | 3197 | ++incCounter; |
3198 | } | 3198 | } |
3199 | el.clear(); | 3199 | el.clear(); |
3200 | manager->hideProgressBar(); | 3200 | manager->hideProgressBar(); |
3201 | 3201 | ||
3202 | // Now write the info back into the sync data space of the files | 3202 | // Now write the info back into the sync data space of the files |
3203 | 3203 | ||
3204 | mLastSync = QDateTime::currentDateTime().addSecs( 1 ); | 3204 | mLastSync = QDateTime::currentDateTime().addSecs( 1 ); |
3205 | // get rid of micro seconds | 3205 | // get rid of micro seconds |
3206 | QTime t = mLastSync.time(); | 3206 | QTime t = mLastSync.time(); |
3207 | mLastSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 3207 | mLastSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
3208 | 3208 | ||
3209 | 3209 | ||
3210 | syncItemLocal->lastSyncDate = mLastSync; | 3210 | syncItemLocal->lastSyncDate = mLastSync; |
3211 | syncItemRemote->lastSyncDate = mLastSync; | 3211 | syncItemRemote->lastSyncDate = mLastSync; |
3212 | 3212 | ||
3213 | QString mes; | 3213 | QString mes; |
3214 | 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 ); | 3214 | 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 ); |
3215 | if ( manager->mShowSyncSummary ) { | 3215 | if ( manager->mShowSyncSummary ) { |
3216 | KMessageBox::information(0, mes, i18n("PWM/Pi Synchronization") ); | 3216 | KMessageBox::information(0, mes, i18n("PWM/Pi Synchronization") ); |
3217 | } | 3217 | } |
3218 | qDebug( mes ); | 3218 | qDebug( mes ); |
3219 | return e_success; | 3219 | return e_success; |
3220 | } | 3220 | } |
3221 | 3221 | ||
3222 | 3222 | ||
3223 | int PwMDoc::takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full ) | 3223 | int PwMDoc::takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full ) |
3224 | { | 3224 | { |
3225 | // 0 equal | 3225 | // 0 equal |
3226 | // 1 take local | 3226 | // 1 take local |
3227 | // 2 take remote | 3227 | // 2 take remote |
3228 | // 3 cancel | 3228 | // 3 cancel |
3229 | QDateTime localMod = local->meta.update; | 3229 | QDateTime localMod = local->meta.update; |
3230 | QDateTime remoteMod = remote->meta.update; | 3230 | QDateTime remoteMod = remote->meta.update; |
3231 | 3231 | ||
3232 | if ( localMod == remoteMod ) | 3232 | if ( localMod == remoteMod ) |
3233 | return 0; | 3233 | return 0; |
3234 | 3234 | ||
3235 | qDebug(" %d %d conflict on %s %s ", mode, full, local->desc.c_str(), remote->desc.c_str() ); | 3235 | qDebug(" %d %d conflict on %s %s ", mode, full, local->desc.c_str(), remote->desc.c_str() ); |
3236 | 3236 | ||
3237 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); | 3237 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); |
3238 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 3238 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
3239 | //full = true; //debug only | 3239 | //full = true; //debug only |
3240 | if ( full ) { | 3240 | if ( full ) { |
3241 | bool equ = ( (*local) == (*remote) ); | 3241 | bool equ = ( (*local) == (*remote) ); |
3242 | if ( equ ) { | 3242 | if ( equ ) { |
3243 | //qDebug("equal "); | 3243 | //qDebug("equal "); |
3244 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 3244 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
3245 | return 0; | 3245 | return 0; |
3246 | 3246 | ||
3247 | }//else //debug only | 3247 | }//else //debug only |
3248 | //qDebug("not equal %s %s ", local->desc.c_str(), remote->desc.c_str()); | 3248 | //qDebug("not equal %s %s ", local->desc.c_str(), remote->desc.c_str()); |
3249 | } | 3249 | } |
3250 | 3250 | ||
3251 | int result; | 3251 | int result; |
3252 | bool localIsNew; | 3252 | bool localIsNew; |
3253 | //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() ); | 3253 | //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() ); |
3254 | 3254 | ||
3255 | if ( full && mode < SYNC_PREF_NEWEST ) | 3255 | if ( full && mode < SYNC_PREF_NEWEST ) |
3256 | mode = SYNC_PREF_ASK; | 3256 | mode = SYNC_PREF_ASK; |
3257 | 3257 | ||
3258 | switch( mode ) { | 3258 | switch( mode ) { |
3259 | case SYNC_PREF_LOCAL: | 3259 | case SYNC_PREF_LOCAL: |
3260 | if ( lastSync > remoteMod ) | 3260 | if ( lastSync > remoteMod ) |
3261 | return 1; | 3261 | return 1; |
3262 | if ( lastSync > localMod ) | 3262 | if ( lastSync > localMod ) |
3263 | return 2; | 3263 | return 2; |
3264 | return 1; | 3264 | return 1; |
3265 | break; | 3265 | break; |
3266 | case SYNC_PREF_REMOTE: | 3266 | case SYNC_PREF_REMOTE: |
3267 | if ( lastSync > remoteMod ) | 3267 | if ( lastSync > remoteMod ) |
3268 | return 1; | 3268 | return 1; |
3269 | if ( lastSync > localMod ) | 3269 | if ( lastSync > localMod ) |
3270 | return 2; | 3270 | return 2; |
3271 | return 2; | 3271 | return 2; |
3272 | break; | 3272 | break; |
3273 | case SYNC_PREF_NEWEST: | 3273 | case SYNC_PREF_NEWEST: |
3274 | if ( localMod > remoteMod ) | 3274 | if ( localMod > remoteMod ) |
3275 | return 1; | 3275 | return 1; |
3276 | else | 3276 | else |
3277 | return 2; | 3277 | return 2; |
3278 | break; | 3278 | break; |
3279 | case SYNC_PREF_ASK: | 3279 | case SYNC_PREF_ASK: |
3280 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 3280 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
3281 | if ( lastSync > remoteMod ) | 3281 | if ( lastSync > remoteMod ) |
3282 | return 1; | 3282 | return 1; |
3283 | if ( lastSync > localMod ) | 3283 | if ( lastSync > localMod ) |
3284 | return 2; | 3284 | return 2; |
3285 | localIsNew = localMod >= remoteMod; | 3285 | localIsNew = localMod >= remoteMod; |
3286 | //qDebug("conflict! ************************************** "); | 3286 | //qDebug("conflict! ************************************** "); |
3287 | { | 3287 | { |
3288 | PwMDataItemChooser acd ( *local,*remote, localIsNew , 0/*this*/ ); | 3288 | PwMDataItemChooser acd ( *local,*remote, localIsNew , 0/*this*/ ); |
3289 | result = acd.executeD(localIsNew); | 3289 | result = acd.executeD(localIsNew); |
3290 | return result; | 3290 | return result; |
3291 | } | 3291 | } |
3292 | break; | 3292 | break; |
3293 | case SYNC_PREF_FORCE_LOCAL: | 3293 | case SYNC_PREF_FORCE_LOCAL: |
3294 | return 1; | 3294 | return 1; |
3295 | break; | 3295 | break; |
3296 | case SYNC_PREF_FORCE_REMOTE: | 3296 | case SYNC_PREF_FORCE_REMOTE: |
3297 | return 2; | 3297 | return 2; |
3298 | break; | 3298 | break; |
3299 | 3299 | ||
3300 | default: | 3300 | default: |
3301 | // SYNC_PREF_TAKE_BOTH not implemented | 3301 | // SYNC_PREF_TAKE_BOTH not implemented |
3302 | break; | 3302 | break; |
3303 | } | 3303 | } |
3304 | return 0; | 3304 | return 0; |
3305 | } | 3305 | } |
3306 | 3306 | ||
3307 | 3307 | void PwMDoc::removeSyncInfo( QString syncProfile) | |
3308 | { | ||
3309 | qDebug("PwMDoc::not implemented: removeSyncInfo for profile %s ", syncProfile.latin1()); | ||
3310 | } | ||
3308 | 3311 | ||
3309 | 3312 | ||
3310 | //this are the overwritten callbackmethods from the syncinterface | 3313 | //this are the overwritten callbackmethods from the syncinterface |
3311 | bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode) | 3314 | bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode) |
3312 | { | 3315 | { |
3313 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3316 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3314 | 3317 | ||
3315 | //1) unlock local file first if necessary (ask for password) | 3318 | //1) unlock local file first if necessary (ask for password) |
3316 | if (this->isDeepLocked()) { | 3319 | if (this->isDeepLocked()) { |
3317 | PwMerror ret = this->deepLock(false); | 3320 | PwMerror ret = this->deepLock(false); |
3318 | if (ret != e_success) | 3321 | if (ret != e_success) |
3319 | return false; | 3322 | return false; |
3320 | } | 3323 | } |
3321 | 3324 | ||
3322 | //2) construct and open a new doc on the stack(automatic cleanup of remote file). | 3325 | //2) construct and open a new doc on the stack(automatic cleanup of remote file). |
3323 | PwMDoc syncTarget(this, "synctarget"); | 3326 | PwMDoc syncTarget(this, "synctarget"); |
3324 | PwMDoc* pSyncTarget = &syncTarget; | 3327 | PwMDoc* pSyncTarget = &syncTarget; |
3325 | 3328 | ||
3326 | 3329 | ||
3327 | PwMerror err = pSyncTarget->openDoc(&filename, 1 /*== open with all entries locked*/); | 3330 | PwMerror err = pSyncTarget->openDoc(&filename, 1 /*== open with all entries locked*/); |
3328 | 3331 | ||
3329 | if (err == e_alreadyOpen) { | 3332 | if (err == e_alreadyOpen) { |
3330 | PwMDocList::listItem li; | 3333 | PwMDocList::listItem li; |
3331 | if (getOpenDocList()->find(filename.latin1(), &li)) | 3334 | if (getOpenDocList()->find(filename.latin1(), &li)) |
3332 | pSyncTarget = li.doc; | 3335 | pSyncTarget = li.doc; |
3333 | else { | 3336 | else { |
3334 | qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); | 3337 | qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); |
3335 | return false; | 3338 | return false; |
3336 | } | 3339 | } |
3337 | } | 3340 | } |
3338 | else if (err != e_success) { | 3341 | else if (err != e_success) { |
3339 | qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); | 3342 | qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); |
3340 | return false; | 3343 | return false; |
3341 | } | 3344 | } |
3342 | 3345 | ||
3343 | qDebug("PWM file loaded %s,sync mode %d",filename.latin1(), mode ); | 3346 | qDebug("PWM file loaded %s,sync mode %d",filename.latin1(), mode ); |
3344 | 3347 | ||
3345 | 3348 | ||
3346 | //3) unlock remote file first if necessary (ask for password) | 3349 | //3) unlock remote file first if necessary (ask for password) |
3347 | if (pSyncTarget->isDeepLocked()) { | 3350 | if (pSyncTarget->isDeepLocked()) { |
3348 | PwMerror ret = pSyncTarget->deepLock(false); | 3351 | PwMerror ret = pSyncTarget->deepLock(false); |
3349 | if (ret != e_success) | 3352 | if (ret != e_success) |
3350 | return false; | 3353 | return false; |
3351 | } | 3354 | } |
3352 | 3355 | ||
3353 | 3356 | ||
3354 | err = syncronize(manager, this, pSyncTarget, mode ); | 3357 | err = syncronize(manager, this, pSyncTarget, mode ); |
3355 | 3358 | ||
3356 | if (err == e_success) { | 3359 | if (err == e_success) { |
3357 | if ( manager->mWriteBackFile ){ | 3360 | if ( manager->mWriteBackFile ){ |
3358 | qDebug("Saving remote PWManager file"); | 3361 | qDebug("Saving remote PWManager file"); |
3359 | err = pSyncTarget->saveDoc(conf()->confGlobCompression()); | 3362 | err = pSyncTarget->saveDoc(conf()->confGlobCompression()); |
3360 | if (err != e_success) { | 3363 | if (err != e_success) { |
3361 | qDebug("PwmDoc::sync: Sync failed. Error %i while storing file %s",err, filename.latin1()); | 3364 | qDebug("PwmDoc::sync: Sync failed. Error %i while storing file %s",err, filename.latin1()); |
3362 | return false; | 3365 | return false; |
3363 | } | 3366 | } |
3364 | } | 3367 | } |
3365 | 3368 | ||
3366 | flagDirty(); | 3369 | flagDirty(); |
3367 | return true; | 3370 | return true; |
3368 | } | 3371 | } |
3369 | else { | 3372 | else { |
3370 | return false; | 3373 | return false; |
3371 | } | 3374 | } |
3372 | } | 3375 | } |
3373 | 3376 | ||
3374 | #endif | 3377 | #endif |
3375 | 3378 | ||
3376 | 3379 | ||
3377 | bool PwMDoc::findSyncData(const QString &syncname, unsigned int *index) | 3380 | bool PwMDoc::findSyncData(const QString &syncname, unsigned int *index) |
3378 | { | 3381 | { |
3379 | vector<PwMSyncItem>::iterator i = dti.syncDta.begin(), | 3382 | vector<PwMSyncItem>::iterator i = dti.syncDta.begin(), |
3380 | end = dti.syncDta.end(); | 3383 | end = dti.syncDta.end(); |
3381 | 3384 | ||
3382 | while (i != end) { | 3385 | while (i != end) { |
3383 | if ((*i).syncName == syncname.latin1()) { | 3386 | if ((*i).syncName == syncname.latin1()) { |
3384 | if (index) { | 3387 | if (index) { |
3385 | *index = i - dti.syncDta.begin(); | 3388 | *index = i - dti.syncDta.begin(); |
3386 | } | 3389 | } |
3387 | return true; | 3390 | return true; |
3388 | } | 3391 | } |
3389 | ++i; | 3392 | ++i; |
3390 | } | 3393 | } |
3391 | return false; | 3394 | return false; |
3392 | }; | 3395 | }; |
3393 | 3396 | ||
3394 | /** add new syncdataentry */ | 3397 | /** add new syncdataentry */ |
3395 | PwMerror PwMDoc::addSyncDataEntry(PwMSyncItem *d, bool dontFlagDirty) | 3398 | PwMerror PwMDoc::addSyncDataEntry(PwMSyncItem *d, bool dontFlagDirty) |
3396 | { | 3399 | { |
3397 | PWM_ASSERT(d); | 3400 | PWM_ASSERT(d); |
3398 | 3401 | ||
3399 | if (isDeepLocked()) { | 3402 | if (isDeepLocked()) { |
3400 | PwMerror ret; | 3403 | PwMerror ret; |
3401 | ret = deepLock(false); | 3404 | ret = deepLock(false); |
3402 | if (ret != e_success) | 3405 | if (ret != e_success) |
3403 | return e_lock; | 3406 | return e_lock; |
3404 | } | 3407 | } |
3405 | unsigned int index; | 3408 | unsigned int index; |
3406 | 3409 | ||
3407 | const QString tmp = d->syncName.c_str(); | 3410 | const QString tmp = d->syncName.c_str(); |
3408 | bool exists = findSyncData(d->syncName.c_str(), &index); | 3411 | bool exists = findSyncData(d->syncName.c_str(), &index); |
3409 | 3412 | ||
3410 | if (exists == true) { | 3413 | if (exists == true) { |
3411 | // DOH! We found this entry. | 3414 | // DOH! We found this entry. |
3412 | return e_entryExists; | 3415 | return e_entryExists; |
3413 | } | 3416 | } |
3414 | 3417 | ||
3415 | dti.syncDta.push_back(*d); | 3418 | dti.syncDta.push_back(*d); |
3416 | 3419 | ||
3417 | if (!dontFlagDirty) | 3420 | if (!dontFlagDirty) |
3418 | flagDirty(); | 3421 | flagDirty(); |
3419 | return e_success; | 3422 | return e_success; |
3420 | } | 3423 | } |
3421 | 3424 | ||
3422 | 3425 | ||
3423 | 3426 | ||
3424 | /** delete syncdata entry */ | 3427 | /** delete syncdata entry */ |
3425 | bool PwMDoc::delSyncDataEntry(unsigned int index, bool dontFlagDirty) | 3428 | bool PwMDoc::delSyncDataEntry(unsigned int index, bool dontFlagDirty) |
3426 | { | 3429 | { |
3427 | if (isDeepLocked()) | 3430 | if (isDeepLocked()) |
3428 | return false; | 3431 | return false; |
3429 | if (index > dti.syncDta.size() - 1) | 3432 | if (index > dti.syncDta.size() - 1) |
3430 | return false; | 3433 | return false; |
3431 | 3434 | ||
3432 | // delete entry | 3435 | // delete entry |
3433 | dti.syncDta.erase(dti.syncDta.begin() + index); | 3436 | dti.syncDta.erase(dti.syncDta.begin() + index); |
3434 | 3437 | ||
3435 | if (!dontFlagDirty) | 3438 | if (!dontFlagDirty) |
3436 | flagDirty(); | 3439 | flagDirty(); |
3437 | return true; | 3440 | return true; |
3438 | } | 3441 | } |
3439 | 3442 | ||
3440 | 3443 | ||
3441 | PwMDataItem* PwMDoc::findEntryByID(const QString &uid, unsigned int *category, unsigned int *index) | 3444 | PwMDataItem* PwMDoc::findEntryByID(const QString &uid, unsigned int *category, unsigned int *index) |
3442 | { | 3445 | { |
3443 | vector<PwMCategoryItem>::iterator catcounter = dti.dta.begin(), | 3446 | vector<PwMCategoryItem>::iterator catcounter = dti.dta.begin(), |
3444 | catend = dti.dta.end(); | 3447 | catend = dti.dta.end(); |
3445 | 3448 | ||
3446 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; | 3449 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; |
3447 | 3450 | ||
3448 | while (catcounter != catend) { | 3451 | while (catcounter != catend) { |
3449 | entrBegin = catcounter->d.begin(); | 3452 | entrBegin = catcounter->d.begin(); |
3450 | entrEnd = catcounter->d.end(); | 3453 | entrEnd = catcounter->d.end(); |
3451 | entrI = entrBegin; | 3454 | entrI = entrBegin; |
3452 | while (entrI != entrEnd) { | 3455 | while (entrI != entrEnd) { |
3453 | if ((*entrI).meta.uniqueid == uid.latin1()) { | 3456 | if ((*entrI).meta.uniqueid == uid.latin1()) { |
3454 | if (category) | 3457 | if (category) |
3455 | *category = catcounter - dti.dta.begin(); | 3458 | *category = catcounter - dti.dta.begin(); |
3456 | if (index) | 3459 | if (index) |
3457 | *index = entrI - entrBegin; | 3460 | *index = entrI - entrBegin; |
3458 | 3461 | ||
3459 | return &(*entrI); | 3462 | return &(*entrI); |
3460 | } | 3463 | } |
3461 | ++entrI; | 3464 | ++entrI; |
3462 | } | 3465 | } |
3463 | ++catcounter; | 3466 | ++catcounter; |
3464 | } | 3467 | } |
3465 | 3468 | ||
3466 | return 0; | 3469 | return 0; |
3467 | } | 3470 | } |
3468 | 3471 | ||
3469 | QStringList PwMDoc::getIDEntryList() | 3472 | QStringList PwMDoc::getIDEntryList() |
3470 | { | 3473 | { |
3471 | QStringList results; | 3474 | QStringList results; |
3472 | 3475 | ||
3473 | vector<PwMCategoryItem>::iterator catcounter = dti.dta.begin(), | 3476 | vector<PwMCategoryItem>::iterator catcounter = dti.dta.begin(), |
3474 | catend = dti.dta.end(); | 3477 | catend = dti.dta.end(); |
3475 | 3478 | ||
3476 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; | 3479 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; |
3477 | 3480 | ||
3478 | while (catcounter != catend) { | 3481 | while (catcounter != catend) { |
3479 | entrBegin = catcounter->d.begin(); | 3482 | entrBegin = catcounter->d.begin(); |
3480 | entrEnd = catcounter->d.end(); | 3483 | entrEnd = catcounter->d.end(); |
3481 | entrI = entrBegin; | 3484 | entrI = entrBegin; |
3482 | while (entrI != entrEnd) { | 3485 | while (entrI != entrEnd) { |
3483 | results.append( (*entrI).meta.uniqueid.c_str() ); | 3486 | results.append( (*entrI).meta.uniqueid.c_str() ); |
3484 | ++entrI; | 3487 | ++entrI; |
3485 | } | 3488 | } |
3486 | ++catcounter; | 3489 | ++catcounter; |
3487 | } | 3490 | } |
3488 | 3491 | ||
3489 | return results; | 3492 | return results; |
3490 | } | 3493 | } |
3491 | 3494 | ||
3492 | 3495 | ||
3493 | 3496 | ||
3494 | 3497 | ||
3495 | 3498 | ||
3496 | #ifndef PWM_EMBEDDED | 3499 | #ifndef PWM_EMBEDDED |
3497 | #include "pwmdoc.moc" | 3500 | #include "pwmdoc.moc" |
3498 | #endif | 3501 | #endif |
diff --git a/pwmanager/pwmanager/pwmdoc.h b/pwmanager/pwmanager/pwmdoc.h index 55e3231..e419c24 100644 --- a/pwmanager/pwmanager/pwmdoc.h +++ b/pwmanager/pwmanager/pwmdoc.h | |||
@@ -1,788 +1,789 @@ | |||
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.1 of pwmanager | 14 | * This file is originaly based on version 1.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 __PWMDOC_H | 20 | #ifndef __PWMDOC_H |
21 | #define __PWMDOC_H | 21 | #define __PWMDOC_H |
22 | #ifdef _WIN32_ | 22 | #ifdef _WIN32_ |
23 | #define ssize_t unsigned int | 23 | #define ssize_t unsigned int |
24 | #endif | 24 | #endif |
25 | #define PWM_FILE_VER (static_cast<char>(0x05)) | 25 | #define PWM_FILE_VER (static_cast<char>(0x05)) |
26 | 26 | ||
27 | #define PWM_HASH_SHA1 (static_cast<char>(0x01)) | 27 | #define PWM_HASH_SHA1 (static_cast<char>(0x01)) |
28 | #define PWM_HASH_SHA256 (static_cast<char>(0x02)) | 28 | #define PWM_HASH_SHA256 (static_cast<char>(0x02)) |
29 | #define PWM_HASH_SHA384 (static_cast<char>(0x03)) | 29 | #define PWM_HASH_SHA384 (static_cast<char>(0x03)) |
30 | #define PWM_HASH_SHA512 (static_cast<char>(0x04)) | 30 | #define PWM_HASH_SHA512 (static_cast<char>(0x04)) |
31 | #define PWM_HASH_MD5 (static_cast<char>(0x05)) | 31 | #define PWM_HASH_MD5 (static_cast<char>(0x05)) |
32 | #define PWM_HASH_RMD160 (static_cast<char>(0x06)) | 32 | #define PWM_HASH_RMD160 (static_cast<char>(0x06)) |
33 | #define PWM_HASH_TIGER (static_cast<char>(0x07)) | 33 | #define PWM_HASH_TIGER (static_cast<char>(0x07)) |
34 | 34 | ||
35 | #define PWM_CRYPT_BLOWFISH(static_cast<char>(0x01)) | 35 | #define PWM_CRYPT_BLOWFISH(static_cast<char>(0x01)) |
36 | #define PWM_CRYPT_AES128(static_cast<char>(0x02)) | 36 | #define PWM_CRYPT_AES128(static_cast<char>(0x02)) |
37 | #define PWM_CRYPT_AES192(static_cast<char>(0x03)) | 37 | #define PWM_CRYPT_AES192(static_cast<char>(0x03)) |
38 | #define PWM_CRYPT_AES256(static_cast<char>(0x04)) | 38 | #define PWM_CRYPT_AES256(static_cast<char>(0x04)) |
39 | #define PWM_CRYPT_3DES (static_cast<char>(0x05)) | 39 | #define PWM_CRYPT_3DES (static_cast<char>(0x05)) |
40 | #define PWM_CRYPT_TWOFISH(static_cast<char>(0x06)) | 40 | #define PWM_CRYPT_TWOFISH(static_cast<char>(0x06)) |
41 | #define PWM_CRYPT_TWOFISH128(static_cast<char>(0x07)) | 41 | #define PWM_CRYPT_TWOFISH128(static_cast<char>(0x07)) |
42 | 42 | ||
43 | #define PWM_COMPRESS_NONE(static_cast<char>(0x00)) | 43 | #define PWM_COMPRESS_NONE(static_cast<char>(0x00)) |
44 | #define PWM_COMPRESS_GZIP(static_cast<char>(0x01)) | 44 | #define PWM_COMPRESS_GZIP(static_cast<char>(0x01)) |
45 | #define PWM_COMPRESS_BZIP2(static_cast<char>(0x02)) | 45 | #define PWM_COMPRESS_BZIP2(static_cast<char>(0x02)) |
46 | 46 | ||
47 | #define DEFAULT_MAX_ENTRIES(~(static_cast<unsigned int>(0))) | 47 | #define DEFAULT_MAX_ENTRIES(~(static_cast<unsigned int>(0))) |
48 | #define FILE_ID_HEADER "PWM_PASSWORD_FILE" | 48 | #define FILE_ID_HEADER "PWM_PASSWORD_FILE" |
49 | 49 | ||
50 | 50 | ||
51 | #include "pwmexception.h" | 51 | #include "pwmexception.h" |
52 | #include "pwmdocui.h" | 52 | #include "pwmdocui.h" |
53 | 53 | ||
54 | #include <qobject.h> | 54 | #include <qobject.h> |
55 | #include <qtimer.h> | 55 | #include <qtimer.h> |
56 | #include <qdatetime.h> | 56 | #include <qdatetime.h> |
57 | 57 | ||
58 | #include <kprocess.h> | 58 | #include <kprocess.h> |
59 | 59 | ||
60 | #ifndef PWM_EMBEDDED | 60 | #ifndef PWM_EMBEDDED |
61 | #include "configuration.h" | 61 | #include "configuration.h" |
62 | #else | 62 | #else |
63 | #include <kapplication.h> | 63 | #include <kapplication.h> |
64 | #include <ksyncmanager.h> | 64 | #include <ksyncmanager.h> |
65 | #endif | 65 | #endif |
66 | 66 | ||
67 | #include <string> | 67 | #include <string> |
68 | #include <vector> | 68 | #include <vector> |
69 | #include <utility> | 69 | #include <utility> |
70 | 70 | ||
71 | using std::vector; | 71 | using std::vector; |
72 | using std::string; | 72 | using std::string; |
73 | using std::pair; | 73 | using std::pair; |
74 | 74 | ||
75 | /* used in findEntry() function */ | 75 | /* used in findEntry() function */ |
76 | #define SEARCH_IN_DESC (1) | 76 | #define SEARCH_IN_DESC (1) |
77 | #define SEARCH_IN_NAME (1 << 1) | 77 | #define SEARCH_IN_NAME (1 << 1) |
78 | #define SEARCH_IN_PW (1 << 2) | 78 | #define SEARCH_IN_PW (1 << 2) |
79 | #define SEARCH_IN_COMMENT(1 << 3) | 79 | #define SEARCH_IN_COMMENT(1 << 3) |
80 | #define SEARCH_IN_URL (1 << 4) | 80 | #define SEARCH_IN_URL (1 << 4) |
81 | #define SEARCH_IN_LAUNCHER(1 << 5) | 81 | #define SEARCH_IN_LAUNCHER(1 << 5) |
82 | #define SEARCH_IN_ALL (SEARCH_IN_DESC | SEARCH_IN_NAME| \ | 82 | #define SEARCH_IN_ALL (SEARCH_IN_DESC | SEARCH_IN_NAME| \ |
83 | SEARCH_IN_PW | SEARCH_IN_COMMENT| \ | 83 | SEARCH_IN_PW | SEARCH_IN_COMMENT| \ |
84 | SEARCH_IN_URL| SEARCH_IN_LAUNCHER) | 84 | SEARCH_IN_URL| SEARCH_IN_LAUNCHER) |
85 | 85 | ||
86 | /** document deeplocked. Data is out for lunch to disk */ | 86 | /** document deeplocked. Data is out for lunch to disk */ |
87 | #define DOC_STAT_DEEPLOCKED (1) | 87 | #define DOC_STAT_DEEPLOCKED (1) |
88 | /** encrypted document on disk is dirty. data has to go to disk. */ | 88 | /** encrypted document on disk is dirty. data has to go to disk. */ |
89 | #define DOC_STAT_DISK_DIRTY (1 << 1) | 89 | #define DOC_STAT_DISK_DIRTY (1 << 1) |
90 | /** we are using a chipcard to encrypt the data */ | 90 | /** we are using a chipcard to encrypt the data */ |
91 | #define DOC_STAT_USE_CHIPCARD (1 << 2) | 91 | #define DOC_STAT_USE_CHIPCARD (1 << 2) |
92 | /** use "currentPw" to unlock. (This flag is set/unset by a timer) */ | 92 | /** use "currentPw" to unlock. (This flag is set/unset by a timer) */ |
93 | #define DOC_STAT_UNLOCK_WITHOUT_PW(1 << 3) | 93 | #define DOC_STAT_UNLOCK_WITHOUT_PW(1 << 3) |
94 | 94 | ||
95 | class PwMDoc; | 95 | class PwMDoc; |
96 | class PwMView; | 96 | class PwMView; |
97 | class QFile; | 97 | class QFile; |
98 | 98 | ||
99 | /* meta data for a PwMDataItem */ | 99 | /* meta data for a PwMDataItem */ |
100 | struct PwMMetaData | 100 | struct PwMMetaData |
101 | { | 101 | { |
102 | PwMMetaData() | 102 | PwMMetaData() |
103 | : updateInt (0) | 103 | : updateInt (0) |
104 | { } | 104 | { } |
105 | /** creation date of the PwMDataItem to which | 105 | /** creation date of the PwMDataItem to which |
106 | * this meta data belongs. | 106 | * this meta data belongs. |
107 | */ | 107 | */ |
108 | QDateTimecreate; | 108 | QDateTimecreate; |
109 | /** becomes valid on this date */ | 109 | /** becomes valid on this date */ |
110 | QDateTimevalid; | 110 | QDateTimevalid; |
111 | /** expire date */ | 111 | /** expire date */ |
112 | QDateTimeexpire; | 112 | QDateTimeexpire; |
113 | /** update date (last updated at this date) */ | 113 | /** update date (last updated at this date) */ |
114 | QDateTimeupdate; | 114 | QDateTimeupdate; |
115 | /** update interval (in minutes). Time since the | 115 | /** update interval (in minutes). Time since the |
116 | * last update to remind the user to update the item. | 116 | * last update to remind the user to update the item. |
117 | * 0 disables. | 117 | * 0 disables. |
118 | */ | 118 | */ |
119 | unsigned long updateInt; | 119 | unsigned long updateInt; |
120 | 120 | ||
121 | //US ENH: enhancements of the filestructure | 121 | //US ENH: enhancements of the filestructure |
122 | /* each entry gets a unique id assigned */ | 122 | /* each entry gets a unique id assigned */ |
123 | string uniqueid; | 123 | string uniqueid; |
124 | 124 | ||
125 | 125 | ||
126 | void clear() | 126 | void clear() |
127 | { | 127 | { |
128 | create = QDateTime(); | 128 | create = QDateTime(); |
129 | expire = QDateTime(); | 129 | expire = QDateTime(); |
130 | update = QDateTime(); | 130 | update = QDateTime(); |
131 | updateInt = 0; | 131 | updateInt = 0; |
132 | uniqueid = KApplication::randomString(8).latin1(); | 132 | uniqueid = KApplication::randomString(8).latin1(); |
133 | } | 133 | } |
134 | 134 | ||
135 | inline bool isValid() const | 135 | inline bool isValid() const |
136 | { | 136 | { |
137 | if (valid.isNull()) | 137 | if (valid.isNull()) |
138 | return true; | 138 | return true; |
139 | return (valid < QDateTime::currentDateTime()); | 139 | return (valid < QDateTime::currentDateTime()); |
140 | } | 140 | } |
141 | inline bool isExpired() const | 141 | inline bool isExpired() const |
142 | { | 142 | { |
143 | if (expire.isNull()) | 143 | if (expire.isNull()) |
144 | return false; | 144 | return false; |
145 | return (expire < QDateTime::currentDateTime()); | 145 | return (expire < QDateTime::currentDateTime()); |
146 | } | 146 | } |
147 | inline bool isUpdateIntOver() const | 147 | inline bool isUpdateIntOver() const |
148 | { | 148 | { |
149 | if (updateInt == 0 || | 149 | if (updateInt == 0 || |
150 | update.isNull()) | 150 | update.isNull()) |
151 | return false; | 151 | return false; |
152 | QDateTime d(update); | 152 | QDateTime d(update); |
153 | return (d.addSecs(updateInt * 60) < QDateTime::currentDateTime()); | 153 | return (d.addSecs(updateInt * 60) < QDateTime::currentDateTime()); |
154 | } | 154 | } |
155 | }; | 155 | }; |
156 | 156 | ||
157 | struct PwMDataItem | 157 | struct PwMDataItem |
158 | { | 158 | { |
159 | PwMDataItem() | 159 | PwMDataItem() |
160 | : lockStat (true) | 160 | : lockStat (true) |
161 | , listViewPos (-1) | 161 | , listViewPos (-1) |
162 | , binary (false) | 162 | , binary (false) |
163 | , rev (0) | 163 | , rev (0) |
164 | { } | 164 | { } |
165 | 165 | ||
166 | /** password description */ | 166 | /** password description */ |
167 | stringdesc; | 167 | stringdesc; |
168 | /** user-name */ | 168 | /** user-name */ |
169 | stringname; | 169 | stringname; |
170 | /** the password itself */ | 170 | /** the password itself */ |
171 | stringpw; | 171 | stringpw; |
172 | /** some comment */ | 172 | /** some comment */ |
173 | stringcomment; | 173 | stringcomment; |
174 | /** an URL string */ | 174 | /** an URL string */ |
175 | stringurl; | 175 | stringurl; |
176 | /** launcher. Can be executed as a system() command */ | 176 | /** launcher. Can be executed as a system() command */ |
177 | stringlauncher; | 177 | stringlauncher; |
178 | /** locking status. If locked (true), pw is not emitted through getEntry() */ | 178 | /** locking status. If locked (true), pw is not emitted through getEntry() */ |
179 | boollockStat; | 179 | boollockStat; |
180 | /** position of this item in main "list-view" | 180 | /** position of this item in main "list-view" |
181 | * If -1, the position is not yet specified and should be appended to the list | 181 | * If -1, the position is not yet specified and should be appended to the list |
182 | */ | 182 | */ |
183 | intlistViewPos; | 183 | intlistViewPos; |
184 | /** does this entry contain binary data? */ | 184 | /** does this entry contain binary data? */ |
185 | bool binary; | 185 | bool binary; |
186 | /** meta data for this data item. */ | 186 | /** meta data for this data item. */ |
187 | PwMMetaData meta; | 187 | PwMMetaData meta; |
188 | /** data revision counter. This counter can be used | 188 | /** data revision counter. This counter can be used |
189 | * to easily, efficiently determine if this data item | 189 | * to easily, efficiently determine if this data item |
190 | * has changed since some time. | 190 | * has changed since some time. |
191 | * This counter is incremented on every update. | 191 | * This counter is incremented on every update. |
192 | */ | 192 | */ |
193 | unsigned int rev; | 193 | unsigned int rev; |
194 | 194 | ||
195 | void clear(bool clearMeta = true) | 195 | void clear(bool clearMeta = true) |
196 | { | 196 | { |
197 | /* NOTE: Don't use .clear() here to be | 197 | /* NOTE: Don't use .clear() here to be |
198 | * backward compatible with gcc-2 (Debian Woody) | 198 | * backward compatible with gcc-2 (Debian Woody) |
199 | */ | 199 | */ |
200 | desc = ""; | 200 | desc = ""; |
201 | name = ""; | 201 | name = ""; |
202 | pw = ""; | 202 | pw = ""; |
203 | comment = ""; | 203 | comment = ""; |
204 | url = ""; | 204 | url = ""; |
205 | launcher = ""; | 205 | launcher = ""; |
206 | lockStat = true; | 206 | lockStat = true; |
207 | listViewPos = -1; | 207 | listViewPos = -1; |
208 | binary = false; | 208 | binary = false; |
209 | if (clearMeta) | 209 | if (clearMeta) |
210 | meta.clear(); | 210 | meta.clear(); |
211 | } | 211 | } |
212 | //US ENH: we need this operator to compare two items if we have no unique ids | 212 | //US ENH: we need this operator to compare two items if we have no unique ids |
213 | //available. Generaly this happens before the first sync | 213 | //available. Generaly this happens before the first sync |
214 | 214 | ||
215 | bool PwMDataItem::operator==( const PwMDataItem &a ) const | 215 | bool PwMDataItem::operator==( const PwMDataItem &a ) const |
216 | { | 216 | { |
217 | //qDebug("oper==%s", a.desc.c_str()); | 217 | //qDebug("oper==%s", a.desc.c_str()); |
218 | if ( desc != a.desc ) return false; | 218 | if ( desc != a.desc ) return false; |
219 | if ( name != a.name ) return false; | 219 | if ( name != a.name ) return false; |
220 | if ( pw != a.pw ) return false; | 220 | if ( pw != a.pw ) return false; |
221 | if ( comment != a.comment ) return false; | 221 | if ( comment != a.comment ) return false; |
222 | if ( url != a.url ) return false; | 222 | if ( url != a.url ) return false; |
223 | if ( launcher != a.launcher ) return false; | 223 | if ( launcher != a.launcher ) return false; |
224 | //all other field will not be checked. | 224 | //all other field will not be checked. |
225 | return true; | 225 | return true; |
226 | } | 226 | } |
227 | }; | 227 | }; |
228 | 228 | ||
229 | struct PwMCategoryItem | 229 | struct PwMCategoryItem |
230 | { | 230 | { |
231 | /** all PwMDataItems (all passwords) within this category */ | 231 | /** all PwMDataItems (all passwords) within this category */ |
232 | vector<PwMDataItem>d; | 232 | vector<PwMDataItem>d; |
233 | /** category name/description */ | 233 | /** category name/description */ |
234 | string name; | 234 | string name; |
235 | 235 | ||
236 | void clear() | 236 | void clear() |
237 | { | 237 | { |
238 | d.clear(); | 238 | d.clear(); |
239 | name = ""; | 239 | name = ""; |
240 | } | 240 | } |
241 | }; | 241 | }; |
242 | 242 | ||
243 | struct PwMSyncItem | 243 | struct PwMSyncItem |
244 | { | 244 | { |
245 | string syncName; | 245 | string syncName; |
246 | QDateTime lastSyncDate; | 246 | QDateTime lastSyncDate; |
247 | 247 | ||
248 | void clear() | 248 | void clear() |
249 | { | 249 | { |
250 | lastSyncDate = QDateTime(); | 250 | lastSyncDate = QDateTime(); |
251 | syncName = ""; | 251 | syncName = ""; |
252 | } | 252 | } |
253 | }; | 253 | }; |
254 | 254 | ||
255 | struct PwMItem | 255 | struct PwMItem |
256 | { | 256 | { |
257 | vector<PwMCategoryItem> dta; | 257 | vector<PwMCategoryItem> dta; |
258 | vector<PwMSyncItem> syncDta; | 258 | vector<PwMSyncItem> syncDta; |
259 | 259 | ||
260 | void clear() | 260 | void clear() |
261 | { | 261 | { |
262 | dta.clear(); | 262 | dta.clear(); |
263 | syncDta.clear(); | 263 | syncDta.clear(); |
264 | } | 264 | } |
265 | }; | 265 | }; |
266 | 266 | ||
267 | 267 | ||
268 | /** "Function Object" for sort()ing PwMDataItem::listViewPos */ | 268 | /** "Function Object" for sort()ing PwMDataItem::listViewPos */ |
269 | class dta_lvp_greater | 269 | class dta_lvp_greater |
270 | { | 270 | { |
271 | public: | 271 | public: |
272 | bool operator() (const pair<unsigned int, unsigned int> &d1, | 272 | bool operator() (const pair<unsigned int, unsigned int> &d1, |
273 | const pair<unsigned int, unsigned int> &d2) | 273 | const pair<unsigned int, unsigned int> &d2) |
274 | { | 274 | { |
275 | return d1.second > d2.second; | 275 | return d1.second > d2.second; |
276 | } | 276 | } |
277 | }; | 277 | }; |
278 | 278 | ||
279 | /** list of PwMDoc documents and it's IDs */ | 279 | /** list of PwMDoc documents and it's IDs */ |
280 | class PwMDocList | 280 | class PwMDocList |
281 | { | 281 | { |
282 | public: | 282 | public: |
283 | struct listItem | 283 | struct listItem |
284 | { | 284 | { |
285 | /** document filename (known as ID, here) */ | 285 | /** document filename (known as ID, here) */ |
286 | string docId; | 286 | string docId; |
287 | /** pointer to the document class */ | 287 | /** pointer to the document class */ |
288 | PwMDoc *doc; | 288 | PwMDoc *doc; |
289 | }; | 289 | }; |
290 | 290 | ||
291 | PwMDocList() {} | 291 | PwMDocList() {} |
292 | 292 | ||
293 | /** add a new item to the list */ | 293 | /** add a new item to the list */ |
294 | void add(PwMDoc *doc, const string &id); | 294 | void add(PwMDoc *doc, const string &id); |
295 | /** changes the contents of an existing item */ | 295 | /** changes the contents of an existing item */ |
296 | void edit(PwMDoc *doc, const string &newId); | 296 | void edit(PwMDoc *doc, const string &newId); |
297 | /** remove the given item */ | 297 | /** remove the given item */ |
298 | void del(PwMDoc *doc); | 298 | void del(PwMDoc *doc); |
299 | /** get the item at index */ | 299 | /** get the item at index */ |
300 | listItem getAt(int index) | 300 | listItem getAt(int index) |
301 | { return docList[index]; } | 301 | { return docList[index]; } |
302 | /** find an entry with this id */ | 302 | /** find an entry with this id */ |
303 | bool find(const string &id, listItem *ret = 0); | 303 | bool find(const string &id, listItem *ret = 0); |
304 | /** returns a copy of the list */ | 304 | /** returns a copy of the list */ |
305 | const vector<listItem>* getList() const | 305 | const vector<listItem>* getList() const |
306 | { return &docList; } | 306 | { return &docList; } |
307 | 307 | ||
308 | 308 | ||
309 | /** returns a new unique number to extend the name of | 309 | /** returns a new unique number to extend the name of |
310 | * an unnamed document. | 310 | * an unnamed document. |
311 | */ | 311 | */ |
312 | static unsigned int getNewUnnamedNumber() | 312 | static unsigned int getNewUnnamedNumber() |
313 | { return unnamedDocCnt++; } | 313 | { return unnamedDocCnt++; } |
314 | 314 | ||
315 | protected: | 315 | protected: |
316 | /* Hm, I think we shouldn't really use a "list" here, should we? | 316 | /* Hm, I think we shouldn't really use a "list" here, should we? |
317 | * So I decided to actually use a vector. | 317 | * So I decided to actually use a vector. |
318 | */ | 318 | */ |
319 | vector<listItem> docList; | 319 | vector<listItem> docList; |
320 | /** This value is used to get a new number for yet unnamed | 320 | /** This value is used to get a new number for yet unnamed |
321 | * documents. It is incremented on every request. So it's | 321 | * documents. It is incremented on every request. So it's |
322 | * theoretically possible to overflow it, but... :) | 322 | * theoretically possible to overflow it, but... :) |
323 | */ | 323 | */ |
324 | static unsigned int unnamedDocCnt; | 324 | static unsigned int unnamedDocCnt; |
325 | }; | 325 | }; |
326 | 326 | ||
327 | /** implements timers for the document */ | 327 | /** implements timers for the document */ |
328 | class DocTimer : public QObject | 328 | class DocTimer : public QObject |
329 | { | 329 | { |
330 | Q_OBJECT | 330 | Q_OBJECT |
331 | public: | 331 | public: |
332 | enum TimerIDs | 332 | enum TimerIDs |
333 | { | 333 | { |
334 | id_mpwTimer, | 334 | id_mpwTimer, |
335 | id_autoLockTimer, | 335 | id_autoLockTimer, |
336 | id_metaCheckTimer | 336 | id_metaCheckTimer |
337 | }; | 337 | }; |
338 | 338 | ||
339 | public: | 339 | public: |
340 | DocTimer(PwMDoc *_doc); | 340 | DocTimer(PwMDoc *_doc); |
341 | ~DocTimer(); | 341 | ~DocTimer(); |
342 | 342 | ||
343 | /** start the timer */ | 343 | /** start the timer */ |
344 | void start(TimerIDs timer); | 344 | void start(TimerIDs timer); |
345 | /** stop the timer */ | 345 | /** stop the timer */ |
346 | void stop(TimerIDs timer); | 346 | void stop(TimerIDs timer); |
347 | /** get the lock for a timer. | 347 | /** get the lock for a timer. |
348 | * This lock is a recursive lock. When a lock is | 348 | * This lock is a recursive lock. When a lock is |
349 | * held, the timer will be stopped and timeout is | 349 | * held, the timer will be stopped and timeout is |
350 | * guaranteed to not happen | 350 | * guaranteed to not happen |
351 | */ | 351 | */ |
352 | void getLock(TimerIDs timer); | 352 | void getLock(TimerIDs timer); |
353 | /** put a recursive timer lock */ | 353 | /** put a recursive timer lock */ |
354 | void putLock(TimerIDs timer); | 354 | void putLock(TimerIDs timer); |
355 | 355 | ||
356 | protected slots: | 356 | protected slots: |
357 | /** timeout slot for the mpw timer */ | 357 | /** timeout slot for the mpw timer */ |
358 | void mpwTimeout(); | 358 | void mpwTimeout(); |
359 | /** timeout slot for the autoLock timer */ | 359 | /** timeout slot for the autoLock timer */ |
360 | void autoLockTimeout(); | 360 | void autoLockTimeout(); |
361 | /** timeout slot for the metaCheck timer */ | 361 | /** timeout slot for the metaCheck timer */ |
362 | void metaCheckTimeout(); | 362 | void metaCheckTimeout(); |
363 | 363 | ||
364 | protected: | 364 | protected: |
365 | /** pointer to the document associated with this timer. */ | 365 | /** pointer to the document associated with this timer. */ |
366 | PwMDoc *doc; | 366 | PwMDoc *doc; |
367 | /** timer object for mpw timer */ | 367 | /** timer object for mpw timer */ |
368 | QTimer *mpwTimer; | 368 | QTimer *mpwTimer; |
369 | /** timer object for the autoLock timer */ | 369 | /** timer object for the autoLock timer */ |
370 | QTimer *autoLockTimer; | 370 | QTimer *autoLockTimer; |
371 | /** timer object for the metaCheck timer */ | 371 | /** timer object for the metaCheck timer */ |
372 | QTimer *metaCheckTimer; | 372 | QTimer *metaCheckTimer; |
373 | /** lock counter for the mpw timer */ | 373 | /** lock counter for the mpw timer */ |
374 | unsigned int mpwLock; | 374 | unsigned int mpwLock; |
375 | /** lock counter for the autoLock timer */ | 375 | /** lock counter for the autoLock timer */ |
376 | unsigned int autoLockLock; | 376 | unsigned int autoLockLock; |
377 | /** lock counter for the metaCheck timer */ | 377 | /** lock counter for the metaCheck timer */ |
378 | unsigned int metaCheckLock; | 378 | unsigned int metaCheckLock; |
379 | }; | 379 | }; |
380 | 380 | ||
381 | /** Document class for PwM */ | 381 | /** Document class for PwM */ |
382 | //US ENH: derived from KSyncInterfaces, to get called by PwM when a sync is required. | 382 | //US ENH: derived from KSyncInterfaces, to get called by PwM when a sync is required. |
383 | // But PwMDoc is handling the sync by itself. | 383 | // But PwMDoc is handling the sync by itself. |
384 | class PwMDoc : public PwMDocUi, public KSyncInterface | 384 | class PwMDoc : public PwMDocUi, public KSyncInterface |
385 | 385 | ||
386 | { | 386 | { |
387 | Q_OBJECT | 387 | Q_OBJECT |
388 | friend class DocTimer; | 388 | friend class DocTimer; |
389 | 389 | ||
390 | public: | 390 | public: |
391 | /** construtor */ | 391 | /** construtor */ |
392 | PwMDoc(QObject* parent = 0, const char *name = 0); | 392 | PwMDoc(QObject* parent = 0, const char *name = 0); |
393 | /** destructor */ | 393 | /** destructor */ |
394 | ~PwMDoc(); | 394 | ~PwMDoc(); |
395 | 395 | ||
396 | /** returns a pointer to a list of all open documents */ | 396 | /** returns a pointer to a list of all open documents */ |
397 | static PwMDocList* getOpenDocList() | 397 | static PwMDocList* getOpenDocList() |
398 | { return &openDocList; } | 398 | { return &openDocList; } |
399 | 399 | ||
400 | /** flag document dirty. dta changed */ | 400 | /** flag document dirty. dta changed */ |
401 | void flagDirty() | 401 | void flagDirty() |
402 | { | 402 | { |
403 | setDocStatFlag(DOC_STAT_DISK_DIRTY); | 403 | setDocStatFlag(DOC_STAT_DISK_DIRTY); |
404 | emitDataChanged(this); | 404 | emitDataChanged(this); |
405 | } | 405 | } |
406 | /** modified? */ | 406 | /** modified? */ |
407 | bool isDirty() | 407 | bool isDirty() |
408 | { return getDocStatFlag(DOC_STAT_DISK_DIRTY); } | 408 | { return getDocStatFlag(DOC_STAT_DISK_DIRTY); } |
409 | /** save document to disk */ | 409 | /** save document to disk */ |
410 | PwMerror saveDoc(char compress, const QString *file = 0); | 410 | PwMerror saveDoc(char compress, const QString *file = 0); |
411 | /** read document from file. | 411 | /** read document from file. |
412 | * "openLocked is must be set to either of these values: | 412 | * "openLocked is must be set to either of these values: |
413 | * 0 == open with all entries unlocked | 413 | * 0 == open with all entries unlocked |
414 | * 1 == open with all entries locked | 414 | * 1 == open with all entries locked |
415 | * 2 == open deep-locked | 415 | * 2 == open deep-locked |
416 | */ | 416 | */ |
417 | PwMerror openDoc(const QString *file, int openLocked); | 417 | PwMerror openDoc(const QString *file, int openLocked); |
418 | /** export document to ascii-textfile */ | 418 | /** export document to ascii-textfile */ |
419 | PwMerror exportToText(const QString *file); | 419 | PwMerror exportToText(const QString *file); |
420 | /** export document to gpasman / kpasman file */ | 420 | /** export document to gpasman / kpasman file */ |
421 | PwMerror exportToGpasman(const QString *file); | 421 | PwMerror exportToGpasman(const QString *file); |
422 | /** import document from ascii-textfile */ | 422 | /** import document from ascii-textfile */ |
423 | PwMerror importFromText(const QString *file, int format = -1); | 423 | PwMerror importFromText(const QString *file, int format = -1); |
424 | /** import document from gpasman / kpasman file */ | 424 | /** import document from gpasman / kpasman file */ |
425 | PwMerror importFromGpasman(const QString *file); | 425 | PwMerror importFromGpasman(const QString *file); |
426 | /** add new entry */ | 426 | /** add new entry */ |
427 | PwMerror addEntry(const QString &category, PwMDataItem *d, | 427 | PwMerror addEntry(const QString &category, PwMDataItem *d, |
428 | bool dontFlagDirty = false, bool updateMeta = true); | 428 | bool dontFlagDirty = false, bool updateMeta = true); |
429 | /** add new category. This function doesn't flag the document dirty! */ | 429 | /** add new category. This function doesn't flag the document dirty! */ |
430 | PwMerror addCategory(const QString &category, unsigned int *categoryIndex, | 430 | PwMerror addCategory(const QString &category, unsigned int *categoryIndex, |
431 | bool checkIfExist = true); | 431 | bool checkIfExist = true); |
432 | /** rename an existing category */ | 432 | /** rename an existing category */ |
433 | bool renameCategory(const QString &category, const QString &newName); | 433 | bool renameCategory(const QString &category, const QString &newName); |
434 | /** rename an existing category */ | 434 | /** rename an existing category */ |
435 | bool renameCategory(unsigned int category, const QString &newName, | 435 | bool renameCategory(unsigned int category, const QString &newName, |
436 | bool dontFlagDirty = false); | 436 | bool dontFlagDirty = false); |
437 | /** delete an existing category */ | 437 | /** delete an existing category */ |
438 | bool delCategory(const QString &category); | 438 | bool delCategory(const QString &category); |
439 | /** delete an existing category */ | 439 | /** delete an existing category */ |
440 | bool delCategory(unsigned int category, bool dontFlagDirty = false); | 440 | bool delCategory(unsigned int category, bool dontFlagDirty = false); |
441 | /** returns a list of all category-names */ | 441 | /** returns a list of all category-names */ |
442 | void getCategoryList(vector<string> *list); | 442 | void getCategoryList(vector<string> *list); |
443 | /** returns a list of all category-names */ | 443 | /** returns a list of all category-names */ |
444 | void getCategoryList(QStringList *list); | 444 | void getCategoryList(QStringList *list); |
445 | /** returns a list of all entry-descs in the given category */ | 445 | /** returns a list of all entry-descs in the given category */ |
446 | void getEntryList(const QString &category, QStringList *list); | 446 | void getEntryList(const QString &category, QStringList *list); |
447 | /** returns a list of all entry-descs in the given category */ | 447 | /** returns a list of all entry-descs in the given category */ |
448 | void getEntryList(const QString &category, vector<string> *list); | 448 | void getEntryList(const QString &category, vector<string> *list); |
449 | /** returns a list of all entry-descs in the given category */ | 449 | /** returns a list of all entry-descs in the given category */ |
450 | void getEntryList(unsigned int category, vector<string> *list); | 450 | void getEntryList(unsigned int category, vector<string> *list); |
451 | /** returns a list of all entry-descs in the given category */ | 451 | /** returns a list of all entry-descs in the given category */ |
452 | void getEntryList(unsigned int category, QStringList *list); | 452 | void getEntryList(unsigned int category, QStringList *list); |
453 | /** delete entry */ | 453 | /** delete entry */ |
454 | bool delEntry(const QString &category, unsigned int index, bool dontFlagDirty = false); | 454 | bool delEntry(const QString &category, unsigned int index, bool dontFlagDirty = false); |
455 | /** delete entry */ | 455 | /** delete entry */ |
456 | bool delEntry(unsigned int category, unsigned int index, bool dontFlagDirty = false); | 456 | bool delEntry(unsigned int category, unsigned int index, bool dontFlagDirty = false); |
457 | /** edit entry */ | 457 | /** edit entry */ |
458 | bool editEntry(const QString &oldCategory, const QString &newCategory, | 458 | bool editEntry(const QString &oldCategory, const QString &newCategory, |
459 | unsigned int index, PwMDataItem *d, bool updateMeta = true); | 459 | unsigned int index, PwMDataItem *d, bool updateMeta = true); |
460 | /** edit entry */ | 460 | /** edit entry */ |
461 | bool editEntry(unsigned int oldCategory, const QString &newCategory, | 461 | bool editEntry(unsigned int oldCategory, const QString &newCategory, |
462 | unsigned int index, PwMDataItem *d, bool updateMeta = true); | 462 | unsigned int index, PwMDataItem *d, bool updateMeta = true); |
463 | /** finds the category with the "name" and return it's index */ | 463 | /** finds the category with the "name" and return it's index */ |
464 | bool findCategory(const QString &name, unsigned int *index); | 464 | bool findCategory(const QString &name, unsigned int *index); |
465 | /** search for an entry "find" and check while searching only for | 465 | /** search for an entry "find" and check while searching only for |
466 | * the data-fields specified by "searchIn". To set the "searchIn" | 466 | * the data-fields specified by "searchIn". To set the "searchIn" |
467 | * value, we may use one or more of the SEARCH_IN_* defines at | 467 | * value, we may use one or more of the SEARCH_IN_* defines at |
468 | * the top of this header-file. It returns the positions of all | 468 | * the top of this header-file. It returns the positions of all |
469 | * matched entries in "foundPositions". If "breakAfterFound" is true, | 469 | * matched entries in "foundPositions". If "breakAfterFound" is true, |
470 | * the function terminates after the first occurence of the entry | 470 | * the function terminates after the first occurence of the entry |
471 | * and doesn't go on searching. So foundPositions->size() is never | 471 | * and doesn't go on searching. So foundPositions->size() is never |
472 | * > 1 if breakAfterFound is true. | 472 | * > 1 if breakAfterFound is true. |
473 | */ | 473 | */ |
474 | void findEntry(unsigned int category, PwMDataItem find, unsigned int searchIn, | 474 | void findEntry(unsigned int category, PwMDataItem find, unsigned int searchIn, |
475 | vector<unsigned int> *foundPositions, bool breakAfterFound = false, | 475 | vector<unsigned int> *foundPositions, bool breakAfterFound = false, |
476 | bool caseSensitive = true, bool exactWordMatch = true, | 476 | bool caseSensitive = true, bool exactWordMatch = true, |
477 | bool sortByLvp = false); | 477 | bool sortByLvp = false); |
478 | /** see the above funtion. This function allows to set the category by name. */ | 478 | /** see the above funtion. This function allows to set the category by name. */ |
479 | void findEntry(const QString &category, PwMDataItem find, unsigned int searchIn, | 479 | void findEntry(const QString &category, PwMDataItem find, unsigned int searchIn, |
480 | vector<unsigned int> *foundPositions, bool breakAfterFound = false, | 480 | vector<unsigned int> *foundPositions, bool breakAfterFound = false, |
481 | bool caseSensitive = true, bool exactWordMatch = true, | 481 | bool caseSensitive = true, bool exactWordMatch = true, |
482 | bool sortByLvp = false); | 482 | bool sortByLvp = false); |
483 | /** returns number of entries */ | 483 | /** returns number of entries */ |
484 | unsigned int numEntries(const QString &category); | 484 | unsigned int numEntries(const QString &category); |
485 | unsigned int numEntries(unsigned int category) | 485 | unsigned int numEntries(unsigned int category) |
486 | { return dti.dta[category].d.size(); } | 486 | { return dti.dta[category].d.size(); } |
487 | /** returns number of categories */ | 487 | /** returns number of categories */ |
488 | unsigned int numCategories() | 488 | unsigned int numCategories() |
489 | { return dti.dta.size(); } | 489 | { return dti.dta.size(); } |
490 | /** returns the name of the category at "index" */ | 490 | /** returns the name of the category at "index" */ |
491 | const string* getCategory(unsigned int index) | 491 | const string* getCategory(unsigned int index) |
492 | { return (&(dti.dta[index].name)); } | 492 | { return (&(dti.dta[index].name)); } |
493 | 493 | ||
494 | /** returns the data of item at "index". | 494 | /** returns the data of item at "index". |
495 | * It unlocks the entry if it's locked and unlockIfLocked is true. | 495 | * It unlocks the entry if it's locked and unlockIfLocked is true. |
496 | * If the entry is locked, but unlockIfLocked is false, it'll not return | 496 | * If the entry is locked, but unlockIfLocked is false, it'll not return |
497 | * the pw. | 497 | * the pw. |
498 | */ | 498 | */ |
499 | bool getEntry(const QString &category, unsigned int index, | 499 | bool getEntry(const QString &category, unsigned int index, |
500 | PwMDataItem *d, bool unlockIfLocked = false); | 500 | PwMDataItem *d, bool unlockIfLocked = false); |
501 | bool getEntry(unsigned int category, unsigned int index, | 501 | bool getEntry(unsigned int category, unsigned int index, |
502 | PwMDataItem *d, bool unlockIfLocked = false); | 502 | PwMDataItem *d, bool unlockIfLocked = false); |
503 | /** returns the comment-string by looking at the category | 503 | /** returns the comment-string by looking at the category |
504 | * and the listViewPos | 504 | * and the listViewPos |
505 | */ | 505 | */ |
506 | PwMerror getCommentByLvp(const QString &category, int listViewPos, | 506 | PwMerror getCommentByLvp(const QString &category, int listViewPos, |
507 | string *foundComment); | 507 | string *foundComment); |
508 | /** checks if a password is already available. (currentPw) */ | 508 | /** checks if a password is already available. (currentPw) */ |
509 | bool isPwAvailable() | 509 | bool isPwAvailable() |
510 | { return (currentPw != ""); } | 510 | { return (currentPw != ""); } |
511 | /** un/lock entry at "index". If needed, ask for password. */ | 511 | /** un/lock entry at "index". If needed, ask for password. */ |
512 | bool lockAt(const QString &category, unsigned int index, | 512 | bool lockAt(const QString &category, unsigned int index, |
513 | bool lock = true); | 513 | bool lock = true); |
514 | bool lockAt(unsigned int category, unsigned int index, | 514 | bool lockAt(unsigned int category, unsigned int index, |
515 | bool lock = true); | 515 | bool lock = true); |
516 | /** returns the lock-status at "index" */ | 516 | /** returns the lock-status at "index" */ |
517 | bool isLocked(const QString &category, unsigned int index); | 517 | bool isLocked(const QString &category, unsigned int index); |
518 | bool isLocked(unsigned int category, unsigned int index) | 518 | bool isLocked(unsigned int category, unsigned int index) |
519 | { return dti.dta[category].d[index].lockStat; } | 519 | { return dti.dta[category].d[index].lockStat; } |
520 | /** returns the deeplock status */ | 520 | /** returns the deeplock status */ |
521 | bool isDeepLocked() | 521 | bool isDeepLocked() |
522 | { return getDocStatFlag(DOC_STAT_DEEPLOCKED); } | 522 | { return getDocStatFlag(DOC_STAT_DEEPLOCKED); } |
523 | /** (un)lock all entries */ | 523 | /** (un)lock all entries */ |
524 | bool lockAll(bool lock); | 524 | bool lockAll(bool lock); |
525 | /** unlocks all entries tempoarly. | 525 | /** unlocks all entries tempoarly. |
526 | * 1st NOTE: Be very careful with this function! :) | 526 | * 1st NOTE: Be very careful with this function! :) |
527 | * 2nd NOTE: After you have called unlockAll_Tempoary(); , | 527 | * 2nd NOTE: After you have called unlockAll_Tempoary(); , |
528 | * please DON'T forget to call unlockAll_Tempoary(true); | 528 | * please DON'T forget to call unlockAll_Tempoary(true); |
529 | * _before_ the user (or someone else) is able to change | 529 | * _before_ the user (or someone else) is able to change |
530 | * the document! | 530 | * the document! |
531 | * 3rd NOTE: Please DON'T change "dta" while the data is tempoary | 531 | * 3rd NOTE: Please DON'T change "dta" while the data is tempoary |
532 | * unlocked! This will cause corruption. | 532 | * unlocked! This will cause corruption. |
533 | */ | 533 | */ |
534 | bool unlockAll_tempoary(bool revert = false); | 534 | bool unlockAll_tempoary(bool revert = false); |
535 | /** deep-(un)locks the document. | 535 | /** deep-(un)locks the document. |
536 | * deep-locking writes all data to the file, deletes all data | 536 | * deep-locking writes all data to the file, deletes all data |
537 | * in memory, but doesn't close the document. | 537 | * in memory, but doesn't close the document. |
538 | * deep-locking is only available, if the user previously saved | 538 | * deep-locking is only available, if the user previously saved |
539 | * the doc to a file (with a password). | 539 | * the doc to a file (with a password). |
540 | * If "saveToFile" is false, it does NOT write the data to the file! | 540 | * If "saveToFile" is false, it does NOT write the data to the file! |
541 | */ | 541 | */ |
542 | PwMerror deepLock(bool lock = true, bool saveToFile = true); | 542 | PwMerror deepLock(bool lock = true, bool saveToFile = true); |
543 | /** is unlockable without pw? */ | 543 | /** is unlockable without pw? */ |
544 | bool unlockWoPw() | 544 | bool unlockWoPw() |
545 | { return getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); } | 545 | { return getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); } |
546 | /** get the "currentPassword" */ | 546 | /** get the "currentPassword" */ |
547 | const QString& getCurrentPw() | 547 | const QString& getCurrentPw() |
548 | { return currentPw; } | 548 | { return currentPw; } |
549 | /** open a window and request the user to change the mpw */ | 549 | /** open a window and request the user to change the mpw */ |
550 | void changeCurrentPw(); | 550 | void changeCurrentPw(); |
551 | /** set the "listViewPos" variable of "dta" */ | 551 | /** set the "listViewPos" variable of "dta" */ |
552 | void setListViewPos(const QString &category, unsigned int index, | 552 | void setListViewPos(const QString &category, unsigned int index, |
553 | int pos); | 553 | int pos); |
554 | /** set the "listViewPos" variable of "dta" */ | 554 | /** set the "listViewPos" variable of "dta" */ |
555 | void setListViewPos(unsigned int category, unsigned int index, | 555 | void setListViewPos(unsigned int category, unsigned int index, |
556 | int pos); | 556 | int pos); |
557 | /** get the "listViewPos" variable of "dta" */ | 557 | /** get the "listViewPos" variable of "dta" */ |
558 | int getListViewPos(const QString &category, unsigned int index); | 558 | int getListViewPos(const QString &category, unsigned int index); |
559 | /** set the maximum number of entries allowed */ | 559 | /** set the maximum number of entries allowed */ |
560 | void setMaxNumEntries(unsigned int num = DEFAULT_MAX_ENTRIES) | 560 | void setMaxNumEntries(unsigned int num = DEFAULT_MAX_ENTRIES) |
561 | { maxEntries = num; } | 561 | { maxEntries = num; } |
562 | /** get the maximum number of entries allowed */ | 562 | /** get the maximum number of entries allowed */ |
563 | unsigned int getMaxNumEntries() | 563 | unsigned int getMaxNumEntries() |
564 | { return maxEntries; } | 564 | { return maxEntries; } |
565 | /** ensure all listViewPos of all dta items are set. (are ! -1). | 565 | /** ensure all listViewPos of all dta items are set. (are ! -1). |
566 | * If there are some undefined entries, add them to the end of | 566 | * If there are some undefined entries, add them to the end of |
567 | * the listViewPos(itions). */ | 567 | * the listViewPos(itions). */ |
568 | void ensureLvp(); | 568 | void ensureLvp(); |
569 | /** execute the "launcher" of this entry */ | 569 | /** execute the "launcher" of this entry */ |
570 | bool execLauncher(const QString &category, unsigned int entryIndex); | 570 | bool execLauncher(const QString &category, unsigned int entryIndex); |
571 | /** see above */ | 571 | /** see above */ |
572 | bool execLauncher(unsigned int category, unsigned int entryIndex); | 572 | bool execLauncher(unsigned int category, unsigned int entryIndex); |
573 | /** open a browser with the URL-section of the given entry */ | 573 | /** open a browser with the URL-section of the given entry */ |
574 | bool goToURL(const QString &category, unsigned int entryIndex); | 574 | bool goToURL(const QString &category, unsigned int entryIndex); |
575 | /** see above */ | 575 | /** see above */ |
576 | bool goToURL(unsigned int category, unsigned int entryIndex); | 576 | bool goToURL(unsigned int category, unsigned int entryIndex); |
577 | /** returns true if there is no entry present in the document. | 577 | /** returns true if there is no entry present in the document. |
578 | * Note: The "default" Category is present everytime, so | 578 | * Note: The "default" Category is present everytime, so |
579 | * it's checked for it's entries. | 579 | * it's checked for it's entries. |
580 | */ | 580 | */ |
581 | bool isDocEmpty() | 581 | bool isDocEmpty() |
582 | { | 582 | { |
583 | if (numCategories() > 1) | 583 | if (numCategories() > 1) |
584 | return false; | 584 | return false; |
585 | if (numEntries(0)) | 585 | if (numEntries(0)) |
586 | return false; | 586 | return false; |
587 | return true; | 587 | return true; |
588 | } | 588 | } |
589 | /** returns the filename of this doc */ | 589 | /** returns the filename of this doc */ |
590 | const QString& getFilename() | 590 | const QString& getFilename() |
591 | { return filename; } | 591 | { return filename; } |
592 | /** returns the title of the doc */ | 592 | /** returns the title of the doc */ |
593 | QString getTitle(); | 593 | QString getTitle(); |
594 | /** sets the list-view-pointer hold in the doc */ | 594 | /** sets the list-view-pointer hold in the doc */ |
595 | void setListViewPointer(PwMView *_listView) | 595 | void setListViewPointer(PwMView *_listView) |
596 | { listView = _listView; } | 596 | { listView = _listView; } |
597 | /** returns the list-view-pointer */ | 597 | /** returns the list-view-pointer */ |
598 | PwMView * getListViewPointer() | 598 | PwMView * getListViewPointer() |
599 | { return listView; } | 599 | { return listView; } |
600 | /** try to delete the doc. The user may be asked to save | 600 | /** try to delete the doc. The user may be asked to save |
601 | * the data. The user may cancel the whole operation. | 601 | * the data. The user may cancel the whole operation. |
602 | * false is returned, then. | 602 | * false is returned, then. |
603 | */ | 603 | */ |
604 | bool tryDelete(); | 604 | bool tryDelete(); |
605 | /** is the doc deleted? (with tryDelete() ) */ | 605 | /** is the doc deleted? (with tryDelete() ) */ |
606 | bool isDeleted() | 606 | bool isDeleted() |
607 | { return deleted; } | 607 | { return deleted; } |
608 | /** returns the document timer object */ | 608 | /** returns the document timer object */ |
609 | DocTimer * timer() | 609 | DocTimer * timer() |
610 | { return _timer; } | 610 | { return _timer; } |
611 | /** get a lock on the dataChanged signal. | 611 | /** get a lock on the dataChanged signal. |
612 | * If someone is holding a lock, the signal is not emitted. | 612 | * If someone is holding a lock, the signal is not emitted. |
613 | */ | 613 | */ |
614 | void getDataChangedLock() | 614 | void getDataChangedLock() |
615 | { ++dataChangedLock; } | 615 | { ++dataChangedLock; } |
616 | /** put the dataChanged lock */ | 616 | /** put the dataChanged lock */ |
617 | void putDataChangedLock() | 617 | void putDataChangedLock() |
618 | { --dataChangedLock; } | 618 | { --dataChangedLock; } |
619 | /** returns the revision count of the item at cat/index */ | 619 | /** returns the revision count of the item at cat/index */ |
620 | unsigned int getEntryRevCnt(unsigned int category, unsigned int index) | 620 | unsigned int getEntryRevCnt(unsigned int category, unsigned int index) |
621 | { return dti.dta[category].d[index].rev; } | 621 | { return dti.dta[category].d[index].rev; } |
622 | /** returns a const pointer to the entries meta */ | 622 | /** returns a const pointer to the entries meta */ |
623 | const PwMMetaData * getEntryMeta(unsigned int category, unsigned int index) | 623 | const PwMMetaData * getEntryMeta(unsigned int category, unsigned int index) |
624 | { return &(dti.dta[category].d[index].meta); } | 624 | { return &(dti.dta[category].d[index].meta); } |
625 | /** is the entry at "category" "index" a binary entry? */ | 625 | /** is the entry at "category" "index" a binary entry? */ |
626 | bool isBinEntry(unsigned int category, unsigned int index) | 626 | bool isBinEntry(unsigned int category, unsigned int index) |
627 | { return dti.dta[category].d[index].binary; } | 627 | { return dti.dta[category].d[index].binary; } |
628 | 628 | ||
629 | public slots: | 629 | public slots: |
630 | /** wrapper for PwMTray */ | 630 | /** wrapper for PwMTray */ |
631 | void _deepUnlock(); | 631 | void _deepUnlock(); |
632 | 632 | ||
633 | signals: | 633 | signals: |
634 | /** the data of the document has changed and must be updated | 634 | /** the data of the document has changed and must be updated |
635 | * in all views. | 635 | * in all views. |
636 | * NOTE: use emitDataChanged(PwMDoc *document) to emit this signal! | 636 | * NOTE: use emitDataChanged(PwMDoc *document) to emit this signal! |
637 | */ | 637 | */ |
638 | void dataChanged(PwMDoc *document); | 638 | void dataChanged(PwMDoc *document); |
639 | /** the document class is going to close. This signal may be | 639 | /** the document class is going to close. This signal may be |
640 | * used to nofify all views, that the user closed the document, | 640 | * used to nofify all views, that the user closed the document, |
641 | * so the views can go down, too. | 641 | * so the views can go down, too. |
642 | */ | 642 | */ |
643 | void docClosed(PwMDoc *document); | 643 | void docClosed(PwMDoc *document); |
644 | /** somebody just opened the document */ | 644 | /** somebody just opened the document */ |
645 | void docOpened(PwMDoc *document); | 645 | void docOpened(PwMDoc *document); |
646 | /** this document object just got created */ | 646 | /** this document object just got created */ |
647 | void docCreated(PwMDoc *document); | 647 | void docCreated(PwMDoc *document); |
648 | 648 | ||
649 | public: | 649 | public: |
650 | /** emit the dataChanged signal after checking for a lock */ | 650 | /** emit the dataChanged signal after checking for a lock */ |
651 | void emitDataChanged(PwMDoc *document) | 651 | void emitDataChanged(PwMDoc *document) |
652 | { | 652 | { |
653 | if (!dataChangedLock) | 653 | if (!dataChangedLock) |
654 | emit dataChanged(document); | 654 | emit dataChanged(document); |
655 | } | 655 | } |
656 | 656 | ||
657 | protected: | 657 | protected: |
658 | /** current file for this doc */ | 658 | /** current file for this doc */ |
659 | QString filename; | 659 | QString filename; |
660 | //US ENH: we need a place where we keep the syncentries. So I invented | 660 | //US ENH: we need a place where we keep the syncentries. So I invented |
661 | // struct PwMItem, that has a vector of PwMCategoryItem and vector of PwMSyncItem | 661 | // struct PwMItem, that has a vector of PwMCategoryItem and vector of PwMSyncItem |
662 | /** holds all data */ | 662 | /** holds all data */ |
663 | PwMItem dti; | 663 | PwMItem dti; |
664 | /** maximum number of entries */ | 664 | /** maximum number of entries */ |
665 | unsigned int maxEntries; | 665 | unsigned int maxEntries; |
666 | /** currently used password to encrypt data */ | 666 | /** currently used password to encrypt data */ |
667 | QString currentPw; | 667 | QString currentPw; |
668 | /** current global document status flags */ | 668 | /** current global document status flags */ |
669 | unsigned int curDocStat; | 669 | unsigned int curDocStat; |
670 | /** browser process for goToURL() */ | 670 | /** browser process for goToURL() */ |
671 | KProcess browserProc; | 671 | KProcess browserProc; |
672 | /** pointer to the list-view, using this document. | 672 | /** pointer to the list-view, using this document. |
673 | * As there can only be one list-view per doc, we | 673 | * As there can only be one list-view per doc, we |
674 | * don't need a list here. | 674 | * don't need a list here. |
675 | */ | 675 | */ |
676 | PwMView *listView; | 676 | PwMView *listView; |
677 | /** unnamedNum is used to store the "unnamed counter" | 677 | /** unnamedNum is used to store the "unnamed counter" |
678 | * for this document, while it's unnamed. If it's 0, | 678 | * for this document, while it's unnamed. If it's 0, |
679 | * we have to get a new unique one. | 679 | * we have to get a new unique one. |
680 | */ | 680 | */ |
681 | unsigned int unnamedNum; | 681 | unsigned int unnamedNum; |
682 | /** is this doc going to be deleted (executing in destructor context) */ | 682 | /** is this doc going to be deleted (executing in destructor context) */ |
683 | bool deleted; | 683 | bool deleted; |
684 | /** document timer */ | 684 | /** document timer */ |
685 | DocTimer *_timer; | 685 | DocTimer *_timer; |
686 | /** lock counter for the "dataChanged" signal */ | 686 | /** lock counter for the "dataChanged" signal */ |
687 | unsigned int dataChangedLock; | 687 | unsigned int dataChangedLock; |
688 | 688 | ||
689 | /** list of all open documents */ | 689 | /** list of all open documents */ |
690 | static PwMDocList openDocList; | 690 | static PwMDocList openDocList; |
691 | 691 | ||
692 | protected: | 692 | protected: |
693 | /** serialize "dta" and return it in "d". */ | 693 | /** serialize "dta" and return it in "d". */ |
694 | bool serializeDta(string *d); | 694 | bool serializeDta(string *d); |
695 | /** de-serialize "d" and overwrite "dta" */ | 695 | /** de-serialize "d" and overwrite "dta" */ |
696 | bool deSerializeDta(const string *d, bool entriesLocked); | 696 | bool deSerializeDta(const string *d, bool entriesLocked); |
697 | /** write header to file */ | 697 | /** write header to file */ |
698 | PwMerror writeFileHeader(char keyHash, char dataHash, char crypt, char compress, | 698 | PwMerror writeFileHeader(char keyHash, char dataHash, char crypt, char compress, |
699 | QString *pw, QFile *f); | 699 | QString *pw, QFile *f); |
700 | /** write data-hash to file */ | 700 | /** write data-hash to file */ |
701 | PwMerror writeDataHash(char dataHash, string *d, QFile *f); | 701 | PwMerror writeDataHash(char dataHash, string *d, QFile *f); |
702 | /** check header. Read header info and verify key-hash and filever. | 702 | /** check header. Read header info and verify key-hash and filever. |
703 | * returns length of header in "headerLength" */ | 703 | * returns length of header in "headerLength" */ |
704 | PwMerror checkHeader(char *cryptAlgo, QString *pw, char *compress, | 704 | PwMerror checkHeader(char *cryptAlgo, QString *pw, char *compress, |
705 | unsigned int *headerLength, char *dataHashType, | 705 | unsigned int *headerLength, char *dataHashType, |
706 | string *dataHash, QFile *f); | 706 | string *dataHash, QFile *f); |
707 | /** check the data-hash */ | 707 | /** check the data-hash */ |
708 | PwMerror checkDataHash(char dataHashType, const string *dataHash, const string *dataStream); | 708 | PwMerror checkDataHash(char dataHashType, const string *dataHash, const string *dataStream); |
709 | /** encrypt data "d" and write to "filename" */ | 709 | /** encrypt data "d" and write to "filename" */ |
710 | PwMerror encrypt(string *d, const QString *pw, QFile *f, char algo); | 710 | PwMerror encrypt(string *d, const QString *pw, QFile *f, char algo); |
711 | /** read data from file beginning at "pos", decrypt and return it */ | 711 | /** read data from file beginning at "pos", decrypt and return it */ |
712 | PwMerror decrypt(string *d, unsigned int pos, const QString *pw, char algo, QFile *f); | 712 | PwMerror decrypt(string *d, unsigned int pos, const QString *pw, char algo, QFile *f); |
713 | /** compress the data */ | 713 | /** compress the data */ |
714 | bool compressDta(string *d, char algo); | 714 | bool compressDta(string *d, char algo); |
715 | /** uncompress the data */ | 715 | /** uncompress the data */ |
716 | bool decompressDta(string *d, char algo); | 716 | bool decompressDta(string *d, char algo); |
717 | /** internal import function for a text-file generated by PwM. | 717 | /** internal import function for a text-file generated by PwM. |
718 | * If this is not a valid PwM-exported file, it returns e_fileFormat */ | 718 | * If this is not a valid PwM-exported file, it returns e_fileFormat */ |
719 | PwMerror importText_PwM(const QString *file); | 719 | PwMerror importText_PwM(const QString *file); |
720 | /** PwM-text-import helper function to extract the name/pw/comment out | 720 | /** PwM-text-import helper function to extract the name/pw/comment out |
721 | * of one entry-line */ | 721 | * of one entry-line */ |
722 | bool textExtractEntry_PwM(const char *in, ssize_t in_size, string *out); | 722 | bool textExtractEntry_PwM(const char *in, ssize_t in_size, string *out); |
723 | /** compare two strings */ | 723 | /** compare two strings */ |
724 | bool compareString(const string &s1, const string &s2, bool caseSensitive, | 724 | bool compareString(const string &s1, const string &s2, bool caseSensitive, |
725 | bool exactWordMatch); | 725 | bool exactWordMatch); |
726 | /** clears all document-data */ | 726 | /** clears all document-data */ |
727 | void clearDoc(); | 727 | void clearDoc(); |
728 | /** delete all empty categories */ | 728 | /** delete all empty categories */ |
729 | void delAllEmptyCat(bool dontFlagDirty); | 729 | void delAllEmptyCat(bool dontFlagDirty); |
730 | /** set a document status flag */ | 730 | /** set a document status flag */ |
731 | void setDocStatFlag(unsigned int statFlag) | 731 | void setDocStatFlag(unsigned int statFlag) |
732 | { curDocStat |= statFlag; } | 732 | { curDocStat |= statFlag; } |
733 | /** unset a document status flag */ | 733 | /** unset a document status flag */ |
734 | void unsetDocStatFlag(unsigned int statFlag) | 734 | void unsetDocStatFlag(unsigned int statFlag) |
735 | { curDocStat &= ~statFlag; } | 735 | { curDocStat &= ~statFlag; } |
736 | /** get a document status flag */ | 736 | /** get a document status flag */ |
737 | bool getDocStatFlag(unsigned int statFlag) const | 737 | bool getDocStatFlag(unsigned int statFlag) const |
738 | { return (curDocStat & statFlag); } | 738 | { return (curDocStat & statFlag); } |
739 | /** set the "currentPassword" */ | 739 | /** set the "currentPassword" */ |
740 | void setCurrentPw(const QString &pw) | 740 | void setCurrentPw(const QString &pw) |
741 | { | 741 | { |
742 | currentPw = pw; | 742 | currentPw = pw; |
743 | setDocStatFlag(DOC_STAT_DISK_DIRTY); | 743 | setDocStatFlag(DOC_STAT_DISK_DIRTY); |
744 | } | 744 | } |
745 | /** make a backup-copy of the given file */ | 745 | /** make a backup-copy of the given file */ |
746 | bool backupFile(const QString &filePath); | 746 | bool backupFile(const QString &filePath); |
747 | /** copy a file from src to dst */ | 747 | /** copy a file from src to dst */ |
748 | bool copyFile(const QString &src, const QString &dst); | 748 | bool copyFile(const QString &src, const QString &dst); |
749 | 749 | ||
750 | 750 | ||
751 | public: | 751 | public: |
752 | #ifdef PWM_EMBEDDED | 752 | #ifdef PWM_EMBEDDED |
753 | //US ENH: this is the magic function that syncronizes the local doc with the remote doc. | 753 | //US ENH: this is the magic function that syncronizes the local doc with the remote doc. |
754 | PwMerror syncronize(KSyncManager* manager, PwMDoc* syncLocal, PwMDoc* syncRemote, int mode ); | 754 | PwMerror syncronize(KSyncManager* manager, PwMDoc* syncLocal, PwMDoc* syncRemote, int mode ); |
755 | 755 | ||
756 | //takePwMDataItem returns the following values | 756 | //takePwMDataItem returns the following values |
757 | // 0 equal | 757 | // 0 equal |
758 | // 1 take local | 758 | // 1 take local |
759 | // 2 take remote | 759 | // 2 take remote |
760 | // 3 cancel | 760 | // 3 cancel |
761 | int takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full ); | 761 | int takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full ); |
762 | 762 | ||
763 | //the following methods are the overwritten callbackmethods from the syncinterface | 763 | //the following methods are the overwritten callbackmethods from the syncinterface |
764 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 764 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
765 | virtual void removeSyncInfo( QString syncProfile); | ||
765 | 766 | ||
766 | #endif | 767 | #endif |
767 | private: | 768 | private: |
768 | //US ENH: helpermethods to access the sync data for a certain syncname. | 769 | //US ENH: helpermethods to access the sync data for a certain syncname. |
769 | // It returns the syncdatas index | 770 | // It returns the syncdatas index |
770 | bool findSyncData(const QString &syncname, unsigned int *index); | 771 | bool findSyncData(const QString &syncname, unsigned int *index); |
771 | 772 | ||
772 | /** add new syncdataentry */ | 773 | /** add new syncdataentry */ |
773 | PwMerror addSyncDataEntry(PwMSyncItem *d, bool dontFlagDirty = false); | 774 | PwMerror addSyncDataEntry(PwMSyncItem *d, bool dontFlagDirty = false); |
774 | 775 | ||
775 | /** returns a pointer to the syncdata */ | 776 | /** returns a pointer to the syncdata */ |
776 | PwMSyncItem* getSyncDataEntry(unsigned int index) | 777 | PwMSyncItem* getSyncDataEntry(unsigned int index) |
777 | { return &(dti.syncDta[index]); } | 778 | { return &(dti.syncDta[index]); } |
778 | 779 | ||
779 | /** delete entry */ | 780 | /** delete entry */ |
780 | bool delSyncDataEntry(unsigned int index, bool dontFlagDirty = false); | 781 | bool delSyncDataEntry(unsigned int index, bool dontFlagDirty = false); |
781 | 782 | ||
782 | PwMDataItem* findEntryByID(const QString &uid, unsigned int *category, unsigned int *index); | 783 | PwMDataItem* findEntryByID(const QString &uid, unsigned int *category, unsigned int *index); |
783 | 784 | ||
784 | QStringList getIDEntryList(); | 785 | QStringList getIDEntryList(); |
785 | 786 | ||
786 | }; | 787 | }; |
787 | 788 | ||
788 | #endif | 789 | #endif |