Beispiel #1
0
void KOAttendeeEditor::openAddressBook()
{
#ifndef KORG_NOKABC
  KPIM::AddressesDialog *dia = new KPIM::AddressesDialog( this, "adddialog" );
  dia->setShowCC( false );
  dia->setShowBCC( false );
  if ( dia->exec() ) {
    KABC::Addressee::List aList = dia->allToAddressesNoDuplicates();
    for ( KABC::Addressee::List::iterator itr = aList.begin();
          itr != aList.end(); ++itr ) {
      insertAttendeeFromAddressee( (*itr) );
    }
  }
  delete dia;
  return;
#if 0
    // old code
    KABC::Addressee a = KABC::AddresseeDialog::getAddressee(this);
    if (!a.isEmpty()) {
        // If this is myself, I don't want to get a response but instead
        // assume I will be available
        bool myself = KOPrefs::instance()->thatIsMe( a.preferredEmail() );
        KCal::Attendee::PartStat partStat =
            myself ? KCal::Attendee::Accepted : KCal::Attendee::NeedsAction;
        insertAttendee( new Attendee( a.realName(), a.preferredEmail(),
                                      !myself, partStat,
                                      KCal::Attendee::ReqParticipant, a.uid() ) );
    }
#endif
#endif
}
Beispiel #2
0
void ResourceGroupwise::slotReadJobData( KIO::Job *job , const QByteArray &data )
{
  kdDebug() << "ResourceGroupwise::slotReadJobData()" << endl;
  Q_UNUSED( job );

  mJobData.append( data.data() );

  KABC::VCardConverter conv;
  QTime profile;
  profile.start();
  Addressee::List addressees = conv.parseVCards( mJobData );
 // kdDebug() << "  parsed " << addressees.count() << " contacts in "  << profile.elapsed() << "ms, now adding to resource..." << endl;

  Addressee::List::ConstIterator it;
  for( it = addressees.begin(); it != addressees.end(); ++it ) {
    KABC::Addressee addr = *it;
    if ( !addr.isEmpty() ) {
      addr.setResource( this );

      QString remote = addr.custom( "GWRESOURCE", "UID" );
      QString local = idMapper().localId( remote );
      if ( local.isEmpty() ) {
        idMapper().setRemoteId( addr.uid(), remote );
      } else {
        addr.setUid( local );
      }

      insertAddressee( addr );
      clearChange( addr );
    }
  }
  mJobData = QString::null;
}
bool GroupDavGlobals::interpretAddressBookDownloadItemsJob(
    KABC::AddressBookAdaptor *adaptor, KIO::Job *job, const QString &jobData)
{
    kdDebug(5800) << "GroupDavGlobals::interpretAddressBookDownloadItemsJob, vCard=" << endl;
    kdDebug(5800) << jobData << endl;
    if(!adaptor || !job) return false;

    KABC::VCardConverter conv;
    KABC::Addressee::List addrs(conv.parseVCards(jobData));

    if(addrs.count() != 1)
    {
        kdError() << "Parsed vCard does not contain exactly one addressee." << endl;
        return false;
    }

    KABC::Addressee a = addrs.first();

    KIO::SimpleJob *sjob = dynamic_cast<KIO::SimpleJob *>(job);
    KURL remoteId;
    if(sjob) remoteId = sjob->url();
    QString fingerprint = extractFingerprint(job, jobData);
    adaptor->addressbookItemDownloaded(a, a.uid(), remoteId, fingerprint,
                                       remoteId.prettyURL());
    return true;
}
Beispiel #4
0
QString ContactsModel::getAvatar(KABC::Addressee contact) const
{
    KABC::Picture pic = contact.photo();
    qDebug() << "Picture url: " << pic.url();

    if (pic.isIntern()) {
        QString url = "contacts/"+contact.uid();
        ImageProvider::getInstance()->registerImage(url, pic.data());
        return "image://images/"+url;
    } else
        return pic.url();
}
Beispiel #5
0
    bool AddressbookHandler::retrieveAddresseeListFromDevice( KABC::Addressee::List &mAddresseeList, QValueList<uint32_t> &idList )
    {
        KABC::VCardConverter vCardConv;
        bool ret = true;

        for ( QValueList<uint32_t>::const_iterator it = idList.begin(); it != idList.end(); ++it ) {
            incrementSteps();

            kdDebug(2120) << "Retrieving Contact from device: " << "RRA-ID-" +
                    QString::number ( *it, 16 ).rightJustify( 8, '0' ) << endl;

            QString vCard = m_rra->getVCard( mTypeId, *it );
            if (vCard.isEmpty()) {
                addErrorEntry("RRA-ID-" + QString::number ( *it, 16 ).rightJustify( 8, '0' ));
                ret = false;
            }

            KABC::Addressee addr = vCardConv.parseVCard ( vCard );
            addr.setFormattedName(addr.formattedName().replace("\\,", ","));

            QString kdeId;

            if ((kdeId = mUidHelper->kdeId("SynCEAddressbook", addr.uid(), "---")) != "---") {
                addr.setUid(kdeId);
            } else {
                mUidHelper->addId("SynCEAddressbook", addr.uid(), addr.uid());
            }

            kdDebug(2120) << "    ID-Pair: KDEID: " << addr.uid() << " DeviceID: " <<
                "RRA-ID-" + QString::number ( *it, 16 ).rightJustify( 8, '0' ) << endl;

            mAddresseeList.push_back( addr );

            KApplication::kApplication()->processEvents();
        }

        return ret;
    }
