示例#1
0
int main( int argc, char **argv )
{
  KAboutData aboutData( "testkabcdlg", 0, ki18n( "TestKabc" ), "0.1" );
  KCmdLineArgs::init( argc, argv, &aboutData );

  KCmdLineOptions options;
  options.add( "multiple", ki18n( "Allow selection of multiple addressees" ) );
  KCmdLineArgs::addCmdLineOptions( options );

  KApplication app;

  KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
  if ( args->isSet( "multiple" ) ) {
    Addressee::List al = AddresseeDialog::getAddressees( 0 );
    Addressee::List::ConstIterator it;
    kDebug() << "Selected Addressees:";
    for ( it = al.constBegin(); it != al.constEnd(); ++it ) {
      kDebug() << "  " << ( *it ).fullEmail();
    }
  } else {
    Addressee a = AddresseeDialog::getAddressee( 0 );

    if ( !a.isEmpty() ) {
      kDebug() << "Selected Addressee:";
      kDebug() << a.toString();
    } else {
      kDebug() << "No Addressee selected.";
    }
  }
}
示例#2
0
bool ResourceEvolution::load()
{
    /* doOpen never get's called :( */
    if(!doOpen())
        return false;
    if(!mWrap)
        return false; // open first!

    DBIterator it = mWrap->begin();
    // skip the "PAS-DB-VERSION"

    for(; it != mWrap->end(); ++it)
    {
        if(it.key().startsWith("PAS-DB-VERSION"))
            continue;

        qWarning("val:%s", it.value().latin1());
        VCardTool tool;
        QString str = it.value().stripWhiteSpace();
        Addressee::List list = tool.parseVCards(str);
        if(!list.first().isEmpty())
        {
            Addressee adr = list.first();
            adr.setResource(this);
            addressBook()->insertAddressee(adr);
        }
    }
    return true;
}
示例#3
0
AddresseeItem::AddresseeItem( TQListView *parent, const Addressee &addressee ) :
  TQListViewItem( parent ),
  mAddressee( addressee )
{
  setText( Name, addressee.realName() );
  setText( Email, addressee.preferredEmail() );
}
示例#4
0
QString KABCHandler::vcard30(const QString& uid) const
{
    Addressee contact = m_addressBook->findByUid(uid);

    if (contact.isEmpty()) return QString::null;

    return m_vcardConverter->createVCard(contact, VCardConverter::v3_0);
}
示例#5
0
bool SortingTraits::GivenName::lt( const Addressee &a1, const Addressee &a2 )
{
  int given = TQString::localeAwareCompare( a1.givenName(), a2.givenName() );
  if ( 0 == given ) {
    return ( TQString::localeAwareCompare( a1.familyName(), a2.familyName() ) < 0 );
  } else {
    return given < 0;
  }
}
示例#6
0
void VCardFormatImpl::readNValue( ContentLine *cl, Addressee &a )
{
  NValue *v = (NValue *)cl->value();
  a.setFamilyName( QString::fromUtf8( v->family() ) );
  a.setGivenName( QString::fromUtf8( v->given() ) );
  a.setAdditionalName( QString::fromUtf8( v->middle() ) );
  a.setPrefix( QString::fromUtf8( v->prefix() ) );
  a.setSuffix( QString::fromUtf8( v->suffix() ) );
}
示例#7
0
bool SortingTraits::FamilyName::lt( const Addressee &a1, const Addressee &a2 )
{
    int family = QString::localeAwareCompare( a1.familyName(), a2.familyName() );
    if ( 0 == family ) {
        return ( QString::localeAwareCompare( a1.givenName(), a2.givenName() ) < 0 );
    } else {
        return family < 0;
    }
}
示例#8
0
int main( int argc, char **argv )
{
  KAboutData aboutData( "bigwrite", 0, ki18n( "BigWriteKabc" ), "0.1" );
  KCmdLineArgs::init( argc, argv, &aboutData );

  KApplication app( false );

  AddressBook ab;
  ResourceFile r( QLatin1String( "my.kabc" ), QLatin1String( "vcard" ) );
  ab.addResource( &r );

  for ( int i = 0; i < 5000; ++i ) {
    Addressee a;
    a.setGivenName( QLatin1String( "number" ) + QString::number( i ) );
    a.setFamilyName( QLatin1String( "Name" ) );
    a.insertEmail( QString::number( i ) + QLatin1String( "@domain" ) );

    ab.insertAddressee( a );
  }
  printf( "\n" );

  Ticket *t = ab.requestSaveTicket( &r );
  if ( t ) {
    struct tms start;

    times( &start );

#if 0
    kDebug() << "utime :" << int( start.tms_utime );
    kDebug() << "stime :" << int( start.tms_stime );
    kDebug() << "cutime:" << int( start.tms_cutime );
    kDebug() << "cstime:" << int( start.tms_cstime );
#endif

    if ( !ab.save( t ) ) {
      kDebug() << "Can't save.";
    }

    struct tms end;

    times( &end );

#if 0
    kDebug() << "utime :" << int( end.tms_utime );
    kDebug() << "stime :" << int( end.tms_stime );
    kDebug() << "cutime:" << int( end.tms_cutime );
    kDebug() << "cstime:" << int( end.tms_cstime );
#endif

    kDebug() << "UTime:" << int( end.tms_utime ) - int( start.tms_utime );
    kDebug() << "STime:" << int( end.tms_stime ) - int( start.tms_stime );

  } else {
    kDebug() << "No ticket for save.";
  }
}
示例#9
0
bool KABCHandler::getEmails(const QString& uid, QStringList& emails) const
{
    Addressee contact = m_addressBook->findByUid(uid);

    if (contact.isEmpty()) return false;

    emails = contact.emails();

    return true;
}
示例#10
0
int main(int argc, char **argv)
{
    KAboutData aboutData("testaddressee", "TestAddressee", "0.1");
    KCmdLineArgs::init(argc, argv, &aboutData);
    KCmdLineArgs::addCmdLineOptions(options);

    KApplication app;
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

    kdDebug() << "Creating a" << endl;
    Addressee a;

    kdDebug() << "tick1" << endl;
    a.setGivenName("Hans");
    kdDebug() << "tick2" << endl;
    a.setPrefix("Dr.");

    kdDebug() << "Creating b" << endl;
    Addressee b(a);

    kdDebug() << "tack1" << endl;
    a.setFamilyName("Wurst");
    kdDebug() << "tack2" << endl;
    a.setNickName("hansi");

    kdDebug() << "Creating c" << endl;
    Addressee c = a;

    kdDebug() << "tock1" << endl;
    c.setGivenName("Eberhard");

    a.dump();
    b.dump();
    c.dump();
}
示例#11
0
Addressee
vcard3()
{
    Addressee addr;

    addr.setName( "ian geiser" );
    addr.setOrganization( "Source eXtreme" );
    addr.insertEmail( "*****@*****.**" );
    addr.setTitle( "VP of Engineering" );
    return addr;
}
示例#12
0
Addressee AddressBook::findByUid( const QString &uid ) const
{
  KRES::Manager<Resource>::ActiveIterator it;
  for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
    Addressee addr = ( *it )->findByUid( uid );
    if ( !addr.isEmpty() ) {
      return addr;
    }
  }

  return Addressee();
}
示例#13
0
bool KABCHandler::getNames(const QString& uid, QCString& givenName,
                           QCString& familyName, QCString& fullName) const
{
    Addressee contact = m_addressBook->findByUid(uid);

    if (contact.isEmpty()) return false;

    givenName  = contact.givenName().utf8();
    familyName = contact.familyName().utf8();
    fullName   = contact.assembledName().utf8();

    return true;
}
示例#14
0
void AddresseeDialog::addSelected( TQListViewItem *item )
{
  AddresseeItem *addrItem = dynamic_cast<AddresseeItem *>( item );
  if ( !addrItem ) return;

  Addressee a = addrItem->addressee();

  TQListViewItem *selectedItem = mSelectedDict.find( a.uid() );
  if ( !selectedItem ) {
    selectedItem = new AddresseeItem( mSelectedList, a );
    mSelectedDict.insert( a.uid(), selectedItem );
  }
}
示例#15
0
void VCardFormatImpl::addNValue( VCARD::VCard *vcard, const Addressee &a )
{
  ContentLine cl;
  cl.setName(EntityTypeToParamName( EntityN ) );
  NValue *v = new NValue;
  v->setFamily( a.familyName().utf8() );
  v->setGiven( a.givenName().utf8() );
  v->setMiddle( a.additionalName().utf8() );
  v->setPrefix( a.prefix().utf8() );
  v->setSuffix( a.suffix().utf8() );

  cl.setValue( v );
  vcard->add(cl);
}
示例#16
0
 EditEntryItem( QListView *parent, const Addressee &addressee,
            const QString &email=QString::null ) :
   QListViewItem( parent ),
   mAddressee( addressee ),
   mEmail( email )
 {
   setText( 0, addressee.realName() );
   if( email.isEmpty() ) {
     setText( 1, addressee.preferredEmail() );
     setText( 2, i18n("Yes") );
   } else {
     setText( 1, email );
     setText( 2, i18n("No") );
   }
 }
