storoj / libimobiledevice-win32

win32 port of libimobiledevice (http://libimobiledevice.org)
64 stars 61 forks source link

Enanle to use Mobilesync #18

Open vipinbeni opened 9 years ago

vipinbeni commented 9 years ago

Hi Sir,

I am using this library in my vc++ application for synchronization of contact and i want to list all contact from devices to my application on windows systems . i am using following code

int main(void) { int count, i, err; lockdownd_service_descriptor_t port = NULL; usbmuxd_device_info_t _devices; idevice_t idevice; idevice_connection_t connection; lockdownd_client_t ldclient; mobilesync_client_t sync_client = NULL; char host_id; err = usbmuxd_get_device_list(&devices); if(err != 1) { printf("usbmuxd_get_device_list error %d, exiting.\n", err); closeall(NULL, NULL, NULL, &devices); return 0; } for(count = 0; devices[count].handle > 0; count++); / First device only _/ err = idevice_new(&idevice, devices[0].udid); if(err != 0) { printf("idevice_new error %d, exiting.\n", err); close_all(NULL, NULL, idevice, &devices); return 0; } err = lockdownd_client_new_with_handshake(idevice, &ldclient, "mobilesync"); if(err != 0) { printf("lockdownd_client_new_with_handshake %d, exiting.\n", err); close_all(NULL, ldclient, idevice, &devices); return 0; } userpref_get_host_id(&host_id); err = lockdownd_start_service(ldclient, "com.apple.mobilesync", &port); if(err != 0) { printf("lockdownd_start_service %d, exiting.\n", err); close_all(NULL, ldclient, idevice, &devices); return 0; } err = mobilesync_client_new(idevice, port, &sync_client); if(err != 0) { printf("mobilesync_client_new %d, exiting.\n", err); close_all(sync_client, ldclient, idevice, &devices); return 0; } plist_t data = NULL; plist_t msg = NULL; plist_t responset = NULL; char * response; / Initial handshake _/ msg = plist_new_array(); plist_array_append_item(msg, plist_new_string("SDMessageSyncDataClassWithDevice")); plist_array_append_item(msg, plist_new_string("com.apple.Contacts")); plist_array_append_item(msg, plist_new_string("---")); plist_array_append_item(msg, plist_newstring("2013-07-29 22-34-00 00")); / plist_array_append_item(msg, plist_newstring("SDSyncTypeSlow")); / plist_array_append_item(msg, plist_new_uint(106)); plist_array_append_item(msg, plist_new_string("_EmptyParameterString_")); err = mobilesync_send(sync_client, msg); plist_free(msg); msg = NULL; if(err != 0) { printf("mobilesync_send %d, exiting.\n", err); close_all(sync_client, ldclient, idevice, &devices); return 0; } plist_free(msg); msg = NULL; err = mobilesync_receive(sync_client, &msg); if(err != 0) { printf("mobilesync_receive %d, exiting.\n", err); close_all(sync_client, ldclient, idevice, &devices); return 0; } response_t = plist_array_get_item(msg, 0); plist_get_string_val(response_t, &response); if(strcmp(response, "SDMessageSyncDataClassWithComputer") != 0) { close_all(sync_client, ldclient, idevice, &devices); return 0; } msg = plist_new_array(); plist_array_append_item(msg, plist_new_string("SDMessageGetAllRecordsFromDevice")); plist_array_append_item(msg, plist_new_string("com.apple.Contacts")); err = mobilesync_send(sync_client, msg); plist_free(msg); msg = NULL; if(err != 0) { printf("mobilesync_send %d, exiting.\n", err); close_all(sync_client, ldclient, idevice, &devices); return 0;; } char * xml = NULL; unsigned int xml_size; err = mobilesync_receive(sync_client, &msg); if(err != 0) { printf("mobilesync_receive %d, exiting.\n", err); close_all(syncclient, ldclient, idevice, &devices); return 0; } / both checks are voluntary _/ if(plist_getparent(msg) == NULL) / check whether it's a root node _/ if(plist_get_node_type(msg) == PLISTARRAY) / check whether root node is an array / plist_to_xml(msg, &xml, &xml_size); printf("%s\n", xml); close_all(sync_client, ldclient, idevice, &devices); return 0; }

But am not getting my contact in xml file .

instead when i am using com.apple.Bookmarks its work fine.

please correct me where i am going wrong please help as i am working on it from many days help me out pls.

Thanks

airwolf2026 commented 9 years ago

try close idevice icloud sync contact first.

vipinbeni commented 9 years ago

Thanks airwolf2026 for your Quick reply its work now , thanks a lot

but i have a problem now got information like first name, last name ,company name etc correct but not information like Phone number, email ,Street Address,URL ,Date etc not coming in this xml dict.

i got this format out put

< ?xml version="1.0" encoding="UTF-8"? > < !DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/ DTDs/PropertyList-1.0.dtd" > < plist version="1.0" > < dict > < key >last name< /key > < string >Ll222< /string > < key >company name< /key > < string>Ccc222< /string > < key >com.apple.syncservices.RecordEntityName< /key > < string >com.apple.contacts.Contact< /string > < key >first name< /key > < string >BbB222< /string > < key >display as company< /key > < string >person</ string > < /dict > < /plist >

< ?xml version="1.0" encoding="UTF-8"? > < !DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/ DTDs/PropertyList-1.0.dtd" > < plist version="1.0" > < dict > < key >display as company< /key > < string>person< /string > < key >company name< /key > < string>Information Limited < key >notes< /key > < string >


Details Updated 4/10/2012:

Business Address City: new delhi

Business Address State: delhi

Business Address Country/Region: India< /string >
< key >com.apple.syncservices.RecordEntityName< /key >
< string >com.apple.contacts.Contact< /string>
< key >last name< /key >
< string >Talwar< /string >
< key >first name< /key >
< string >Ankur< /string >
< key >department< /key >
< string >Technical Support< /string >

</ dict > </ plist>

please help me how i got all information where to change made in my code please help me

Thanks

airwolf2026 commented 9 years ago

you should read message until null.like: while(msg!=null) { mobilesync_receive(sync_client, &msg); } idevice send contact infos in diffrent plist.

vipinbeni commented 9 years ago

int main(void) { int count, i, err; lockdownd_service_descriptor_t port = NULL; usbmuxd_device_info_t devices; idevice_t idevice; idevice_connection_t connection; lockdownd_client_t ldclient; mobilesync_client_t sync_client = NULL; char _host_id; err = usbmuxd_get_device_list(&devices); if(err != 1) { printf("usbmuxd_get_device_list error %d, exiting.\n", err); close_all(NULL, NULL, NULL, &devices); return 0; } for(count = 0; devices[count].handle > 0; count++); / First device only / err = idevice_new(&idevice, devices[0].udid); if(err != 0) { printf("idevice_new error %d, exiting.\n", err); close_all(NULL, NULL, idevice, &devices); return 0; } err = lockdownd_client_new_with_handshake(idevice, &ldclient, "mobilesync"); if(err != 0) { printf("lockdownd_client_new_with_handshake %d, exiting.\n", err); close_all(NULL, ldclient, idevice, &devices); return 0; } userpref_get_host_id(&host_id); err = lockdownd_start_service(ldclient, "com.apple.mobilesync", &port); if(err != 0) { printf("lockdownd_start_service %d, exiting.\n", err); close_all(NULL, ldclient, idevice, &devices); return 0; } err = mobilesync_client_new(idevice, port, &sync_client); if(err != 0) { printf("mobilesync_client_new %d, exiting.\n", err); close_all(sync_client, ldclient, idevice, &devices); return 0; } plist_t data = NULL; plist_t msg = NULL; plist_t response_t = NULL; char * response; / Initial handshake / msg = plist_new_array(); plist_array_append_item(msg, plist_new_string("SDMessageSyncDataClassWithDevice")); plist_array_append_item(msg, plist_new_string("com.apple.Contacts")); plist_array_append_item(msg, plist_new_string("---")); plist_array_append_item(msg, plist_new_string("2013-07-29 22-34-00 00")); / plist_array_append_item(msg, plist_new_string("SDSyncTypeSlow")); / plist_array_append_item(msg, plist_new_uint(106)); plist_array_append_item(msg, plist_new_string("EmptyParameterString")); err = mobilesync_send(sync_client, msg); plist_free(msg); msg = NULL; if(err != 0) { printf("mobilesync_send %d, exiting.\n", err); close_all(sync_client, ldclient, idevice, &devices); return 0; } plist_free(msg); msg = NULL; err = mobilesync_receive(sync_client, &msg); if(err != 0) { printf("mobilesync_receive %d, exiting.\n", err); close_all(sync_client, ldclient, idevice, &devices); return 0; } response_t = plist_array_get_item(msg, 0); plist_get_string_val(response_t, &response); if(strcmp(response, "SDMessageSyncDataClassWithComputer") != 0) { close_all(sync_client, ldclient, idevice, &devices); return 0; } msg = plist_new_array(); plist_array_append_item(msg, plist_new_string("SDMessageGetAllRecordsFromDevice")); plist_array_append_item(msg, plist_new_string("com.apple.Contacts")); err = mobilesync_send(sync_client, msg); plist_free(msg); msg = NULL; if(err != 0) { printf("mobilesync_send %d, exiting.\n", err); close_all(sync_client, ldclient, idevice, &devices); return 0;; } char * xml = NULL; unsigned int xml_size; err = mobilesync_receive(client, &msg); if(plist_getparent(msg) == NULL) / check whether it's a root node _/ if(plist_get_node_type(msg) == PLISTARRAY) / check whether root node is an array */ plist_to_xml(msg, &xml, &xml_size); printf("%s\n", xml);

while(msg!=NULL)
{
    err = mobilesync_receive(client, &msg);
    if(plist_get_parent(msg) == NULL)                       /* check whether it's a root node       */
        if(plist_get_node_type(msg) == PLIST_ARRAY)     /* check whether root node is an array  */
            plist_to_xml(msg, &xml, &xml_size);
    printf("%s\n", xml);
}

close_all(sync_client, ldclient, idevice, &devices); return 0; }

i use this but still no phone no come in plist dist while in iphone all have no and email and url etc

while(msg!=NULL) { err = mobilesync_receive(client, &msg);

}

value return -1 ; second time execution

pls help it only show com.apple.contacts.Contacs not com.apple.contacs.Phone Number etc data . 1 2

vipinbeni commented 9 years ago

Please help me how can i get Phone Number email etc

airwolf2026 commented 9 years ago

sorry,you should test msg[3] is lastrecord

vipinbeni commented 9 years ago

Dear Sir . Could you please give some brief in detail

where i am wrong and where to change .

vipinbeni commented 9 years ago

Dear Sir . Could you please give some brief in detail

where i am wrong

On Tue, Sep 16, 2014 at 9:05 AM, airwolf2026 notifications@github.com wrote:

sorry,you should test msg[3] is lastrecord

— Reply to this email directly or view it on GitHub https://github.com/storoj/libimobiledevice-win32/issues/18#issuecomment-55690912 .

Thanks Vipin Kumar Beniwal

airwolf2026 commented 9 years ago

sniff the usb message use Bus Hound <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

SDMessageProcessChanges com.apple.Contacts 3/6/8 com.apple.syncservices.RecordEntityName com.apple.contacts.Phone Number contact 6 type mobile value +86123567 SyncDeviceLinkAllRecordsOfPulledEntityTypeSentKey SyncDeviceLinkEntityNamesKey com.apple.contacts.Phone Number
vipinbeni commented 9 years ago

Hi Sir,

i add following to my code array = plist_new_array(); plist_array_append_item(array, plist_new_string("SDMessageProcessChanges")); plist_array_append_item(array, plist_new_string("com.apple.Contacts")); plist_array_append_item(array, plist_new_dict()); plist_array_append_item(array, plist_new_bool(0)); plist_t dict1 = plist_new_dict(); plist_array_append_item(array, dict1); plist_t array22 = plist_new_array(); plist_dict_insert_item(dict1, "SyncDeviceLinkEntityNamesKey", array22); plist_array_append_item(array22, plist_new_string("com.apple.contacts.Phone Number")); plist_array_append_item(array22, plist_new_string("com.apple.contacts.Group")); plist_dict_insert_item(dict1, "SyncDeviceLinkAllRecordsOfPulledEntityTypeSentKey", plist_new_bool(0));

  ret = mobilesync_send(client, array);
  plist_free(array);
  array = NULL;

  ret = mobilesync_receive(client, &array);
   if(plist_get_parent(array) == NULL)                       /* check whether it's a root node       */
        if(plist_get_node_type(array) == PLIST_ARRAY)     /* check whether root node is an array  */
                plist_to_xml(array, &xml, &xml_size);
printf("%s\n", xml);

but out put is still same .

< key >15< /key > < dict > < key >com.apple.syncservices.RecordEntityName < /key > < string >com.apple.contacts.Contact< /string > < key >first name< /key > < string >Ratina < key >display as company< /key > < string >person< /string > < /dict > < key >3 < dict > < key >first name< /key > < string >Zulfiqar< /string > < key >company name< /key > < string >Ftftft< /string > < key >last name< /key > < string >Ali< /string > < key >notes< /key > < string >My notes vvvvvvvvvvvvv< /string > < key >birthday< /key > < date/ > < key >display as company< /key > < string >person< /string > < key >com.apple.syncservices.RecordEntityName< /key > < string >com.apple.contacts.Contact< /string >

Dear Sir please tell me how you get these value :

com.apple.syncservices.RecordEntityName com.apple.contacts.Phone Number contact

6

type mobile value +86123567

airwolf2026 commented 9 years ago

plist_dict_insert_item(dict1, "SyncDeviceLinkEntityNamesKey", array22); plist_array_append_item(array22, plist_new_string("com.apple.contacts.Phone Number")); plist_array_append_item(array22, plist_new_string("com.apple.contacts.Group")); plist_dict_insert_item(dict1, "SyncDeviceLinkAllRecordsOfPulledEntityTypeSentKey", >plist_new_bool(0));

don't add these ,these are idevice send to computer

vipinbeni commented 9 years ago

then how can i get phone no my all code is shown to you sir where i am wrong please tell me where i have to change or add something pls help .

airwolf2026 commented 9 years ago

i know why you can't get more info while(msg!=NULL) { err = mobilesync_receive(client, &msg); //send 'SDMessageAcknowledgeChangesFromDevice' msg = plist_new_array(); plist_array_append_item(msg,plist_new_string("SDMessageAcknowledgeChangesFromDevice")); plist_array_append_item(msg, plist_new_string("com.apple.Contacts")); err = mobilesync_send(sync_client, msg); if(plist_getparent(msg) == NULL) /* check whether it's a root node / if(plist_get_node_type(msg) == PLISTARRAY) / check whether root node is an array */ plist_to_xml(msg, &xml, &xml_size); printf("%s\n", xml); }

airwolf2026 commented 9 years ago

send 'SDMessageAcknowledgeChangesFromDevice' to tell device you had done previous msg,then device can send other info like phonenumbers etc

vipinbeni commented 9 years ago

hi sir i tried it but same out out still i am trying it to rewrite again as money changes has been done after final i will show you my code again .

vipinbeni commented 9 years ago

Thanks a lot Sir its working after make some little change THANKS A LOT and expecting help if needed in further implementation of this sync process to my application..

airwolf2026 commented 9 years ago

hm, there are a lot free software to manager idevice.

vipinbeni commented 9 years ago

k I want to add new contact with all detail to iphone is i am in right direction pls guide me sir..

i am using vc++ in my app

can i also insert contact with this method .

airwolf2026 commented 9 years ago

yes,you're in rigtht direction reference this http://www.libimobiledevice.org/docs/mobilesync.html to sync changes to iphone

vipinbeni commented 9 years ago

Dear Sir Could you tell me little bit how can i insert i new contact in iphone using this some steps as you tell me in reading contact from iphone

Thanks

On Wed, Sep 17, 2014 at 8:13 AM, airwolf2026 notifications@github.com wrote:

yes,you're in rigtht direction reference this http://www.libimobiledevice.org/docs/mobilesync.html to sync changes to iphone

— Reply to this email directly or view it on GitHub https://github.com/storoj/libimobiledevice-win32/issues/18#issuecomment-55842100 .

Thanks Vipin Kumar Beniwal

vipinbeni commented 9 years ago

Hi Sir,

i am trying to add new contact using following code but i am not understand how can i do this please help me . where the detail of contact add i don't understand pls help me out sir.

int main1(mobilesync_client_t sync_client) { int count, i, err; plist_t data = NULL; plist_t msg = NULL; plist_t responset = NULL; char * response; /* Initial handshake / msg = plist_new_array(); plist_array_append_item(msg, plist_new_string("SDMessageSyncDataClassWithDevice")); plist_array_append_item(msg, plist_new_string("com.apple.Contacts")); plist_array_append_item(msg, plist_new_string("---")); plist_array_append_item(msg, plist_newstring("2013-07-29 22-34-00 00")); / plist_array_append_item(msg, plist_new_string("SDSyncTypeSlow")); */ plist_array_append_item(msg, plist_new_uint(106)); plist_array_append_item(msg, plist_new_string("_EmptyParameterString_")); err = mobilesync_send(sync_client, msg); plist_free(msg); msg = NULL; if(err != 0) { printf("mobilesync_send %d, exiting.\n", err);

        return 0;
}
plist_free(msg);
msg = NULL;
err = mobilesync_receive(sync_client, &msg);
if(err != 0)
{
        printf("mobilesync_receive %d, exiting.\n", err);

        return 0;
}
response_t = plist_array_get_item(msg, 0);
plist_get_string_val(response_t, &response);
if(strcmp(response, "SDMessageSyncDataClassWithComputer") != 0)
{

        return 0;
}
msg = plist_new_array();
plist_array_append_item(msg, plist_new_string("SDMessageGetAllRecordsFromDevice"));
plist_array_append_item(msg, plist_new_string("com.apple.Contacts"));
err = mobilesync_send(sync_client, msg);
plist_free(msg);
msg = NULL;
if(err != 0)
{
        printf("mobilesync_send %d, exiting.\n", err);

        return 0;;
}
char * xml = NULL;
unsigned int xml_size;
err = mobilesync_receive(sync_client, &msg);
if(plist_get_parent(msg) == NULL) /* check whether it's a root node */
    if(plist_get_node_type(msg) == PLIST_ARRAY) /* check whether root node is an array */
    plist_to_xml(msg, &xml, &xml_size);
    printf("%s\n", xml);
    xml=NULL;
    while(msg!=NULL)
{

    plist_free(msg);
    msg = NULL;
    printf("%s\n", xml);
    //send 'SDMessageAcknowledgeChangesFromDevice'
    msg = plist_new_array();
    plist_array_append_item(msg,plist_new_string("SDMessageAcknowledgeChangesFromDevice"));
    plist_array_append_item(msg, plist_new_string("com.apple.Contacts"));
    err = mobilesync_send(sync_client, msg);
    plist_free(msg);
    msg = NULL;

    err = mobilesync_receive(sync_client, &msg);
    if(plist_get_parent(msg) == NULL) /* check whether it's a root node */
    if(plist_get_node_type(msg) == PLIST_ARRAY) /* check whether root node is an array */
    plist_to_xml(msg, &xml, &xml_size);
    printf("%s\n", xml);
    xml=NULL;
        xml_size=0;

    //
}

//=======================new change to add new contact ===========================// msg = plist_new_array(); plist_array_append_item(msg, plist_new_string("DLMessagePing")); plist_array_append_item(msg, plist_new_string("Preparing to get changes for device"));

err = mobilesync_send(sync_client, msg);
plist_free(msg);
msg = NULL;

msg = plist_new_array();
plist_array_append_item(msg, plist_new_string("SDMessageProcessChanges"));
plist_array_append_item(msg, plist_new_string("com.apple.Contacts"));

plist_array_append_item(msg, plist_new_dict());
plist_array_append_item(msg, plist_new_string("vipin"));
plist_array_append_item(msg, plist_new_bool(1));

plist_t dict = plist_new_dict();
plist_array_append_item(msg, dict);
plist_t array2 = plist_new_array();
plist_dict_insert_item(dict, "SyncDeviceLinkEntityNamesKey", array2);
plist_array_append_item(array2, plist_new_string("com.apple.contacts.Contact"));
plist_array_append_item(array2, plist_new_string("com.apple.contacts.Group"));
plist_dict_insert_item(dict, "SyncDeviceLinkAllRecordsOfPulledEntityTypeSentKey", plist_new_bool(0));

err = mobilesync_send(sync_client, msg);
plist_free(msg);
msg = NULL;

err = mobilesync_receive(sync_client, &msg);

if(plist_get_parent(msg) == NULL) /* check whether it's a root node */
    if(plist_get_node_type(msg) == PLIST_ARRAY) /* check whether root node is an array */
    plist_to_xml(msg, &xml, &xml_size);
    printf("%s\n", xml);
    xml=NULL;
plist_free(msg);
msg = NULL;
    //=======================================================//
if(err != 0)
{
        printf("mobilesync_receive %d, exiting.\n", err);

        return 0;
}
/* both checks are voluntary */
if(plist_get_parent(msg) == NULL)                       /* check whether it's a root node       */
        if(plist_get_node_type(msg) == PLIST_ARRAY)     /* check whether root node is an array  */
                plist_to_xml(msg, &xml, &xml_size);
printf("%s\n", xml);

return 0;
}

where i add details of contact and how it insert to iphone .

airwolf2026 commented 9 years ago

change the line 'plist_array_append_item(msg, plist_new_string("vipin"));' to plist_t contactMainInfoDict =plist_new_dict(); plist_dict_insert_item(contactMainInfoDict , "first name", plist_new_string("FirstName")); plist_dict_insert_item(contactMainInfoDict , "last name", plist_new_string("LastName")); blabla...like device send plist format to pc;

plist_array_append_item(msg,contactMainInfoDict );

may this help you ,sorry for my poor english.

vipinbeni commented 9 years ago

K thanks Sir i will try it and reply you

vipinbeni commented 9 years ago

Hi Sir

@storoj please Help me as i am waiting for your reply pls help me sir .

On Fri, Sep 19, 2014 at 2:35 PM, vipin beniwal < vipinkumar.beniwal01@gmail.com> wrote:

Hi Sir , contact is not added after changing this

On Thu, Sep 18, 2014 at 3:02 PM, airwolf2026 notifications@github.com wrote:

change the line 'plist_array_append_item(msg, plist_new_string("vipin"));' to plist_t contactMainInfoDict =plist_new_dict(); plist_dict_insert_item(contactMainInfoDict , "first name", plist_new_string("FirstName")); plist_dict_insert_item(contactMainInfoDict , "last name", plist_new_string("LastName")); blabla...like device send plist format to pc;

plist_array_append_item(msg,contactMainInfoDict );

may this help you ,sorry for my poor english.

— Reply to this email directly or view it on GitHub https://github.com/storoj/libimobiledevice-win32/issues/18#issuecomment-56015788 .

Thanks Vipin Kumar Beniwal

Thanks Vipin Kumar Beniwal

airwolf2026 commented 9 years ago

before send contact msg to device ,send

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
    <string>DLMessagePing</string>
    <string>com.apple.Contacts</string>
</array>
</plist>

then send the contact msg, in your case ,you miss the contact id

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
    <string>SDMessageProcessChanges</string>
    <string>com.apple.Contacts</string>
    <dict>
        <key>{7F2CEA11-BF50-4288-8A24-585D7C1FA47A}</key>
        <dict>
            <key>birthday</key>
            <date>2014-09-22T00:00:00Z</date>
            <key>com.apple.syncservices.RecordEntityName</key>
            <string>com.apple.contacts.Contact</string>
            <key>company name</key>
            <string>company</string>
            <key>department</key>
            <string>department</string>
            <key>display as company</key>
            <string>person</string>
            <key>first name</key>
            <string>name</string>
            <key>job title</key>
            <string>jobs</string>
            <key>last name</key>
            <string>test</string>
        </dict>
    </dict>
    <true/>
    <dict>
        <key>SyncDeviceLinkAllRecordsOfPulledEntityTypeSentKey</key>
        <true/>
        <key>SyncDeviceLinkEntityNamesKey</key>
        <array>
            <string>com.apple.contacts.Contact</string>
            <string>com.apple.contacts.Group</string>
        </array>
    </dict>
</array>
</plist>

after send the msg, device will send you the new id on device ,like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
    <string>SDMessageRemapRecordIdentifiers</string>
    <string>com.apple.Contacts</string>
    <dict>
        <key>{7F2CEA11-BF50-4288-8A24-585D7C1FA47A}</key>
        <string>11</string>
    </dict>
</array>
</plist>

then ,you can send phonenumbers, email etc to device ,in case of phoneNumbers:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
    <string>SDMessageProcessChanges</string>
    <string>com.apple.Contacts</string>
    <dict>
        <key>{A63CF3AD-B01A-48A8-BB5B-598CE69394CE}</key>
        <dict>
            <key>com.apple.syncservices.RecordEntityName</key>
            <string>com.apple.contacts.Phone Number</string>
            <key>contact</key>
            <array>
                <string>11</string>
            </array>
            <key>type</key>
            <string>mobile</string>
            <key>value</key>
            <string>8613599998888</string>
        </dict>
    </dict>
    <true/>
    <dict>
        <key>SyncDeviceLinkAllRecordsOfPulledEntityTypeSentKey</key>
        <true/>
        <key>SyncDeviceLinkEntityNamesKey</key>
        <array>
            <string>com.apple.contacts.Phone Number</string>
        </array>
    </dict>
</array>
</plist>

like main contact info,after received phoneNumbers,device will send you the new id base on your phoneNumber id.

<plist version="1.0">
<array>
    <string>SDMessageRemapRecordIdentifiers</string>
    <string>com.apple.Contacts</string>
    <dict>
        <key>{A63CF3AD-B01A-48A8-BB5B-598CE69394CE}</key>
        <string>3/11/0</string>
    </dict>
</array>
</plist>
vipinbeni commented 9 years ago

k Thanks Sir I will try this and get back to you Thanks a lot.

vipinbeni commented 9 years ago

Dear Sir all is going in the same way but contact is not shown and each time adding same contact id is coming , phone no out put is also same as you describe but contact is not added to iphone .

new4

new3

where is i am doing wrong pls help me sir

airwolf2026 commented 9 years ago

you should send other infos to device ,like related name,email,dates etc.

<plist version="1.0">
<array>
    <string>SDMessageProcessChanges</string>
    <string>com.apple.Contacts</string>
    <dict/>
    <true/>
    <dict>
        <key>SyncDeviceLinkAllRecordsOfPulledEntityTypeSentKey</key>
        <true/>
        <key>SyncDeviceLinkEntityNamesKey</key>
        <array>
            <string>com.apple.contacts.Related Name</string>
        </array>
    </dict>
</array>
</plist> 

in final,send

<plist version="1.0">
<array>
    <string>SDMessageFinishSessionOnDevice</string>
    <string>com.apple.Contacts</string>
</array>
</plist>

you should download a free ios tool ,then use busHound to sniffer the packet,when add a new contact.

vipinbeni commented 9 years ago

Dear Sir,

One More Query to you i am running libimobiledevice-win32 successfully in debug configuration but in release mode it show me lot of error how can i build it in release mode . I am getting error like

Touching "Release\libcnary.unsuccessfulbuild". 1>ClCompile: 1> cnary.c 1>cnary.c(30): error C2275: 'node_t' : illegal use of this type as an expression 1> D:\contact sync\libimobiledevice-win32-master-1\libcnary\include\node.h(54) : see declaration of 'node_t' 1>cnary.c(30): error C2065: 'root' : undeclared identifier

ClCompile: 2> libusbmuxd.c 1> base64.c 1>src\base64.c(49): error C2275: 'size_t' : illegal use of this type as an expression 1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(29) : see declaration of 'size_t' 1>src\base64.c(49): error C2146: syntax error : missing ';' before identifier 'outlen

airwolf2026 commented 9 years ago

sorry, i didn't build the project in release.

vipinbeni commented 9 years ago

K Sir I want use this .lib file to my main project but there they are showing linking error

1>idevice_id.obj : warning LNK4217: locally defined symbol _plist_new_bool imported in function "int cdecl main1(struct mobilesync_client_private )" (?main1@@YAHPAUmobilesync_client_private@@@Z) 1>idevice_id.obj : warning LNK4217: locally defined symbol _plist_dict_insert_item imported in function "int __cdecl main1(struct mobilesync_client_private )" (?main1@@YAHPAUmobilesync_client_private@@@Z) 1>idevice_id.obj : warning LNK4217: locally defined symbol _plist_new_dict imported in function "int cdecl main1(struct mobilesync_client_private *)" (?main1@@YAHPAUmobilesync_client_private@@@Z) 1>idevice_id.obj : warning LNK4217: locally defined symbol _plist_to_xml imported in function "int cdecl main1(struct mobilesync_client_private *)" (?main1@@YAHPAUmobilesync_client_private@@@Z) 1>idevice_id.obj : warning LNK4217: locally defined symbol _plist_get_node_type imported in function "int cdecl main1(struct mobilesync_client_private )" (?main1@@YAHPAUmobilesync_client_private@@@Z) 1>idevice_id.obj : warning LNK4217: locally defined symbol _plist_get_parent imported in function "int __cdecl main1(struct mobilesync_client_private )" (?main1@@YAHPAUmobilesync_client_private@@@Z) 1>idevice_id.obj : warning LNK4217: locally defined symbol _plist_get_string_val imported in function "int cdecl main1(struct mobilesync_client_private )" (?main1@@YAHPAUmobilesync_client_private@@@Z) 1>idevice_id.obj : warning LNK4217: locally defined symbol _plist_array_get_item imported in function "int __cdecl main1(struct mobilesync_client_private )" (?main1@@YAHPAUmobilesync_client_private@@@Z) 1>idevice_id.obj : warning LNK4217: locally defined symbol _plist_free imported in function "int cdecl main1(struct mobilesync_client_private )" (?main1@@YAHPAUmobilesync_client_private@@@Z) 1>idevice_id.obj : warning LNK4217: locally defined symbol _plist_new_uint imported in function "int __cdecl main1(struct mobilesync_client_private )" (?main1@@YAHPAUmobilesync_client_private@@@Z) 1>idevice_id.obj : warning LNK4217: locally defined symbol _plist_array_append_item imported in function "int cdecl main1(struct mobilesync_client_private *)" (?main1@@YAHPAUmobilesync_client_private@@@Z) 1>idevice_id.obj : warning LNK4217: locally defined symbol _plist_new_string imported in function "int cdecl main1(struct mobilesync_client_private )" (?main1@@YAHPAUmobilesync_client_private@@@Z) 1>idevice_id.obj : warning LNK4217: locally defined symbol _plist_new_array imported in function "int __cdecl main1(struct mobilesync_client_private )" (?main1@@YAHPAUmobilesync_client_private@@@Z) 1>libimobiledevice.lib(lockdown.obj) : error LNK2019: unresolved external symbol _BIO_new referenced in function "short cdecl lockdownd_gen_pair_cert(struct key_data_t,struct key_data_t ,struct key_data_t ,struct key_data_t *)" (?lockdownd_gen_pair_cert@@YAFUkey_data_t@@PAU1@11@Z) 1>libimobiledevice.lib(idevice.obj) : error LNK2001: unresolved external symbol _BIO_new 1>libimobiledevice.lib(userpref.obj) : error LNK2001: unresolved external symbol _BIO_new 1>libimobiledevice.lib(lockdown.obj) : error LNK2019: unresolved external symbol _BIO_free referenced in function "short cdecl lockdownd_gen_pair_cert(struct key_data_t,struct key_data_t ,struct key_data_t ,struct key_data_t )" (?lockdownd_gen_pair_cert@@YAFUkey_data_t@@PAU1@11@Z) 1>libimobiledevice.lib(idevice.obj) : error LNK2001: unresolved external symbol _BIO_free 1>libimobiledevice.lib(lockdown.obj) : error LNK2019: unresolved external symbol _BIO_ctrl referenced in function "short __cdecl lockdownd_gen_pair_cert(struct key_data_t,struct key_data_t ,struct key_data_t ,struct key_data_t )" (?lockdownd_gen_pair_cert@@YAFUkey_data_t@@PAU1@11@Z) 1>libimobiledevice.lib(userpref.obj) : error LNK2001: unresolved external symbol _BIO_ctrl 1>libimobiledevice.lib(lockdown.obj) : error LNK2019: unresolved external symbol _BIO_s_mem referenced in function "short cdecl lockdownd_gen_pair_cert(struct key_data_t,struct key_data_t ,struct key_data_t ,struct key_data_t )" (?lockdownd_gen_pair_cert@@YAFUkey_data_t@@PAU1@11@Z) 1>libimobiledevice.lib(userpref.obj) : error LNK2001: unresolved external symbol _BIO_s_mem 1>libimobiledevice.lib(lockdown.obj) : error LNK2019: unresolved external symbol _BIO_new_mem_buf referenced in function "short __cdecl lockdownd_gen_pair_cert(struct key_data_t,struct key_data_t ,struct key_data_t ,struct key_data_t )" (?lockdownd_gen_pair_cert@@YAFUkey_data_t@@PAU1@11@Z) 1>libimobiledevice.lib(idevice.obj) : error LNK2001: unresolved external symbol _BIO_new_mem_buf 1>libimobiledevice.lib(lockdown.obj) : error LNK2019: unresolved external symbol _ASN1_INTEGER_new referenced in function "short cdecl lockdownd_gen_pair_cert(struct key_data_t,struct key_data_t ,struct key_data_t ,struct key_data_t )" (?lockdownd_gen_pair_cert@@YAFUkey_data_t@@PAU1@11@Z) 1>libimobiledevice.lib(userpref.obj) : error LNK2001: unresolved external symbol _ASN1_INTEGER_new 1>libimobiledevice.lib(lockdown.obj) : error LNK2019: unresolved external symbol _ASN1_INTEGER_free referenced in function "short __cdecl lockdownd_gen_pair_cert(struct key_data_t,struct key_data_t ,struct key_data_t ,struct key_data_t )" (?lockdownd_gen_pair_cert@@YAFUkey_data_t@@PAU1@11@Z) 1>libimobiledevice.lib(userpref.obj) : error LNK2001: unresolved external symbol _ASN1_INTEGER_free 1>libimobiledevice.lib(lockdown.obj) : error LNK2019: unresolved external symbol _ASN1_TIME_new referenced in function "short cdecl lockdownd_gen_pair_cert(struct key_data_t,struct key_data_t ,struct key_data_t ,struct key_data_t *)" (?lockdownd_gen_pair_cert@@YAFUkey_data_t@@PAU1@11@Z) 1>libimobiledevice.lib(userpref.obj) : error LNK2001: unresolved external symbol _ASN1_TIME_new 1>libimobiledevice.lib(lockdown.obj) : error LNK2019: unresolved external symbol _ASN1_TIME_free referenced in function "short cdecl lockdownd_gen_pair_cert(struct key_data_t,struct key_data_t ,struct key_data_t ,struct key_data_t )" (?lockdownd_gen_pair_cert@@YAFUkey_data_t@@PAU1@11@Z) 1>libimobiledevice.lib(userpref.obj) : error LNK2001: unresolved external symbol _ASN1_TIME_free 1>libimobiledevice.lib(lockdown.obj) : error LNK2019: unresolved external symbol _ASN1_TIME_set referenced in function "short __cdecl lockdownd_gen_pair_cert(struct key_data_t,struct key_data_t ,struct key_data_t ,struct key_data_t )" (?lockdownd_gen_pair_cert@@YAFUkey_data_t@@PAU1@11@Z) idevice_id.obj : error LNK2019: unresolved external symbol impplist_new_bool referenced in function "int cdecl main1(struct mobilesync_client_private *)" (?main1@@YAHPAUmobilesync_client_private@@@Z) 1>idevice_id.obj : error LNK2019: unresolved external symbol impplist_dict_insert_item referenced in function "int cdecl main1(struct mobilesync_client_private )" (?main1@@YAHPAUmobilesync_client_private@@@Z) 1>idevice_id.obj : error LNK2019: unresolved external symbol impplist_new_dict referenced in function "int __cdecl main1(struct mobilesync_client_private )" (?main1@@YAHPAUmobilesync_client_private@@@Z) 1>idevice_id.obj : error LNK2019: unresolved external symbol impplist_to_xml referenced in function "int cdecl main1(struct mobilesync_client_private *)" (?main1@@YAHPAUmobilesync_client_private@@@Z) 1>idevice_id.obj : error LNK2019: unresolved external symbol impplist_get_node_type referenced in function "int cdecl main1(struct mobilesync_client_private )" (?main1@@YAHPAUmobilesync_client_private@@@Z) 1>idevice_id.obj : error LNK2019: unresolved external symbol impplist_get_parent referenced in function "int __cdecl main1(struct mobilesync_client_private )" (?main1@@YAHPAUmobilesync_client_private@@@Z) 1>idevice_id.obj : error LNK2019: unresolved external symbol impplist_get_string_val referenced in function "int cdecl main1(struct mobilesync_client_private *)" (?main1@@YAHPAUmobilesync_client_private@@@Z) 1>idevice_id.obj : error LNK2019: unresolved external symbol impplist_array_get_item referenced in function "int cdecl main1(struct mobilesync_client_private )" (?main1@@YAHPAUmobilesync_client_private@@@Z) 1>idevice_id.obj : error LNK2019: unresolved external symbol _mobilesync_receive referenced in function "int __cdecl main1(struct mobilesync_client_private )" (?main1@@YAHPAUmobilesync_client_private@@@Z) 1>idevice_id.obj : error LNK2019: unresolved external symbol impplist_free referenced in function "int cdecl main1(struct mobilesync_client_private )" (?main1@@YAHPAUmobilesync_client_private@@@Z) 1>idevice_id.obj : error LNK2019: unresolved external symbol _mobilesync_send referenced in function "int __cdecl main1(struct mobilesync_client_private )" (?main1@@YAHPAUmobilesync_client_private@@@Z) 1>idevice_id.obj : error LNK2019: unresolved external symbol impplist_new_uint referenced in function "int cdecl main1(struct mobilesync_client_private )" (?main1@@YAHPAUmobilesync_client_private@@@Z) 1>idevice_id.obj : error LNK2019: unresolved external symbol impplist_array_append_item referenced in function "int __cdecl main1(struct mobilesync_client_private )" (?main1@@YAHPAUmobilesync_client_private@@@Z) 1>idevice_id.obj : error LNK2019: unresolved external symbol impplist_new_string referenced in function "int __cdecl main1(struct mobilesync_client_private )" (?main1@@YAHPAUmobilesync_client_private@@@Z) 1>idevice_id.obj : error LNK2019: unresolved external symbol impplist_new_array referenced in function "int __cdecl main1(struct mobilesync_client_private )" (?main1@@YAHPAUmobilesync_client_private@@@Z) 1>idevice_id.obj : error LNK2019: unresolved external symbol _lockdownd_client_free referenced in function _main 1>idevice_id.obj : error LNK2019: unresolved external symbol _mobilesync_client_free referenced in function _main 1>idevice_id.obj : error LNK2019: unresolved external symbol _mobilesync_client_new referenced in function _main 1>idevice_id.obj : error LNK2019: unresolved external symbol _lockdownd_data_classes_free referenced in function _main 1>idevice_id.obj : error LNK2019: unresolved external symbol _lockdownd_get_sync_data_classes referenced in function _main 1>idevice_id.obj : error LNK2019: unresolved external symbol _lockdownd_start_service referenced in function _main 1>idevice_id.obj : error LNK2019: unresolved external symbol _idevice_free referenced in function _main 1>idevice_id.obj : error LNK2019: unresolved external symbol _lockdownd_client_new_with_handshake referenced in function _main 1>idevice_id.obj : error LNK2019: unresolved external symbol _idevice_new referenced in function _main 1>idevice_id.obj : error LNK2019: unresolved external symbol _idevice_set_debug_level referenced in function _main

airwolf2026 commented 9 years ago

sorry,i don't maintain this project . and I have no experience in vc++ you may ask other people to sovle your question.

vipinbeni commented 9 years ago

Thanks a lot Sir , My little query about AFC that i write a file to device using AFCFileRefWrite all is going well but file is not shown in iphone it is shown after i restart device So Please tell me how can i update it to device after writing file so it can show without restart . Image Is not reflect without restart the device .

Pls help Sir

airwolf2026 commented 9 years ago

call afcflush? or afcclosefile??

akhilritu commented 9 years ago

please help where i am wrong...

akhilritu commented 9 years ago

Hi sir, I am getting these values in plist as

please tell me where i am wrong.

airwolf2026 commented 9 years ago

hi, akhiritu, you can add a contact in device with all information like phoneNumber,email, address,note ...blabla. then use your read code to get this contact from device,and save these plist that device send to you.

after that ,you should know how to send a contact with phoneNumber or email info to device.

akhilritu commented 9 years ago

Hello sir, I have added a contact and received id 1277 and after that i am sending phone number info as below but -1 is returning in mobilesync_receive

akhilritu commented 9 years ago

Hi sir,

Is Akhil1130sep14 is the right key because it is my contact first name.

airwolf2026 commented 9 years ago

sorry ,i forget that key fomat, see the plist you get from device.

akhilritu commented 9 years ago

It is as you have mentioned in your code described on this page but i have changed contact to Akhil1130sep14 in the key part after com.apple.contacts.Phone Number

akhilritu commented 9 years ago

you have described above as:

after send the msg, device will send you the new id on device ,like:

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

SDMessageRemapRecordIdentifiers com.apple.Contacts {7F2CEA11-BF50-4288-8A24-585D7C1FA47A} 11

then ,you can send phonenumbers, email etc to device ,in case of phoneNumbers:

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

SDMessageProcessChanges com.apple.Contacts ``` type mobile SyncDeviceLinkAllRecordsOfPulledEntityTypeSentKey SyncDeviceLinkEntityNamesKey com.apple.contacts.Phone Number ```

Please help

airwolf2026 commented 9 years ago
<key>Akhil1130sep14</key> 

the key is wrong, correct is

<key>contact</key>
<array>
    <string>"the contact id that device send to you"</string>
</array>
akhilritu commented 9 years ago

Ok sir i am trying this.

akhilritu commented 9 years ago

hi

airwolf2026 commented 9 years ago

Sorry,i don't know why you received -1.Maybe other error happens,see the device runtime log

or you leave an email. I'll send the packages when add a new contact with phoneNumber info on device

akhilritu commented 9 years ago

Ok sir i will check again. My email id is: akhil.ritu777@gmail.com

akhilritu commented 9 years ago

Hello sir, Where can i see the device runtime log.

airwolf2026 commented 9 years ago

Use idevicesyslog tool to view the syslog in realtime on http://www.libimobiledevice.org/ site

akhilritu commented 9 years ago

Ok sir