[libcontacts] Move import logic to libcontacts for sharing

Should be used by the batch importer and the GUI importer.