storoj / libimobiledevice-win32

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

Enanle to use Mobilesync #18

Open vipinbeni opened 10 years ago

vipinbeni commented 10 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

akhilritu commented 9 years ago

Hello Airwolf2026 sir, Please help me to convert datestring into int32_t sec, int32_t usec to insert into plist_dict_insert_item(contactMainInfoDict , "dateCreated", plist_new_date(int32_t sec, int32_t usec));

I got date as

dateCreated
        <date>1983-09-09T22:53:14Z</date>

help please...

airwolf2026 commented 9 years ago

@akhilritu Why should you need convert GMT dataString to int32_t sec?

akhilritu commented 9 years ago

Hello sir, Because it will be inserted into plist in this foramt:

plist_dict_insert_item(contactMainInfoDict , "dateCreated", plist_new_date(int32_t sec, int32_t usec));

If i am giving 01/01/2001 as date then i got this in plist:

1969-12-31T16:00:00Z
ftahir999 commented 9 years ago

Hi @airwolf2026, Any update on atc code?

prateek1108 commented 9 years ago

hello sir, i want to restore my iPhone by .ipsw firmware of that iphone......i had gone through the code https://github.com/storoj/libimobiledevice-win32/tree/master/libimobiledevice-tools/idevicerestore but i didn't fiond code to restore iPhone.....how i can do restoration of iphone while connecting device with windows computer

vipinbeni commented 9 years ago

Hi @airwolf2026 Sir Please update us for ATC .

pls help me.

vipinbeni commented 9 years ago

Hi @airwolf2026 Sir Please update us

qianguozheng commented 9 years ago

hi @vipinbeni , how did you solve the problem as below LNK error with MSVC. I'm also coming through this problem now.

error LNK2019: unresolved external symbol impplist_array_get_item referenced

prateek1108 commented 9 years ago

Hello Airwolf2026 sir, I am trying to do the sync iphone work as per your guideline using atc protocol but i am not able to sync the photos in iphone by code even tried many a things and devoted my lot of time to do so but not able to do so please share the code if had done done this please sir its a humble request that please make a small demo code for me to solve my work, even i am interested in buying that demo code my skype id is prateek_chauhan20@hotmail.com

airwolf2026 commented 9 years ago

@prateek1108 Sorry, Im afraid I hava to break my promise.If i share the code,may be violate apple's intellectual property rights.

vipinbeni commented 9 years ago

@airwolf2026 sir there are many third party tools sync photo audio and video etc then how can they are doing this without violate apple's intellectual property rights. dear Sir please tell me how can i do this as i am waiting from a very log time i also try some freelancer but my work is still undone please help me Sir

thanks vipin

vipinbeni commented 9 years ago

@airwolf2026 pls help

vipinbeni commented 9 years ago

@airwolf2026 Sir ,

now i am able to do ATHostConnectionSendAssetCompleted but i need your help as it need .mthmb file but i am not able to convert Jpg file to .mthmb could you please tell me how can i do this.

pls sir tell me how can i change jpg to mthmb Sir i am also want to know how can we pass data to iphone of audio and vedio as image is pass mthmb file please Sir help me here

airwolf2026 commented 9 years ago

@vipinbeni . There may be opensource project to convert jpg to mthmb.

vipinbeni commented 9 years ago

@airwolf2026 any link Sir as i found on google but not get

pls sir share one sample for me.

vipinbeni commented 9 years ago

Hi Sir @airwolf2026 This my code please tell me how can i pass jpg in place of mthmb

if (hc->_status == STATUS_ASSETMANIFEST) { for (uint32_t n = 0; n < photos.size(); n++) { std::string photoGuid = photos[n].UUID; std::string photoName = photos[n].FILENAME; std::string devicePath = std::string("/Photos/Thumbs/") + photoGuid + ".mthmb";

            hc->_pDeviceInstance->CopyFileToDevice("1F4C7629-A18E-49D7-946C-EBDA3A38E29D.mthmb",devicePath);
            impl::AirTrafficHost::ATHostConnectionSendAssetCompleted(hc->_hHandle,HCFString(photoGuid.c_str()).get(), HCFString("Photo").get(), HCFString(devicePath.c_str()).get());

        }
        hc->_status = STATUS_INITIALIZE;
        continue;
    }
