author | eilers <eilers> | 2003-02-28 10:25:31 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-02-28 10:25:31 (UTC) |
commit | 81cbb2d97b4f0cd7eef56536d791434856d7ae8d (patch) (unidiff) | |
tree | 644f7c1dc38c07b67b9337a4138ca80741d0c9ca | |
parent | 18c19111466e43e91678c5a1fa50f2f561ca3257 (diff) | |
download | opie-81cbb2d97b4f0cd7eef56536d791434856d7ae8d.zip opie-81cbb2d97b4f0cd7eef56536d791434856d7ae8d.tar.gz opie-81cbb2d97b4f0cd7eef56536d791434856d7ae8d.tar.bz2 |
Beaming personal vcard on keypress is implented now !
-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index 0276231..8937227 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp | |||
@@ -529,69 +529,71 @@ void AddressbookWindow::writeMail() | |||
529 | qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1()); | 529 | qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1()); |
530 | if ( QFile::exists( basepath + "/bin/mail" ) ){ | 530 | if ( QFile::exists( basepath + "/bin/mail" ) ){ |
531 | qWarning ("QCop"); | 531 | qWarning ("QCop"); |
532 | QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)"); | 532 | QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)"); |
533 | e << name << email; | 533 | e << name << email; |
534 | return; | 534 | return; |
535 | } else | 535 | } else |
536 | m_config.setUseQtMail( true ); | 536 | m_config.setUseQtMail( true ); |
537 | } | 537 | } |
538 | 538 | ||
539 | } | 539 | } |
540 | 540 | ||
541 | static const char * beamfile = "/tmp/obex/contact.vcf"; | 541 | static const char * beamfile = "/tmp/obex/contact.vcf"; |
542 | 542 | ||
543 | void AddressbookWindow::slotBeam() | 543 | void AddressbookWindow::slotBeam() |
544 | { | 544 | { |
545 | QString filename; | 545 | QString beamFilename; |
546 | OContact c; | 546 | OContact c; |
547 | if ( actionPersonal->isOn() ) { | 547 | if ( actionPersonal->isOn() ) { |
548 | filename = addressbookPersonalVCardName(); | 548 | beamFilename = addressbookPersonalVCardName(); |
549 | if (!QFile::exists(filename)) | 549 | if ( !QFile::exists( beamFilename ) ) |
550 | return; // can't beam a non-existent file | 550 | return; // can't beam a non-existent file |
551 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 551 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
552 | filename ); | 552 | beamFilename ); |
553 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 553 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
554 | OContactAccess::List allList = access->allRecords(); | 554 | OContactAccess::List allList = access->allRecords(); |
555 | OContactAccess::List::Iterator it = allList.begin(); // Just take first | 555 | OContactAccess::List::Iterator it = allList.begin(); // Just take first |
556 | c = *it; | 556 | c = *it; |
557 | 557 | ||
558 | delete access; | 558 | delete access; |
559 | } else { | 559 | } else { |
560 | unlink( beamfile ); // delete if exists | 560 | unlink( beamfile ); // delete if exists |
561 | mkdir("/tmp/obex/", 0755); | 561 | mkdir("/tmp/obex/", 0755); |
562 | c = m_abView -> currentEntry(); | 562 | c = m_abView -> currentEntry(); |
563 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 563 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
564 | beamfile ); | 564 | beamfile ); |
565 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 565 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
566 | access->add( c ); | 566 | access->add( c ); |
567 | access->save(); | 567 | access->save(); |
568 | delete access; | 568 | delete access; |
569 | 569 | ||
570 | filename = beamfile; | 570 | beamFilename = beamfile; |
571 | } | 571 | } |
572 | 572 | ||
573 | qWarning("Beaming: %s", beamFilename.latin1() ); | ||
573 | 574 | ||
574 | Ir *ir = new Ir( this ); | 575 | Ir *ir = new Ir( this ); |
575 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 576 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
576 | QString description = c.fullName(); | 577 | QString description = c.fullName(); |
577 | ir->send( filename, description, "text/x-vCard" ); | 578 | ir->send( beamFilename, description, "text/x-vCard" ); |
578 | } | 579 | } |
579 | 580 | ||
580 | void AddressbookWindow::beamDone( Ir *ir ) | 581 | void AddressbookWindow::beamDone( Ir *ir ) |
581 | { | 582 | { |
583 | |||
582 | delete ir; | 584 | delete ir; |
583 | unlink( beamfile ); | 585 | unlink( beamfile ); |
584 | } | 586 | } |
585 | 587 | ||
586 | 588 | ||
587 | static void parseName( const QString& name, QString *first, QString *middle, | 589 | static void parseName( const QString& name, QString *first, QString *middle, |
588 | QString * last ) | 590 | QString * last ) |
589 | { | 591 | { |
590 | 592 | ||
591 | int comma = name.find ( "," ); | 593 | int comma = name.find ( "," ); |
592 | QString rest; | 594 | QString rest; |
593 | if ( comma > 0 ) { | 595 | if ( comma > 0 ) { |
594 | *last = name.left( comma ); | 596 | *last = name.left( comma ); |
595 | comma++; | 597 | comma++; |
596 | while ( comma < int(name.length()) && name[comma] == ' ' ) | 598 | while ( comma < int(name.length()) && name[comma] == ' ' ) |
597 | comma++; | 599 | comma++; |
@@ -626,35 +628,41 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) | |||
626 | 628 | ||
627 | OContact cnt; | 629 | OContact cnt; |
628 | QString fn, mn, ln; | 630 | QString fn, mn, ln; |
629 | parseName( name, &fn, &mn, &ln ); | 631 | parseName( name, &fn, &mn, &ln ); |
630 | // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); | 632 | // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); |
631 | cnt.setFirstName( fn ); | 633 | cnt.setFirstName( fn ); |
632 | cnt.setMiddleName( mn ); | 634 | cnt.setMiddleName( mn ); |
633 | cnt.setLastName( ln ); | 635 | cnt.setLastName( ln ); |
634 | cnt.insertEmails( email ); | 636 | cnt.insertEmails( email ); |
635 | cnt.setDefaultEmail( email ); | 637 | cnt.setDefaultEmail( email ); |
636 | cnt.setFileAs(); | 638 | cnt.setFileAs(); |
637 | 639 | ||
638 | m_abView -> addEntry( cnt ); | 640 | m_abView -> addEntry( cnt ); |
639 | 641 | ||
640 | // :SXm_abView()->init( cnt ); | 642 | // :SXm_abView()->init( cnt ); |
641 | editEntry( EditEntry ); | 643 | editEntry( EditEntry ); |
642 | 644 | } else if ( msg == "beamBusinessCard()" ) { | |
643 | 645 | QString beamFilename = addressbookPersonalVCardName(); | |
644 | 646 | if ( !QFile::exists( beamFilename ) ) | |
647 | return; // can't beam a non-existent file | ||
648 | |||
649 | Ir *ir = new Ir( this ); | ||
650 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | ||
651 | QString description = "mycard.vcf"; | ||
652 | ir->send( beamFilename, description, "text/x-vCard" ); | ||
645 | } | 653 | } |
646 | #if 0 | 654 | #if 0 |
647 | else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) { | 655 | else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) { |
648 | QDataStream stream(data,IO_ReadOnly); | 656 | QDataStream stream(data,IO_ReadOnly); |
649 | QCString ch,m; | 657 | QCString ch,m; |
650 | QStringList types; | 658 | QStringList types; |
651 | stream >> ch >> m >> types; | 659 | stream >> ch >> m >> types; |
652 | AddressPicker picker(abList,this,0,TRUE); | 660 | AddressPicker picker(abList,this,0,TRUE); |
653 | picker.showMaximized(); | 661 | picker.showMaximized(); |
654 | picker.setChoiceNames(types); | 662 | picker.setChoiceNames(types); |
655 | int i=0; | 663 | int i=0; |
656 | for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { | 664 | for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { |
657 | QStringList sel; | 665 | QStringList sel; |
658 | stream >> sel; | 666 | stream >> sel; |
659 | picker.setSelection(i++,sel); | 667 | picker.setSelection(i++,sel); |
660 | } | 668 | } |