示例#17
0
void VCardFormatImpl::addSoundValue( VCARD::VCard *vcard, const Sound &sound, const Addressee &addr, bool intern )
{
  ContentLine cl;
  cl.setName( EntityTypeToParamName( EntitySound ) );

  if ( sound.isIntern() && sound.data().isNull() )
    return;

  if ( !sound.isIntern() && sound.url().isEmpty() )
    return;

  ParamList params;
  if ( sound.isIntern() ) {
    QByteArray data = sound.data();
    if ( intern ) { // only for vCard export we really write the data inline
        cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) );
    } else { // save sound in cache
      QFile file( locateLocal( "data", "kabc/sounds/" + addr.uid() ) );
      if ( file.open( IO_WriteOnly ) ) {
        file.writeBlock( data );
      }
      cl.setValue( new TextValue( "<dummy>" ) );
    }
    params.append( new Param( "ENCODING", "b" ) );
  } else {
    cl.setValue( new TextValue( sound.url().utf8() ) );
    params.append( new Param( "VALUE", "uri" ) );
  }

  cl.setParamList( params );
  vcard->add( cl );
}
示例#18
0
Sound VCardFormatImpl::readSoundValue( VCARD::ContentLine *cl, const Addressee &addr )
{
  Sound sound;
  bool isInline = false;
  TextValue *v = (TextValue *)cl->value();

  ParamList params = cl->paramList();
  ParamListIterator it( params );
  for( ; it.current(); ++it ) {
    if ( (*it)->name() == "ENCODING" && (*it)->value() == "b" )
      isInline = true;
  }

  if ( isInline ) {
    QByteArray data;
    if ( v->asString() == "<dummy>" ) { // no sound inline stored => sound is in cache
      QFile file( locateLocal( "data", "kabc/sounds/" + addr.uid() ) );
      if ( file.open( IO_ReadOnly ) ) {
        data = file.readAll();
        file.close();
      }
    } else {
      KCodecs::base64Decode( v->asString(), data );
    }
    sound.setData( data );
  } else {
    sound.setUrl( QString::fromUtf8( v->asString() ) );
  }

  return sound;
}
示例#19
0
void ResourceEvolution::removeAddressee(const Addressee &rem)
{
    if(!m_isOpen)
        return;

    mWrap->remove(rem.uid());
}
示例#20
0
void ResourceSlox::slotUploadResult( KIO::Job *job )
{
  kdDebug() << "ResourceSlox::slotUploadResult()" << endl;

  if ( job->error() ) {
    job->showErrorDialog( 0 );
  } else {
    kdDebug() << "ResourceSlox::slotUploadResult() success" << endl;

    QDomDocument doc = mUploadJob->response();
    kdDebug() << k_funcinfo << "Upload result: " << endl;
    kdDebug() << doc.toString() << endl;

    QValueList<SloxItem> items = WebdavHandler::getSloxItems( this, doc );

    QValueList<SloxItem>::ConstIterator it;
    for( it = items.begin(); it != items.end(); ++it ) {
      SloxItem item = *it;
      if ( !item.response.contains( "200" ) ) {
        savingError( this, item.response + "\n" + item.responseDescription );
        continue;
      }
      if ( item.status == SloxItem::New ) {
        QMap<QString,Addressee>::Iterator search_res;
        search_res = mAddrMap.find( item.clientId );
        if ( search_res != mAddrMap.end() ) {
          // use the id provided by the server
          Addressee a = *search_res;
          mAddrMap.remove( search_res );
          a.setUid( "kresources_slox_kabc_" + item.sloxId );
          a.setResource( this );
          a.setChanged( false );
          mAddrMap.replace( a.uid(), a );
          saveCache();
        }
      }
    }
  }

  clearChange( mUploadAddressee );

  mUploadJob = 0;
  mUploadProgress->setComplete();
  mUploadProgress = 0;

  uploadContacts();
}
示例#21
0
QStringList DistributionList::emails() const
{
  QStringList emails;

  Entry::List::ConstIterator it;
  for( it = mEntries.begin(); it != mEntries.end(); ++it ) {
    Addressee a = (*it).addressee;
    QString email = (*it).email.isEmpty() ? a.fullEmail() :
                                            a.fullEmail( (*it).email );

    if ( !email.isEmpty() ) {
      emails.append( email );
    }
  }
  
  return emails;
}
示例#22
0
void AddresseeEditorWidget::nameTextChanged( const QString &text )
{
  // use the addressee class to parse the name for us
  AddresseeConfig config( mAddressee );
  if ( config.automaticNameParsing() ) {
    if ( !mAddressee.formattedName().isEmpty() ) {
      QString fn = mAddressee.formattedName();
      mAddressee.setNameFromString( text );
      mAddressee.setFormattedName( fn );
    } else {
      // use extra addressee to avoid a formatted name assignment
      Addressee addr;
      addr.setNameFromString( text );
      mAddressee.setPrefix( addr.prefix() );
      mAddressee.setGivenName( addr.givenName() );
      mAddressee.setAdditionalName( addr.additionalName() );
      mAddressee.setFamilyName( addr.familyName() );
      mAddressee.setSuffix( addr.suffix() );
    }
  }

  nameBoxChanged();

  emitModified();
}
示例#23
0
bool DistributionListManager::load()
{
  KSimpleConfig cfg( locateLocal( "data", "kabc/distlists" ) );

  QMap<QString,QString> entryMap = cfg.entryMap( "DistributionLists" );
  cfg.setGroup( "DistributionLists" );

  // clear old lists
  mLists.clear();
  d->mMissingEntries.clear();

  QMap<QString,QString>::ConstIterator it;
  for( it = entryMap.constBegin(); it != entryMap.constEnd(); ++it ) {
    QString name = it.key();
    QStringList value = cfg.readListEntry( name );

    kdDebug(5700) << "DLM::load(): " << name << ": " << value.join(",") << endl;

    DistributionList *list = new DistributionList( this, name );

    MissingEntryList missingEntries;
    QStringList::ConstIterator entryIt = value.constBegin();
    while( entryIt != value.constEnd() ) {
      QString id = *entryIt++;
      QString email = *entryIt;

      kdDebug(5700) << "----- Entry " << id << endl; 
      
      Addressee a = d->mAddressBook->findByUid( id );
      if ( !a.isEmpty() ) {
        list->insertEntry( a, email );
      } else {
        missingEntries.append( qMakePair( id, email ) );
      }
      
      if ( entryIt == value.end() )
        break;
      ++entryIt;
    }

    d->mMissingEntries.insert( name, missingEntries );
  }
  
  return true;
}
示例#24
0
void KraftView::slotNewAddress( const Addressee& contact, bool interactive )
{

  Addressee adr( contact );

  if( contact.isEmpty() ) {
    return;
  }
  QString newAddress = mAddressProvider->formattedAddress( contact );
  const QString currAddress = m_headerEdit->m_postAddressEdit->toPlainText();

  bool replace = true;
  m_headerEdit->m_labName->setText( contact.realName() );

  if( currAddress.isEmpty() ) {
    replace = true;
  } else if( currAddress != newAddress ) {
    // non empty and current different from new address
    // need to ask first if we overwrite
    if( interactive ) {
        if( KMessageBox::questionYesNo( this, i18n("The address label is not empty and different from the selected one.<br/>"
                                                   "Do you really want to replace it with the text shown below?<pre>%1</pre>").arg(newAddress),
                                     i18n("Address Overwrite") ) == KMessageBox::No ) replace = false;
    } else {
      // this happens when the document is loaded and the address arrives from addressbook
      replace = false;
    }
  } else if( currAddress == newAddress ) {
    // both are equal, no action needed
    return;
  }

  if( replace ) {
    mContactUid = contact.uid();

    m_headerEdit->m_postAddressEdit->setText( newAddress );

    // Generate the welcome
    m_headerEdit->m_letterHead->clear();
    QStringList li = generateLetterHead( adr );

    m_headerEdit->m_letterHead->insertItems(-1, li );
    m_headerEdit->m_letterHead->setCurrentIndex( KraftSettings::self()->salut() );
  }
}
示例#25
0
void DistributionList::removeEntry( const Addressee &a, const QString &email )
{
  QValueList<Entry>::Iterator it;
  for( it = mEntries.begin(); it != mEntries.end(); ++it ) {
    if ( (*it).addressee.uid() == a.uid() && (*it).email == email ) {
      mEntries.remove( it );
      return;
    }
  }
}
示例#26
0
void DistributionList::removeEntry( const Addressee &a, const QString &email )
{
  QList<Entry>::Iterator it;
  for ( it = d->mEntries.begin(); it != d->mEntries.end(); ++it ) {
    if ( ( *it ).addressee().uid() == a.uid() && ( *it ).email() == email ) {
      d->mEntries.erase( it );
      return;
    }
  }
}
示例#27
0
int main(int argc,char **argv)
{
    KAboutData aboutData("testkabc",I18N_NOOP("TestKabc"),"0.1");
    KCmdLineArgs::init(argc, argv, &aboutData);

    KApplication app( false, false );
    AddressBook *ab = StdAddressBook::self();

#define READ

#ifdef READ
    AddressBook::Iterator it;
    for ( it = ab->begin(); it != ab->end(); ++it ) {
      QString vcard;
      VCardConverter converter;
      converter.addresseeToVCard( *it, vcard );
      kdDebug() << "card=" << vcard << endl;
    }
#else
    Addressee addr;

    addr.setGivenName("Tobias");
    addr.setFamilyName("Koenig");


    Picture pic;
    QImage img;
    img.load("/home/tobias/test.png");
/*
    pic.setData(img);
    pic.setType(QImage::imageFormat("/home/tobias/test.png"));
*/
    pic.setUrl("http://www.mypict.de");
    addr.setLogo( pic );

    ab->insertAddressee( addr );

    StdAddressBook::save();
#endif

    return 0;
}
示例#28
0
bool VCardFormat::loadAll( AddressBook *, Resource *resource, QFile *file )
{
  QByteArray data;

  data = file->readAll();

  VCardConverter converter;

  Addressee::List l = converter.parseVCards( data );

  Addressee::List::iterator itr;
  for ( itr = l.begin(); itr != l.end(); ++itr ) {
    Addressee addressee = *itr;
    addressee.setResource( resource );
    addressee.setChanged( false );
    resource->insertAddressee( addressee );
  }

  return true;
}
示例#29
0
AddressBook::ConstIterator AddressBook::find( const Addressee &a ) const
{
  ConstIterator it;
  for ( it = begin(); it != end(); ++it ) {
    if ( a.uid() == ( *it ).uid() ) {
      return it;
    }
  }

  return end();
}
示例#30
0
bool VCardFormatImpl::loadAll( AddressBook *addressBook, Resource *resource, QFile *file )
{
  kdDebug(5700) << "VCardFormat::loadAll()" << endl;

  QByteArray fdata = file->readAll();
  QCString data(fdata.data(), fdata.size()+1);

  VCardEntity e( data );

  VCardListIterator it( e.cardList() );

  for (; it.current(); ++it) {
    VCARD::VCard v(*it.current());
    Addressee addressee;
    loadAddressee( addressee, v );
    addressee.setResource( resource );
    addressBook->insertAddressee( addressee );
  }

  return true;
}