Source Code (Use browser search to find items of interest.)

Class Index

kab'makeEntryFromKab1Section() (./kdeutils/kab/kab_kab1importer.cc:90)

bool makeEntryFromKab1Section(Section* section, AddressBook::Entry& entry)
{
  bool GUARD; GUARD=true;
  kDebugInfo(GUARD, 0, "makeEntryFromKab1Section: called.");
  // -----
  Kab1Entry kab1;
  KeyValueMap* map;
  int count;
  AddressBook::Entry dummy;
  AddressBook::Entry::Address address;
  AddressBook::Entry::Address addressDummy;
  // ----- clear up the old entry: (change on July 19 1998):
  entry=dummy; // dummy is always completely empty
  // -----
  map=section->getKeys();
  // the first 6 keys are required, something went wrong if
  // these are not set:
  if(!map->get("name", kab1.name)
     || !map->get("firstname", kab1.firstname)
     || !map->get("email", kab1.email)
     || !map->get("telephone", kab1.telephone)
     || !map->get("town", kab1.town)
     || !map->get("address", kab1.address))
    {
      return false;
    } else { // the entry should be OK
      map->get("additionalName", kab1.additionalName);
      map->get("namePrefix", kab1.namePrefix);
      map->get("fn", kab1.fn);
      map->get("comment", kab1.comment);
      map->get("org", kab1.org);
      map->get("orgUnit", kab1.orgUnit);
      map->get("orgSubUnit", kab1.orgSubUnit);
      map->get("title", kab1.title);
      map->get("role", kab1.role);
      map->get("deliveryLabel", kab1.deliveryLabel);
      map->get("email2", kab1.email2);
      map->get("email3", kab1.email3);
      map->get("fax", kab1.fax);
      map->get("modem", kab1.modem);
      map->get("URL", kab1.URL);
      map->get("zip", kab1.zip);
      map->get("state", kab1.state);
      map->get("country", kab1.country);
      if(map->get("talk", kab1.talk))
	{
	  kDebugInfo(GUARD, 0, "AddressBook::makeEntryFromSection: "
	     "found %stalk address(es) (%i).",
	     kab1.talk.isEmpty() ? "no " : "",
	     kab1.talk.count());
	}
      if(map->get("keywords", kab1.keywords))
	{
	  kDebugInfo(GUARD, 0, "AddressBook::makeEntryFromSection: "
	     "found %skeyword(s) (%i).",
	     kab1.keywords.isEmpty() ? "no " : "",
	     kab1.keywords.count());
	}
      if(map->get("emails", kab1.emails))
	{
	  kDebugInfo(GUARD, 0, "AddressBook::makeEntryFromSection: "
	     "found %semail address(es) (%i).",
	     kab1.emails.isEmpty() ? "no " : "",
	     kab1.emails.count());
	}
      if(map->get("birthday", kab1.birthday))
	{
	  kDebugInfo(GUARD, 0, "AddressBook::makeEntryFromSection: "
	     "found the birthday.");
	}
    }
  // ----- first copy the attributes of the person:
  entry.lastname=kab1.name;
  entry.middlename=kab1.additionalName;
  entry.firstname=kab1.firstname;
  entry.nameprefix=kab1.namePrefix;
  entry.fn=kab1.fn;
  entry.comment=kab1.comment;
  entry.title=kab1.title;
  entry.birthday=kab1.birthday;
  for(count=0; (unsigned)count<kab1.emails.count(); ++count)
    {
      entry.emails.append(kab1.emails.at(count));
    }
  if(!kab1.email.isEmpty()) entry.emails.append(kab1.email);
  if(!kab1.email2.isEmpty()) entry.emails.append(kab1.email2);
  if(!kab1.email3.isEmpty()) entry.emails.append(kab1.email3);
  if(!kab1.URL.isEmpty()) entry.URLs.append(kab1.URL);
  for(count=0; (unsigned)count<kab1.talk.count(); ++count)
    {
      entry.talk.append(kab1.talk.at(count));
    }
  if(!kab1.telephone.isEmpty())
    {
      entry.telephone.append(AddressBook::phoneType(AddressBook::Fixed));
      entry.telephone.append(kab1.telephone);
    }
  if(!kab1.fax.isEmpty())
    {
      entry.telephone.append(AddressBook::phoneType(AddressBook::Fax));
      entry.telephone.append(kab1.fax);
    }
  if(!kab1.modem.isEmpty())
    {
      entry.telephone.append(AddressBook::phoneType(AddressBook::Modem));
      entry.telephone.append(kab1.modem);
    }
  // ----- then copy the attributes of the (one) address of this person:
  address=addressDummy; // clean it up
  address.headline=i18n("Home");
  address.org=kab1.org;
  address.orgUnit=kab1.orgUnit;
  address.orgSubUnit=kab1.orgSubUnit;
  // address.role=kab1.role;
  address.address=kab1.address;
  address.town=kab1.town;
  address.zip=kab1.zip;
  address.state=kab1.state;
  address.country=kab1.country;
  entry.addresses.push_back(address);
  /* The following values where never implemented in kab 1:
     QPixmap logo;
     QCString sound; // base64 coded wav - file
     QCString agent; // contains a complete vCard possibly?
     QStrList keywords; // list of form-free keywords
     QCString deliveryLabel;
  */
  // ----- done:
  kDebugInfo(GUARD, 0, "makeEntryFromKab1Section: done.");
  return true;
}


kab'main() (./kdeutils/kab/kab_main.cc:42)

int main(int argc, char** argv)
{
  KAboutData aboutData( "kab", I18N_NOOP("KAB"),
    version, description, KAboutData::License_GPL,
    "(c) Mirko Sucker");
  //  aboutData.addAuthor("",0, "");
  KCmdLineArgs::init( argc, argv, &aboutData );

  KApplication app;
  TopLevelWidget widget;
  KMessageBox::information
    (0,
     i18n("Version 2 of the KDE address book is not compatible "
	  "with the previous one.\n"
	  "To protect your address database, another file will "
	  "be used.\n"
	  "Run \"File->Import->KDE 1 addressbook\" to use your old\n"
	  "database with the new version."),
     i18n("new format"),
     "kab_new_version_incompatibility");
  app.setMainWidget(&widget);
  widget.resize(480, 320);
  widget.show();
  return app.exec();
}