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

showman123 commented 9 years ago

Thank you for your reply,but sr still it gives exception errorcode=ATHostConnectionSendPowerAssertion(rt,true); I am also searching this function in IDA IDA shows that it has three arg can you give me some code for how to use this function

airwolf2026 commented 9 years ago

CFBoolean true,not the c "true"

akhilritu commented 9 years ago

Hello sir, how can i close idevice icloud sync contact programmatically in c language. please help..

akhilritu commented 9 years ago

Hello airwolf2026 sir, it will be a great help if you can guide how can i get contact information plist without closing iclous sync. Help me sir...

akhilritu commented 9 years ago

Hello airwolf2026 sir, Please guide me how to close idevice icloud sync contact programmatically.

AnFengDe commented 9 years ago

塔夫男,你好! 本不想在这里留言,不过找不到你的邮件和其他联系方式,我去了cnblogs,注意到你最近不怎么在那里活动,只好在这里留言了。 我的邮件是:chtian艾特anfengde.com 有问题向你请教,有空请邮件联系我,谢谢。

airwolf2026 commented 9 years ago

akhilritu , Sorry, last week i have a lot work to do. May be you can get value from lockdown with this domain "com.apple.mobile.data_sync" and the key "Contacts"

airwolf2026 commented 9 years ago

@AnFengDe 啊哈,可否直接这边交流呢?

akhilritu commented 9 years ago

Hello sir, Please provide it in code form how can i do it with key. Thnx for reply..

airwolf2026 commented 9 years ago

Pseudocode auto contactSet = lockdown.getValue("com.apple.mobile.data_sync","Contacts"); change contactSet; then lockdown.setValue("com.apple.mobile.data_sync","Contacts",contactSet);

akhilritu commented 9 years ago

Hello sir, i am working in c and the function is: lockdownd_get_value(lockdownd_client_t client, const char domain, const char key, plist_t *value) and

so can you please guide me about contactSet you used and how can i do this.

airwolf2026 commented 9 years ago

hi,akhilritu you can reference libimobiledevice in deviceinfo tool

akhilritu commented 9 years ago

Hi sir, How can i change contactSet? please guide me about this. I have done this:

<?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">

``` AccountNames iCloud Sources iCloud ```

So please suggest something for this...what should i do now...

airwolf2026 commented 9 years ago

hi,akhilritu Sorry, maybe i made a mistake, you can see if iTunes could close the icloud sync? If iTunes can,then we can do it .Just capture the package ...

akhilritu commented 9 years ago

Hi sir, Please give me some example about how you change contactSet so that i can apply it and see if this works or not.

airwolf2026 commented 9 years ago

Or you close the icloud account ,then use

plist_t value = NULL;
    lockdownd_error_t errr112 = 0;
    errr112 = lockdownd_get_value(client,"com.apple.mobile.data_sync","Contacts",&value);

to get the value again.Then lockdownd_set_value(xx,xx,xx,newValue);

akhilritu commented 9 years ago

Hi sir, Now i close the icloud account and get this:

<?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">

``` AccountNames Sources ```

Please suggest what should i do now?

akhilritu commented 9 years ago

Hi sir, It is not working lockdownd_set_value(xx,xx,xx,newValue). i get the value after closing the icloud account and tried to set this value but it is giving error. please guide me about this.

ftahir999 commented 9 years ago

Hi airwolf2026, Can you share the complete "com.apple.atc" process in detail? Don't need code but detailed process. Thanks

akhilritu commented 9 years ago

Hi airwolf2026, I am inserting contact info but image data is not displayed in the contact. Please guide me how can i insert image of the contact. Please help.

airwolf2026 commented 9 years ago

Use a iphone for test, add a new contact on that iphone,and set a image for that test contact,Then read that contact from the phone, and you will know how to insert a image(the protocol).

akhilritu commented 9 years ago

Hello sir, I have done that but it is not still displaying image. i am inserting as:

lenFil is the length of the chQuery buffer.

airwolf2026 commented 9 years ago

Hello akhilritu, from your code i can't see why the iphone not display image.The code is right.

maybe you add a value ?plist_dict_insert_item("display as company","company").Remove this value .