Beispiel #6
0
void ResourceGroupwise::slotUpdateJobData( KIO::Job *job, const QByteArray &data )
{
  kdDebug() << "ResourceGroupwise::slotUpdateJobData()" << endl;
  kdDebug() << "  Job address: " << job << endl;
  KABC::VCardConverter conv;
  mJobData.append( data.data() );

  Addressee::List addressees = conv.parseVCards( mJobData );
  Addressee::List::ConstIterator it;

  for( it = addressees.begin(); it != addressees.end(); ++it ) {
    KABC::Addressee addr = *it;
    if ( !addr.isEmpty() ) {
      // if added or changed
      QString syncType = addr.custom( "GWRESOURCE", "SYNC" );
      QString remote = addr.custom( "GWRESOURCE", "UID" );
      QString local = idMapper().localId( remote );

      if ( syncType == "ADD" || syncType == "UPD" )
      {
        addr.setResource( this );
          if ( local.isEmpty() ) {
          idMapper().setRemoteId( addr.uid(), remote );
        } else {
          addr.setUid( local );
        }

        insertAddressee( addr );
        clearChange( addr );
      }
      else if ( syncType == "DEL" )
      {
        // if deleted
        if ( !remote.isEmpty() )
        {
          if ( !local.isEmpty() )
          {
            idMapper().removeRemoteId( remote );
            KABC::Addressee addrToDelete = findByUid( local );
            removeAddressee( addrToDelete );
          }
        }
        else
          kdError() << "Addressee to delete did not have a remote UID, unable to find the corresponding local contact" << endl;
      }
    }
  }
  mJobData = QString::null;
}
Beispiel #7
0
void AddresseeEditorWidget::setAddressee( const KABC::Addressee &addr )
{
  if ( mAddressee.uid() == addr.uid() )
    return;
  mAddressee = addr;

  bool readOnly = false;
  if ( KABC::Resource *res = addr.resource() ) {
    if ( res->readOnly() ) {
      readOnly = true;

    //Kolab resources have finer access control than planned in the overall design.
    } else if ( res->inherits( "KPIM::ResourceABC" ) ) {
      KPIM::ResourceABC *resAbc = static_cast<KPIM::ResourceABC *>( res );

      QString subresource = resAbc->uidToResourceMap()[ addr.uid() ];
      if ( !subresource.isEmpty() )
        readOnly |= !resAbc->subresourceWritable( subresource );
    }
  }
  setReadOnly( readOnly );

  load();
}
Beispiel #8
0
    void AddressbookHandler::fakeAddresseeListFromDevice( KABC::Addressee::List &mAddresseeList, QValueList<uint32_t> &idList )
    {
        for ( QValueList<uint32_t>::const_iterator it = idList.begin(); it != idList.end(); ++it ) {
            KABC::Addressee addr;

            QString konId = "RRA-ID-" + QString::number( *it, 16 ).rightJustify( 8, '0' );
            QString kdeId;

            if ((kdeId = mUidHelper->kdeId("SynCEAddressbook", konId, "---")) != "---") {
                addr.setUid(kdeId);
                mUidHelper->removeId("SynCEAddressbook", addr.uid());
                mAddresseeList.push_back( addr );
            }
            kdDebug(2120) << "Contact: " << konId << "  --  " << kdeId << endl;
        }
    }