vipinbeni commented 9 years ago

Sir please tell me the way how can i insert image to iphone as i am not able to convert it to mthmb . Sir kindly share a link or sample for conversion if you found

please help me sir. @storoj @ @airwolf2026 and @showman123 and all other member pls helpme

vipinbeni commented 9 years ago

Dear @airwolf2026 Sir i got success to transfer photo but i am not able to create anew album in which i want to copy photo i want i will create the same name album as folder i select from pc .please help me Sir

2 . i also need your help that how can i transfer audio it is similar or i need to do some new concept for audio and vedio .

thanks a lot Sir.

airwolf2026 commented 9 years ago

@vipinbeni
Tranfser audio or vedio is like transfer photo,only the plist protols difference.

vipinbeni commented 9 years ago

dear Sir @airwolf2026 could you tell me an example how could i do this for audio and video my photolibrary.plist is <?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 >libraryKind< /key > < string >Folder< /string > < key >libraryUUID< /key > < string >B2B907D9-68E6-4E36-BFA6-A28EA24F3F77< /string > < key >updates< /key > < array > < dict > < key >caption< /key > < string >IMAG0149< /string > < key >exposureDate< /key > < real >3485353756< /real > < key >isVideo< /key > < false/> < key >itemType< /key > < string >Asset< /string > < key >latitude< /key > < real >+infinity< /real > < key >longitude< /key > < real >+infinity< /real > < key >modificationDate< /key > < real >3485353756< /real > < key >originalFileName< /key > < string >IMAG0149.jpg< /string > < key >uuid< /key > < string >799B955A-0689-4D89-A16F-A72C869545D8< /string > < /dict > < dict > < key >albumName< /key > < string >Photo Library< /string > < key >assetUUIDs< /key > < array > < string >799B955A-0689-4D89-A16F-A72C869545D8< /string > < /array > < key >itemType< /key > < string >Album< /string > < key >subclass< /key > < integer >5< /integer > < key >uuid< /key > < string >326C6D71-22EA-4847-8EB5-3EA045DD5A84< /string > < /dict > < /array > < /dict > < /plist >

i copy this plist file to /Photos/Sync/PhotoLibrary.plist location dear Sir pls tell me where i need to make change . if (hc->_status == STATUS_READYFORSYNC) {

            for (uint32_t n = 0; n < hc->_filesList.size(); n++)
            {
                char uuid[64];
                GUID connectionGuid;
                CoCreateGuid(&connectionGuid);
                sprintf_s(uuid, "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
                    connectionGuid.Data1,
                    connectionGuid.Data2,
                    connectionGuid.Data3,
                    connectionGuid.Data4[0], connectionGuid.Data4[1],
                    connectionGuid.Data4[2], connectionGuid.Data4[3], connectionGuid.Data4[4], connectionGuid.Data4[5], connectionGuid.Data4[6], connectionGuid.Data4[7]);

                std::string fullPath = hc->_filesList[n];

                size_t sep = fullPath.find_last_of("\\/");
                if (sep != std::string::npos)
                    fullPath = fullPath.substr(sep + 1, fullPath.size() - sep - 1);

                PhotoInfo info(uuid, 3485353756, fullPath);
                info.FullPath = hc->_filesList[n];
                photos.push_back(info);

            }

            // request database
            DatabaseSqlite3* db = new DatabaseSqlite3();
            db->Open("Photos.sqlite");
            db->CreatePlistHeadAndContent(hc->_pDeviceInstance, photos);
            db->Close();
            hc->_pDeviceInstance->CopyFileToDevice("PhotoLibrary.plist", "/Photos/Sync/PhotoLibrary.plist");

            impl::AirTrafficHost::ATHostConnectionSendPowerAssertion(hc->_hHandle,impl::CoreFoundation::kCFBooleanTrue);

            HCFDictionaryMutable dataSynced;
            dataSynced.addValue("Photo",1);
            HCFDictionaryMutable empty;
            impl::AirTrafficHost::ATHostConnectionSendMetadataSyncFinished(hc->_hHandle,dataSynced.get(),empty.get());
        }

