Exemplo n.º 1
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;
}
Exemplo n.º 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;
}
Exemplo n.º 3
0
void VCardXXPort::addKey( KABC::Addressee &addr, KABC::Key::Types type )
{
  QString fingerprint = addr.custom( "KADDRESSBOOK",
                                     (type == KABC::Key::PGP ? "OPENPGPFP" : "SMIMEFP") );
  if ( fingerprint.isEmpty() )
    return;

  GpgME::Context * context = GpgME::Context::createForProtocol( GpgME::Context::OpenPGP );
  if ( !context ) {
    kdError() << "No context available" << endl;
    return;
  }

  context->setArmor( false );
  context->setTextMode( false );

  QGpgME::QByteArrayDataProvider dataProvider;
  GpgME::Data dataObj( &dataProvider );
  GpgME::Error error = context->exportPublicKeys( fingerprint.latin1(), dataObj );
  delete context;

  if ( error ) {
    kdError() << error.asString() << endl;
    return;
  }

  KABC::Key key;
  key.setType( type );
  key.setBinaryData( dataProvider.data() );

  addr.insertKey( key );
}
Exemplo n.º 4
0
static QString custom(const QString &name, const KABC::Addressee &addr, const QString &defaultValue = QString())
{
    const QString value = addr.custom("Scalix", name);
    if(value.isEmpty())
        return defaultValue;
    else
        return value;
}
Exemplo n.º 5
0
static QString getOpportunityRoleFields(const KABC::Addressee &addressee)
{
    return addressee.custom("FATCRM", "X-OpportunityRoleFields");
}
Exemplo n.º 6
0
static QString getSalutation(const KABC::Addressee &addressee)
{
    return addressee.custom("FATCRM", "X-Salutation");
}
Exemplo n.º 7
0
static QString getCreatedById(const KABC::Addressee &addressee)
{
    return addressee.custom("FATCRM", "X-CreatedById");
}
Exemplo n.º 8
0
static QString getModifiedUserId(const KABC::Addressee &addressee)
{
    return addressee.custom("FATCRM", "X-ModifiedUserId");
}
Exemplo n.º 9
0
static QString getDoNotCall(const KABC::Addressee &addressee)
{
    return addressee.custom("FATCRM", "X-DoNotCall");
}
Exemplo n.º 10
0
static QString getAssignedUserId(const KABC::Addressee &addressee)
{
    return addressee.custom("FATCRM", "X-AssignedUserId");
}
Exemplo n.º 11
0
static QString getCampaignId(const KABC::Addressee &addressee)
{
    return addressee.custom("FATCRM", "X-CampaignId");
}
Exemplo n.º 12
0
static QString getLeadSourceName(const KABC::Addressee &addressee)
{
    return addressee.custom("FATCRM", "X-LeadSourceName");
}
Exemplo n.º 13
0
static QString getAssistantPhone(const KABC::Addressee &addressee)
{
    return addressee.custom("FATCRM", "X-AssistantsPhone");
}
Exemplo n.º 14
0
static QString getAssistantName(const KABC::Addressee &addressee)
{
    return addressee.custom("KADDRESSBOOK", "X-AssistantsName");
}
Exemplo n.º 15
0
static QString getMAcceptStatusFields(const KABC::Addressee &addressee)
{
    return addressee.custom("FATCRM", "X-MacceptStatusFields");
}
Exemplo n.º 16
0
static QString getDeleted(const KABC::Addressee &addressee)
{
    return addressee.custom("FATCRM", "X-Deleted");
}
Exemplo n.º 17
0
static QString getReportsToUserId(const KABC::Addressee &addressee)
{
    return addressee.custom("FATCRM", "X-ReportsToUserId");
}
Exemplo n.º 18
0
static QString getAccountId(const KABC::Addressee &addressee)
{
    return addressee.custom("FATCRM", "X-AccountId");
}
Exemplo n.º 19
0
static QString getModifiedByName(const KABC::Addressee &addressee)
{
    return addressee.custom("FATCRM", "X-ModifiedByName");
}
Exemplo n.º 20
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;
}
Exemplo n.º 21
0
static QString getDateModified(const KABC::Addressee &addressee)
{
    return addressee.custom("FATCRM", "X-DateModified");
}