Permalink
Browse files

Work on buildLDIFEntry for use by the to-be-written r/w sync code

  • Loading branch information...
1 parent 7f178f3 commit deffa893efb3d414f0cde1d5af76b04d55558ebc @codemage codemage committed Sep 8, 2010
Showing with 12 additions and 1 deletion.
  1. +12 −1 src/info/codethink/ldapsync/LDAPSyncMapping.java
@@ -25,6 +25,7 @@
import android.os.RemoteException;
import android.provider.ContactsContract.CommonDataKinds;
import android.provider.ContactsContract.Data;
+import android.provider.ContactsContract.RawContacts;
import android.sax.Element;
import android.sax.RootElement;
import android.sax.StartElementListener;
@@ -288,8 +289,18 @@ public void buildData(ArrayList<ContentProviderOperation> ops, SearchResultEntry
public Entry buildLDIFEntry(ContentProviderClient provider, long rawContactId)
{
try {
- String dn = ""; // TODO: get DN
+ Cursor idCursor = provider.query(Utils.syncURI(RawContacts.CONTENT_URI),
+ new String[] { RawContacts.SOURCE_ID },
+ RawContacts._ID + " = " + rawContactId,
+ null, null);
+ if (!idCursor.moveToFirst()) {
+ // contact not found
+ return null;
+ }
+ String dn = idCursor.getString(0);
Entry result = new Entry(dn);
+
+ // translate mapped attributes back to LDAP
for (RowBuilder row: mRows) {
row.buildLDIFEntry(provider, rawContactId, result);
}

0 comments on commit deffa89

Please sign in to comment.