Beispiel #9
0
void KOAttendeeEditor::insertAttendeeFromAddressee(const KABC::Addressee &a, const Attendee * at)
{
  bool myself = KOPrefs::instance()->thatIsMe( a.preferredEmail() );
  bool sameAsOrganizer = mOrganizerCombo &&
  KPIM::compareEmail( a.preferredEmail(), mOrganizerCombo->currentText(), false );
  KCal::Attendee::PartStat partStat = at? at->status() : KCal::Attendee::NeedsAction;
  bool rsvp = at? at->RSVP() : true;

  if ( myself && sameAsOrganizer ) {
    partStat = KCal::Attendee::Accepted;
    rsvp = false;
  }
  Attendee *newAt = new Attendee( a.realName(),
                               a.preferredEmail(),
                               !myself, partStat,
                               at ? at->role() : Attendee::ReqParticipant,
                               a.uid() );
  newAt->setRSVP( rsvp );
  insertAttendee( newAt, true );
}
Beispiel #10
0
QString KWMailMergeKABC::getValue( const QString &name, int record ) const
{
    kdDebug() << "KWMailMergeKABC::getValue(" << name << ", " << record << ")" << endl;
    if ( record < 0 )
        return name;

    // This doesn't ever happen, right? So why is it there? Dirk Schmidt
    if ( record == -1 && _iterator == _addressBook->end() )
        return "";

    //
    // Set the iterator to the asked Addressee.
    //
    bool uidAvailable = false;
    if ( record != -1 )
    {
        int counter = 0;

        for ( _UIDIterator = _exclusiveUIDs.begin(); _UIDIterator != _exclusiveUIDs.end()
                && counter < record; _UIDIterator++ )
        {
            counter++;
        }

        for ( _iterator = _addressBook->begin(); _iterator != _addressBook->end(); ++_iterator )
        {

            if( _iterator->uid() == *_UIDIterator )
            {
                uidAvailable = true;
                break;
            }
        }
    }

    if( !uidAvailable )
    {
        return ( i18n ( "KAddressbook entry '%1' not available." ).arg( *_UIDIterator ) );
    }


    KABC::Addressee addr = *_iterator;
    _iterator++; // Don't know why. Could be removed? Dirk Schmidt


    //
    // Return the asked variable.
    //
    if ( name == "KAddressbook identifier" )
        return addr.uid();
    if ( name == "Name" )
        return addr.name();
    if ( name == "Formatted name" )
        return addr.formattedName();
    if ( name == "Family names" )
        return addr.familyName();
    if ( name == "Given name" )
        return addr.givenName();
    if ( name == "Additional names" )
        return addr.additionalName();
    if ( name == "Honorific prefixes" )
        return addr.prefix();
    if ( name == "Honorific suffixes" )
        return addr.suffix();
    if ( name == "Nick name" )
        return addr.nickName();
    if ( name == "Birthday" )
        return KGlobal::locale()->formatDate( addr.birthday().date() );

    if ( name == "Home address: Street" )
    {
        KABC::Address a = addr.address( KABC::Address::Home );
        return a.street();
    }
    if ( name == "Home address: Locality" )
    {
        KABC::Address a = addr.address( KABC::Address::Home );
        return a.locality();
    }
    if ( name == "Home address: Region" )
    {
        KABC::Address a = addr.address( KABC::Address::Home );
        return a.region();
    }
    if ( name == "Home address: Postal code" )
    {
        KABC::Address a = addr.address( KABC::Address::Home );
        return a.postalCode();
    }
    if ( name == "Home address: Country" )
    {
        KABC::Address a = addr.address( KABC::Address::Home );
        return a.country();
    }
    if ( name == "Home address: Label" )
    {
        KABC::Address a = addr.address( KABC::Address::Home );
        return a.label();
    }

    if ( name == "Business address: Street" )
    {
        KABC::Address a = addr.address( KABC::Address::Work );
        return a.street();
    }
    if ( name == "Business address: Locality" )
    {
        KABC::Address a = addr.address( KABC::Address::Work );
        return a.locality();
    }
    if ( name == "Business address: Region" )
    {
        KABC::Address a = addr.address( KABC::Address::Work );
        return a.region();
    }
    if ( name == "Business address: Postal code" )
    {
        KABC::Address a = addr.address( KABC::Address::Work );
        return a.postalCode();
    }
    if ( name == "Business address: Country" )
    {
        KABC::Address a = addr.address( KABC::Address::Work );
        return a.country();
    }
    if ( name == "Business address: Label" )
    {
        KABC::Address a = addr.address( KABC::Address::Work );
        return a.label();
    }

    if ( name == "Prefered address: Street" )
    {
        KABC::Address a = addr.address( KABC::Address::Pref );
        return a.street();
    }

    if ( name == "Prefered address: Locality" )
    {
        KABC::Address a = addr.address( KABC::Address::Pref );
        return a.locality();
    }
    if ( name == "Prefered address: Region" )
    {
        KABC::Address a = addr.address( KABC::Address::Pref );
        return a.region();
    }
    if ( name == "Prefered address: Postal code" )
    {
        KABC::Address a = addr.address( KABC::Address::Pref );
        return a.postalCode();
    }
    if ( name == "Prefered address: Country" )
    {
        KABC::Address a = addr.address( KABC::Address::Pref );
        return a.country();
    }
    if ( name == "Prefered address: Label" )
    {
        KABC::Address a = addr.address( KABC::Address::Pref );
        return a.label();
    }

    if ( name == "Home phone" )
    {
        KABC::PhoneNumber phone = addr.phoneNumber( KABC::PhoneNumber::Home );
        return phone.number();
    }
    if ( name == "Business phone" )
    {
        KABC::PhoneNumber phone = addr.phoneNumber( KABC::PhoneNumber::Work );
        return phone.number();
    }
    if ( name == "Mobile phone" )
    {
        KABC::PhoneNumber phone = addr.phoneNumber( KABC::PhoneNumber::Cell );
        return phone.number();
    }
    if ( name == "Home fax" )
    {
        KABC::PhoneNumber phone = addr.phoneNumber( KABC::PhoneNumber::Home | KABC::PhoneNumber::Fax );
        return phone.number();
    }
    if ( name == "Business fax" )
    {
        KABC::PhoneNumber phone = addr.phoneNumber( KABC::PhoneNumber::Work | KABC::PhoneNumber::Fax );
        return phone.number();
    }
    if ( name == "Car phone" )
    {
        KABC::PhoneNumber phone = addr.phoneNumber( KABC::PhoneNumber::Car );
        return phone.number();
    }
    if ( name == "ISDN" )
    {
        KABC::PhoneNumber phone = addr.phoneNumber( KABC::PhoneNumber::Isdn );
        return phone.number();
    }
    if ( name == "Pager" )
    {
        KABC::PhoneNumber phone = addr.phoneNumber( KABC::PhoneNumber::Pager );
        return phone.number();
    }

    if ( name == "Email" )
        return addr.preferredEmail();
    if ( name == "Mailer" )
        return addr.mailer();
    if ( name == "Time zone" )
    {
        KABC::TimeZone zone = addr.timeZone();
        return QString::number( zone.offset() );
    }
    if ( name == "Geographic position" )
    {
        KABC::Geo geo = addr.geo();
        QString lat;
        QString longi;
        if(  geo.latitude()<0 )
            lat = QString( i18n("%1 South") ).arg( -geo.latitude() );
        else
            lat = QString( i18n("%1 North") ).arg( geo.latitude() );

        if(  geo.longitude()<0 )
            // There is something going wrong, because "W" is replaced by "q ".
            // Needs fix.
            longi = QString( i18n("%1 West") ).arg( -geo.longitude() );
        else
            longi = QString( i18n("%1 East") ).arg( geo.longitude() );

        return i18n( "Geographic coordinates", "%1, %2" ).arg ( lat, longi );
    }

    if ( name == "Title" )
        return addr.title();
    if ( name == "Role" )
        return addr.role();
    if ( name == "Organization" )
        return addr.organization();
    if ( name == "Note" )
        return addr.note();
    if ( name == "productId" )
        return addr.productId();
    if ( name == "Revision" )
        return KGlobal::locale()->formatDate( addr.revision().date() );
    if ( name == "sortString" )
        return addr.sortString();
    if ( name == "URL" )
        return addr.url().url();
    if ( name == "Secrecy" )
    {
        KABC::Secrecy secrecy = addr.secrecy();
        return KABC::Secrecy::typeLabel( secrecy.type() );
    }

    return ( i18n("Unkown mail merge variable: %1").arg ( name ) ) ;
}
Beispiel #11
0
QString Contact::toXml(const KABC::Addressee &addr)
{
    /**
     * Handle distribution lists.
     */
    if(KPIM::DistributionList::isDistributionList(addr))
    {
        if(s_distListMap)
            return (*s_distListMap)[ addr.uid() ];
        else
            return QString();
    }

    /**
     * Handle normal contacts.
     */
    QString xml;
    xml += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
    xml += "<contact>\n";

    xml += "<direct_ref>" + addr.uid() + "</direct_ref>\n";
    xml += "<sensitivity>" + custom("sensitivity", addr, "0") + "</sensitivity>\n";

    xml += "<message_class>IPM.Contact</message_class>\n";
    xml += "<is_recurring>" + custom("is_recurring", addr, "false") + "</is_recurring>\n";
    xml += "<reminder_set>" + custom("reminder_set", addr, "false") + "</reminder_set>\n";
    xml += "<send_rich_info>" + custom("send_rich_info", addr, "false") + "</send_rich_info>\n";
    xml += "<subject>" + addr.formattedName() + "</subject>\n";
    xml += "<last_modification_time>" + addr.revision().toString(Qt::ISODate) + "</last_modification_time>\n";

    xml += "<display_name_prefix>" + addr.prefix() + "</display_name_prefix>\n";
    xml += "<first_name>" + addr.givenName() + "</first_name>\n";
    xml += "<middle_name>" + addr.additionalName() + "</middle_name>\n";
    xml += "<last_name>" + addr.familyName() + "</last_name>\n";
    xml += "<suffix>" + addr.suffix() + "</suffix>\n";
    xml += "<display_name>" + addr.assembledName() + "</display_name>\n";
    xml += "<file_as>" + addr.formattedName() + "</file_as>\n";
    xml += "<nickname>" + addr.nickName() + "</nickname>\n";

    xml += "<web_page_address>" + addr.url().url() + "</web_page_address>\n";
    xml += "<company_name>" + addr.organization() + "</company_name>\n";
    xml += "<job_title>" + addr.title() + "</job_title>\n";

    QStringList emails = addr.emails();
    for(uint i = 0; i < 3; ++i)
    {
        QString type, address, comment, display;

        if(i < emails.count())
        {
            type = "SMTP";
            address = emails[ i ];

            /**
             * If the contact was created by kontact use the email address as
             * display name and the formatted name as comment, otherwise we use
             * the values from the server.
             */
            if(custom("comes_from_scalix", addr) != "true")
            {
                comment = addr.formattedName();
                display = emails[ i ];
            }
            else
            {
                comment = custom(QString("email%1_address_with_comment").arg(i + 1), addr);
                display = custom(QString("email%1_display_name").arg(i + 1), addr);
            }
        }

        xml += QString("<email%1_address_type>").arg(i + 1) + type +
               QString("</email%1_address_type>").arg(i + 1) + "\n";
        xml += QString("<email%1_address>").arg(i + 1) + address +
               QString("</email%1_address>").arg(i + 1) + "\n";
        xml += QString("<email%1_address_with_comment>").arg(i + 1) + comment +
               QString("</email%1_address_with_comment>").arg(i + 1) + "\n";
        xml += QString("<email%1_display_name>").arg(i + 1) + display +
               QString("</email%1_display_name>").arg(i + 1) + "\n";
    }

    KABC::PhoneNumber phone = addr.phoneNumber(KABC::PhoneNumber::Home);
    xml += "<home_phone_number>" + phone.number() + "</home_phone_number>\n";

    phone = addr.phoneNumber(KABC::PhoneNumber::Work);
    xml += "<work_phone_number>" + phone.number() + "</work_phone_number>\n";

    phone = addr.phoneNumber(KABC::PhoneNumber::Work | KABC::PhoneNumber::Fax);
    xml += "<work_fax_number>" + phone.number() + "</work_fax_number>\n";

    phone = addr.phoneNumber(KABC::PhoneNumber::Cell);
    xml += "<mobile_phone_number>" + phone.number() + "</mobile_phone_number>\n";

    const KABC::Address workAddress = addr.address(KABC::Address::Work);
    xml += "<work_address_street>" + workAddress.street() + "</work_address_street>\n";
    xml += "<work_address_zip>" + workAddress.postalCode() + "</work_address_zip>\n";
    xml += "<work_address_city>" + workAddress.locality() + "</work_address_city>\n";
    xml += "<work_address_state>" + workAddress.region() + "</work_address_state>\n";
    xml += "<work_address_country>" + workAddress.country() + "</work_address_country>\n";

    const KABC::Address homeAddress = addr.address(KABC::Address::Home);
    xml += "<home_address_street>" + homeAddress.street() + "</home_address_street>\n";
    xml += "<home_address_zip>" + homeAddress.postalCode() + "</home_address_zip>\n";
    xml += "<home_address_city>" + homeAddress.locality() + "</home_address_city>\n";
    xml += "<home_address_state>" + homeAddress.region() + "</home_address_state>\n";
    xml += "<home_address_country>" + homeAddress.country() + "</home_address_country>\n";

    const KABC::Address otherAddress = addr.address(KABC::Address::Dom);
    xml += "<other_address_street>" + otherAddress.street() + "</other_address_street>\n";
    xml += "<other_address_zip>" + otherAddress.postalCode() + "</other_address_zip>\n";
    xml += "<other_address_city>" + otherAddress.locality() + "</other_address_city>\n";
    xml += "<other_address_state>" + otherAddress.region() + "</other_address_state>\n";
    xml += "<other_address_country>" + otherAddress.country() + "</other_address_country>\n";

    if(homeAddress.type() & KABC::Address::Pref)
        xml += "<selected_mailing_address>1</selected_mailing_address>\n";
    else if(workAddress.type() & KABC::Address::Pref)
        xml += "<selected_mailing_address>2</selected_mailing_address>\n";
    else if(otherAddress.type() & KABC::Address::Pref)
        xml += "<selected_mailing_address>3</selected_mailing_address>\n";

    xml += "<im_address>" + addr.custom("KADDRESSBOOK", "X-IMAddress") + "</im_address>\n";
    xml += "<manager>" + addr.custom("KADDRESSBOOK", "X-ManagersName") + "</manager>\n";
    xml += "<department>" + addr.custom("KADDRESSBOOK", "X-Department") + "</department>\n";
    xml += "<assistant>" + addr.custom("KADDRESSBOOK", "X-AssistantsName") + "</assistant>\n";
    xml += "<profession>" + addr.custom("KADDRESSBOOK", "X-Profession") + "</profession>\n";
    xml += "<office_location>" + addr.custom("KADDRESSBOOK", "X-Office") + "</office_location>\n";
    xml += "<spouse>" + addr.custom("KADDRESSBOOK", "X-SpousesName") + "</spouse>\n";

    xml += "<bday>" + addr.birthday().toString(Qt::ISODate) + "</bday>\n";
    xml += "<anniversary>" + addr.custom("KADDRESSBOOK", "X-Anniversary") + "</anniversary>\n";

    xml += "<mapi_charset>" + custom("mapi_charset", addr, "UTF8") + "</mapi_charset>";

    xml += "</contact>\n";

    return xml;
}
Beispiel #12
0
/**
 * Perform an addressbook command (edit contact, create new contact,
 * change/delete association.)
 * @param id                The command id.  @ref CommandIDs.
 *
 * The operation is performed on the nickname at the currently-selected item in
 * the nicklistview.
 *
 * Also refreshes the nicklistview display to reflect the new addressbook state
 * for the nick.
 */