and after that if (hc->_status == STATUS_ASSETMANIFEST) {

            for (uint32_t n = 0; n < photos.size(); n++)
            {
                std::string photoGuid = photos[n].UUID;
                std::string photoName = photos[n].FILENAME;
                std::string devicePath = std::string("/Photos/Thumbs/") + photoGuid + ".mthmb";

                std::string photoGuidName;

                photoGuidName = photoGuid + ".mthmb";
                test00(photos[n].FullPath, std::wstring(photoGuidName.begin(), photoGuidName.end()), photoGuid);

                Log("transferring '%s'\n", photos[n].FullPath.c_str());
                hc->_pDeviceInstance->CopyFileToDevice(photoGuidName.c_str(), devicePath);
                impl::AirTrafficHost::ATHostConnectionSendAssetCompleted(hc->_hHandle, HCFString(photoGuid.c_str()).get(), HCFString("Photo").get(), HCFString(devicePath.c_str()).get());

                DeleteFileA(photoGuidName.c_str());

        }

Kindly help me sir i am not able to transfer audio and vedio

airwolf2026 commented 9 years ago

@vipinbeni Transfer a MP3 (audio) to ios: `<?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">

Command RequestingSync Params DataclassAnchors Media 0 Dataclasses Media Keybag HostInfo Grappa AQFq+LTPz+WjnQtBJWgHS+l5AUDY4OCRqLBL60nIqXM1y15DNhsM Mklj1zWBJhyhqNKtjVBbG9gmLsj7HRCa 8A2itSEt LibraryID DC035319231CB SyncHostName BYxxxxxx SyncedDataclasses Data Version 11.1.0.126 Session 1 ` ` operations db_info audio_language -1 primary_container_pid 5406162756675934739 subtitle_language -1 operation update_db_info pid -7254603803456499258 avformat_info audio_format 301 bit_rate 320 sample_rate 44100 item album 冬雨 album_artist 齐秦 album_pid 5329534496791630948 artist 齐秦 artist_pid 5102499129198456608 artwork_cache_id 103 comment 163 key(Don't modify):L64FU3W4YxX3ZFTmbZ+8/cbGIWzMwTjyEbHi0icBF9w0MTJM+XMh2P3fo9c0SgDg3Gj/0b8nkrbtJNw5104vFhbVAKq4TcBZsuRfFgEjN+diydtiyTnk9IuEo8LgrYf/Mpp6+rqfTGGxDgjxX0/aAxoqJ12DErs6pRL7VKLJTRVB7xNK1l8O2+0q/D7Vr5SoVdH9bzzKGNGey34mmJu5dWcVllFJW6rMUwSWEwi0/vE40HLDt8DWiWOxhwpmNiTv1KmIQqN3/4B5MAx1xtKCQFCrV4L2XKa+UHLj7LZ8iVrOX01ZrNxvLChL47JZ2Mb0qiOMB0K5acx2UpLsjmjmsIM+kA3zA8f7G+spTffGavEfIIwT/YasB9PJ2kchj7AV0cyWqDKTH9fnuPNDRmMfpYUJhKM9HnV1ch4+rtOeARY= composer date_created 2015-07-22T18:26:59Z description disc_count 0 disc_number 0 genre grouping is_song sort_album 冬雨 sort_album_artist 齐秦 sort_artist 齐秦 sort_composer sort_name 大约在冬季 title 大约在冬季 total_time_ms 234292 track_count 0 track_number 0 year 0 item_stats has_been_played play_count_recent 0 play_count_user 0 skip_count_recent 0 skip_count_user 0 location kind MPEG Audio operation insert_track pid 5321879069250455199 album kind 2 name 冬雨 operation insert_album pid 5329534496791630948 artist kind 2 name 齐秦 operation insert_artist pid 5102499129198456608 revision 3 timestamp 2015-07-22T18:26:59Z ` May this can help you.
vipinbeni commented 9 years ago

@airwolf2026 can i copy this plist file to /Photos/Sync/PhotoLibrary.plist location and do same process as i photo or somthing else to do it

hc->_pDeviceInstance->CopyFileToDevice("PhotoLibrary.plist", "/Photos/Sync/PhotoLibrary.plist"); is replace with hc->_pDeviceInstance->CopyFileToDevice("audio.plist", "/Photos/Sync/audio.plist");

and what to do on if (hc->_status == STATUS_ASSETMANIFEST)

airwolf2026 commented 9 years ago

@vipinbeni Sorry, these plists just for audio transfer,not for the Photos

vipinbeni commented 9 years ago

Thanks Sir for your reply @airwolf2026 Sir i want to know where i can use this in my code i already able to transfer photo i also need for audio so please specify steps for me.

this is my code DWORD WINAPI HostConnection::Send(LPVOID Arguments) { BOOL bSyncStarted = FALSE; HostConnection* hc = (HostConnection*)Arguments;

std::vector<PhotoInfo> photos;

while (true)
{
    if (hc->_status == STATUS_SYNCALLOWED)
    {
        if (!bSyncStarted)
        {
            bSyncStarted = TRUE;

            photos.clear();

            impl::AirTrafficHost::ATHostConnectionSendPing(hc->_hHandle);
            impl::AirTrafficHost::ATHostConnectionSendPowerAssertion(hc->_hHandle, impl::CoreFoundation::kCFBooleanTrue);
            impl::AirTrafficHost::ATHostConnectionSendPowerAssertion(hc->_hHandle, impl::CoreFoundation::kCFBooleanTrue);

            HCFArrayMutable dataClassAnchors;
            if (hc->_syncType == SyncPhoto)
                dataClassAnchors.addValue(HCFString("Photo").get());
            else if (hc->_syncType == SyncAudio)
                dataClassAnchors.addValue(HCFString("Media").get());

            HCFDictionaryMutable dictParams;
            HCFArrayMutable syncedClasses;

            char computerName[256];
            DWORD dwSize = sizeof(computerName) - 1;
            GetComputerNameA(computerName, &dwSize);

            HCFDictionaryMutable hostInfo;
            hostInfo.addValue("LibraryID", hc->_libraryId);
            hostInfo.addValue("SyncHostName", computerName);
            hostInfo.addObject("SyncedDataclasses", syncedClasses.get());
            hostInfo.addValue("Version", "12.2.0.145");
            impl::AirTrafficHost::ATHostConnectionSendSyncRequest(hc->_hHandle, dataClassAnchors.get(), dictParams.get(), hostInfo.get());
            SetEvent(hc->_hSyncAllowed);
        }
        hc->_status = STATUS_INITIALIZE;
        continue;
    }

    if (hc->_status == STATUS_READYFORSYNC)
    {
        if (hc->_syncType == SyncPhoto)
        {
            for (uint32_t n = 0; n < hc->_filesList.size(); n++)
            {
                char uuid[64];
                GUID connectionGuid;
                CoCreateGuid(&connectionGuid);
                sprintf_s(uuid, "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
                    connectionGuid.Data1,
                    connectionGuid.Data2,
                    connectionGuid.Data3,
                    connectionGuid.Data4[0], connectionGuid.Data4[1],
                    connectionGuid.Data4[2], connectionGuid.Data4[3], connectionGuid.Data4[4], connectionGuid.Data4[5], connectionGuid.Data4[6], connectionGuid.Data4[7]);

                std::string fullPath = hc->_filesList[n];

                size_t sep = fullPath.find_last_of("\\/");
                if (sep != std::string::npos)
                    fullPath = fullPath.substr(sep + 1, fullPath.size() - sep - 1);

                PhotoInfo info(uuid, 3485353756, fullPath);
                info.FullPath = hc->_filesList[n];
                photos.push_back(info);

            }

            // request database
            DatabaseSqlite3* db = new DatabaseSqlite3();
            db->Open("Photos.sqlite");
            db->CreatePlistHeadAndContent(hc->_pDeviceInstance, photos);
            db->Close();
            hc->_pDeviceInstance->CopyFileToDevice("PhotoLibrary.plist", "/Photos/Sync/PhotoLibrary.plist");

            impl::AirTrafficHost::ATHostConnectionSendPowerAssertion(hc->_hHandle,impl::CoreFoundation::kCFBooleanTrue);

            HCFDictionaryMutable dataSynced;
            dataSynced.addValue("Photo",1);
            HCFDictionaryMutable empty;
            impl::AirTrafficHost::ATHostConnectionSendMetadataSyncFinished(hc->_hHandle,dataSynced.get(),empty.get());
        }

        hc->_status = STATUS_INITIALIZE;
        continue;
    }

    if (hc->_status == STATUS_ASSETMANIFEST)
    {
        if (hc->_syncType == SyncPhoto)
        {
            for (uint32_t n = 0; n < photos.size(); n++)
            {
                std::string photoGuid = photos[n].UUID;
                std::string photoName = photos[n].FILENAME;
                std::string devicePath = std::string("/Photos/Thumbs/") + photoGuid + ".mthmb";

                std::string photoGuidName;

                photoGuidName = photoGuid + ".mthmb";
                test00(photos[n].FullPath, std::wstring(photoGuidName.begin(), photoGuidName.end()), photoGuid);

                Log("transferring '%s'\n", photos[n].FullPath.c_str());
                hc->_pDeviceInstance->CopyFileToDevice(photoGuidName.c_str(), devicePath);
                impl::AirTrafficHost::ATHostConnectionSendAssetCompleted(hc->_hHandle, HCFString(photoGuid.c_str()).get(), HCFString("Photo").get(), HCFString(devicePath.c_str()).get());

                DeleteFileA(photoGuidName.c_str());

            }
        }           

        hc->_status = STATUS_INITIALIZE;
        continue;
    }

    if (hc->_status == STATUS_SEND_FILE_ERROR)
    {
        ResetEvent(hc->_hSyncAllowed);
        __debugbreak();
        continue;
    }

    if (hc->_status == STATUS_SYNCFINISHED || hc->_status == STATUS_SYNCFAILED)
    {
        ResetEvent(hc->_hSyncAllowed);
        CloseHandle(hc->_hThreadSend);
        hc->_hThreadSend = NULL;
        SetEvent(hc->_hSyncFinished);
        return 1;
    }

    if (hc->_status == STATUS_CLOSE_THREAD)
    {
        ResetEvent(hc->_hSyncAllowed);
        __debugbreak();
        continue;
    }

    Sleep(20);
}
return 0;

}

airwolf2026 commented 9 years ago

@vipinbeni Yes, you can use this to transfer audio in your code.

vipinbeni commented 9 years ago

@airwolf2026 Sir i want know this plist you send me is use at place of phtoplist i use or some other place could you please modify my code accordingly or tell me step where i need to put this plist for audio

vipinbeni commented 9 years ago

@airwolf2026 Dear sir write a few code line for me how to use this i really depend on you for this work i will wait .. Please Sir .

prateek1108 commented 9 years ago

Hello airwolf2026 sir,

Sir i had tried this photo plist code at my end but i am not getting how i can create a album in iphone by this .Please guide me to create a album in iphone.

vipinbeni commented 9 years ago

@airwolf2026 Sir please help me ....

walkman4321 commented 9 years ago

Hi Sir, I am using this library in vc++ application for getting contacts in iphone and with help of your discuddion above make some changes in my code but it gives only contacts which are add to device manually not the contacts which are sync from gmail. Please help me how to get contacts which are sync from gmail I am using the following code int count, i, err; 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);

        return 0;
}
plist_free(msg);
msg = NULL;
char * xml = NULL;
unsigned int xml_size=0;
err = mobilesync_receive(sync_client, &msg);
plist_to_xml(msg, &xml, &xml_size);

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.email"));
err = mobilesync_send(sync_client, msg);