akhilritu commented 9 years ago

Hello sir, Code is:

                            msg = plist_new_array();
                            plist_array_append_item(msg, plist_new_string("DLMessagePing"));
                            plist_array_append_item(msg, 

                            err = mobilesync_receive(sync_client, &msg);

Please guide me...

akhilritu commented 9 years ago

Hello sir, In this code the same data(in plist) which is received from iphone in its original form(decoded base64) is inserted. Or we should decode it in jfif format . What else i should do...please guide.

ftahir999 commented 9 years ago

airwolf2026, Can you also please share the ATC process information?

airwolf2026 commented 9 years ago

hi, akhilritu The image format is png.The base64 encode is the bplist required, you don't encode the image data .

airwolf2026 commented 9 years ago

Hi,iMobileDevs Yes, if i have time ,i'll share the ATC info. Before share the code,maybe i'd share the main process first.

ftahir999 commented 9 years ago

Thanks airwolf2026.

ftahir999 commented 9 years ago

Hi Airwolf2026, Can you please share the complete ATC Process first, so that may I can explore it myself also.

ftahir999 commented 9 years ago

Hello Airwolf2026, do you have any update on ATC? Kindly please share the process. I am unable to find information through reverse engineering.

airwolf2026 commented 9 years ago

Hi, iMobileDevs . Sorry,last week, Apple release a x64 iTunes,now I have to make change to my code first.

ftahir999 commented 9 years ago

ok sure Airwolf2026. Thank you

prateek1108 commented 9 years ago

Hello Sir, I am trying reverse engineering of Airtraffichost.dll's for sync data with iPhone .Sir please provide me any sample code for my this job......

akhilritu commented 9 years ago

Hello Airwolf2026 sir, What i should do to get all the information of calendar ?? Please guide me...

vipinbeni commented 9 years ago

Hi Sir @airwolf2026 any update on com.apple.atc process sample code as i want to sync photo music etc from iphone so please share if you have time for ATC

thanks

airwolf2026 commented 9 years ago

@akhilritu Sync calendar like sync contact.

airwolf2026 commented 9 years ago

@vipinbeni Sorry for the delay.

akhilritu commented 9 years ago

Hello Airwolf2026 sir, I will try it. Thnx for the reply..

vipinbeni commented 9 years ago

Thanks For Reply Sir @airwolf2026 Take your Time No problem I will wait .

johnadam650 commented 9 years ago

@airwolf2026 Thank you very much for all this information. With the help of this information I can now retrieve contacts,bookmarks,notes and calendar. I can also send contact to the device. But I don't know how to send send notes,calendar and bookmark to device. Can you please guide me on this? Can you give me the SDMessageProcess Example in xml format on this? like you give above about the contact.

ftahir999 commented 9 years ago

@johnadam650, You will do the same for notes, calendar and bookmark.

johnadam650 commented 9 years ago

@iMobileDevs, Actually I can send the notes successfully and device is sending new note Key after remapping but the note isn't showing on the device? do you have any idea?

ftahir999 commented 9 years ago

Hmm well if you are getting remapped keys, then i think it should be ok. But let check by relaunching the notes app again.

johnadam650 commented 9 years ago

I'm not sending DateModified and DateCreated to the device. You think that can be the issue? I have tried relaunching the app but it doesn't show new notes.

johnadam650 commented 9 years ago

Thank you for all the help i get from this discussion. I can now send contacts,notes,bookmarks,calendar to the device successfully. It turned out that Date was the issue. DateCreated and DateModified is to be send as well for the notes.

johnadam650 commented 9 years ago

@iMobileDevs @airwolf2026 Can any of you tell me how to retrieve sms from the device? As FileRelay service been shut down by Apple after iOS 8 update. I don't know how to do it else. Your help will be much appreciated, thanks.

ftahir999 commented 9 years ago

@johnadam650 Hmm yes FileRelay is disabled in iOS 8. In my mind you can use the full backup service and then get the sms.db file. But this is a time consuming approach.

akhilritu commented 9 years ago

Hello Airwolf2026 sir, I am not getting date of note right.What should i do??

akhilritu commented 9 years ago

Hello Airwolf2026 sir, Please help....