void NicksOnline::doCommand(int id)
{
    if(id < 0)
    {
        return;
    }

    QString serverName;
    QString nickname;
    QListViewItem* item = m_nickListView->selectedItem();

    if(!getItemServerAndNick(item, serverName, nickname))
    {
        return;
    }

    // Get the server object corresponding to the server name.
    Server* server = KonversationApplication::instance()->getConnectionManager()->getServerByName(serverName);

    if (!server) return;

    // Get NickInfo object corresponding to the nickname.
    NickInfoPtr nickInfo = server->getNickInfo(nickname);
    // Get addressbook entry for the nick.
    KABC::Addressee addressee;

    if(nickInfo)
    {
        addressee = nickInfo->getAddressee();
    }
    else
    {
        addressee = server->getOfflineNickAddressee(nickname);
    }

    switch(id)
    {
    case ciSendEmail:
        Konversation::Addressbook::self()->sendEmail(addressee);
        return;                               //no need to refresh item
    case ciAddressbookEdit:
        Konversation::Addressbook::self()->editAddressee(addressee.uid());
        return;                               //no need to refresh item - nickinfo changed will be called anyway.
    case ciAddressbookChange:
        if(nickInfo)
        {
            nickInfo->showLinkAddressbookUI();
        }
        else
        {
            LinkAddressbookUI *linkaddressbookui = new LinkAddressbookUI(server->getViewContainer()->getWindow(), NULL, nickname, server->getServerName(), server->getDisplayName(), addressee.realName());
            linkaddressbookui->show();
        }
        break;
    case ciAddressbookNew:
    case ciAddressbookDelete:
    {
        Konversation::Addressbook *addressbook = Konversation::Addressbook::self();

        if(addressbook && addressbook->getAndCheckTicket())
        {
            if(id == ciAddressbookDelete)
            {
                if (addressee.isEmpty())
                {
                    return;
                }

                addressbook->unassociateNick(addressee, nickname, server->getServerName(), server->getDisplayName());
            }
            else
            {
                addressee.setGivenName(nickname);
                addressee.setNickName(nickname);
                addressbook->associateNickAndUnassociateFromEveryoneElse(addressee, nickname, server->getServerName(), server->getDisplayName());
            }
            if(addressbook->saveTicket())
            {
                //saveTicket will refresh the addressees for us.
                if(id == ciAddressbookNew)
                {
                    Konversation::Addressbook::self()->editAddressee(addressee.uid());
                }
            }
        }
        break;
    }
    case ciJoinChannel:
    {
        // only join real channels
        if (static_cast<NicksOnlineItem*>(m_nickListView->selectedItem())->type() == NicksOnlineItem::ChannelItem)
        {
            QString contactChannel = m_nickListView->selectedItem()->text(nlvcChannel);
            server->queue( "JOIN "+contactChannel );
        }
        break;
    }
    case ciWhois:
        server->queue("WHOIS "+nickname);
        return;
    case ciOpenQuery:
        NickInfoPtr nickInfo = server->obtainNickInfo(nickname);
        class Query* query = server->addQuery(nickInfo, true /*we initiated*/);
        emit showView(query);
        return;
    }

    refreshItem(item);
}
static QString getId(const KABC::Addressee &addressee)
{
    return addressee.uid();
}