xml = NULL;
xml_size=0;
plist_to_xml(msg, &xml, &xml_size);
plist_free(msg);
msg = NULL;
if(err != 0)
{
        printf("mobilesync_send %d, exiting.\n", err);

        return 0;;
}
//char * xml = NULL;
//unsigned int xml_size=0;
xml = NULL;
xml_size=0;

err = mobilesync_receive(sync_client, &msg);
       plist_to_xml(msg, &xml, &xml_size);
airwolf2026 commented 9 years ago

@walkman4321 You can't get contacts from ios which sync with the cloud service, like icloud or gmail contact sync service etc

walkman4321 commented 9 years ago

Hi airwolf2026, Thank you for your quick reply sir, Is their any other way for getting contact because a third party software also get contact.

fcgll521 commented 8 years ago

@vipinbeni Can you share your code about converting jpg to mthmb?

emelyan1987 commented 8 years ago

Hi Everybody!

Thanks for your discussion.

Your discussion is really useful for iPhone utilities developers.

Ahead I want to say thanks.

And I hope to ask for you how to get photos from iPhone using idevice library.

If you can please give me a hand.

Thanks again.

Emelyan

prateek1108 commented 7 years ago

Hello @airwolf2026 Sir,

i tried to connect and send data in ios 10 by libimobiledevice on windows platform . i am unable to send data to iphone, its shows error at lock_start_service() no service value is there as result of this function and the function fails at service_send() debug_info("sending %d bytes", length); service_send(client->parent, (const char)&nlen, sizeof(nlen), (uint32_t)&bytes); if (bytes == sizeof(nlen)) { service_send(client->parent, content, length, (uint32_t*)&bytes); if (bytes > 0) { debug_info("sent %d bytes", bytes); debug_plist(plist); if ((uint32_t)bytes == length) { res = PROPERTY_LIST_SERVICE_E_SUCCESS; } else { debug_info("ERROR: Could not send all data (%d of %d)!", bytes, length); } } }

first service send work completely and another one fails to write data in iphone.

prateek1108 commented 7 years ago

Hello @airwolf2026 Sir,

I upgraded the libimobiledevice code for ios 10 support ....all the things(contacts,bookmarks,notes ) are importing to iphone as in the earlier version of libimobiledevice but the calendars are not working properly in new version of libimobiledevice and ios 10 iphone. Please help me out sir how and whats change i do so i can transfer calendars to ios10 iphone.

msg = plist_new_array(); plist_array_append_item(msg, plist_new_string("SDMessageFinishSessionOnDevice")); plist_array_append_item(msg, plist_new_string("com.apple.Calendars")); plist_to_xml(msg, &xml, &xml_size); xml=NULL;

    err = mobilesync_send(sync_client, msg);

    plist_free(msg);
    msg = NULL;

    err = mobilesync_receive(sync_client, &msg);
    plist_to_xml(msg, &xml, &xml_size);
vipinbeni commented 7 years ago

@airwolf2026 Sir , i am also facing this issue all is going ok but calendar events not shown in device kindly help me is there is any update in ios 10 calendar we need to change as notes bookmark and all other is going good as it is ..@emelyan1987

airwolf2026 commented 7 years ago

@vipinbeni sorry, i have to dig it to know why u can't sync calendar like other class(bookmark,contacts,ie.)

yogendra123456 commented 5 years ago

hi all,

my Notes data is not transfer to IOS 12.0 In below code my problem is that plist_get_node_type(response_t) (3) is not match PLIST_DICT value (5) here it is fail but in previous version IOS 10 it work properly.

my key value for Note is, nkey="Note/190"; ////////////////////////////////////////// response_t=NULL; response=NULL;

            response_t = plist_array_get_item(msg, 2);
            plist_type type=   plist_get_node_type(response_t) ;        
            if(type==PLIST_DICT)
            {
                Item= plist_dict_get_item(response_t,nkey);
                plist_type type=   plist_get_node_type(Item) ;
                if(type==PLIST_STRING)
                {
                    plist_get_string_val(Item, &response);
                    sameresponse = response;
                    sameresponse22 = response;
                }

            }

/////////////////////////////////////////////// Kindly help me what is the problem with IOS 12.0 device.

Thanks

airwolf2026 commented 4 years ago

hi all,

my Notes data is not transfer to IOS 12.0 In below code my problem is that plist_get_node_type(response_t) (3) is not match PLIST_DICT value (5) here it is fail but in previous version IOS 10 it work properly.

my key value for Note is, nkey="Note/190"; ////////////////////////////////////////// response_t=NULL; response=NULL;

          response_t = plist_array_get_item(msg, 2);
          plist_type type=   plist_get_node_type(response_t) ;        
          if(type==PLIST_DICT)
          {
              Item= plist_dict_get_item(response_t,nkey);
              plist_type type=   plist_get_node_type(Item) ;
              if(type==PLIST_STRING)
              {
                  plist_get_string_val(Item, &response);
                  sameresponse = response;
                  sameresponse22 = response;
              }

          }

/////////////////////////////////////////////// Kindly help me what is the problem with IOS 12.0 device.

Thanks

from ios11, iphone can't sync Notes with PC(Mac)