Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync calendar without iCloud in ios 11.2.5 #639

Open
shmaylibi opened this issue Mar 15, 2018 · 3 comments
Open

sync calendar without iCloud in ios 11.2.5 #639

shmaylibi opened this issue Mar 15, 2018 · 3 comments

Comments

@shmaylibi
Copy link

shmaylibi commented Mar 15, 2018

I am trying to sync calenders via USB on ios 11.2.5 but its not working.
please help me in this case, why local calenders syncronization failed?
I don't get this error "No Data Store available for data class".
how can i find the problem.
Through icloud com.apple.calenders is working. Calenders sync with iphone. But local sync is not working.

pic1
pic2
pic3
pic4
pic5

@shmaylibi shmaylibi changed the title com.apple.calenders not working in ios 11.2.5 sync calendar without iCloud in ios 11.2.5 Mar 15, 2018
@mexmer
Copy link

mexmer commented Mar 15, 2018

i might review your code later, but did you read this page?

http://www.libimobiledevice.org/docs/mobilesync.html

@mexmer
Copy link

mexmer commented Mar 15, 2018

btw. i just tested my own code (based on libimobile sync), and it does work with 11.2.6, so methods itself should be fine, you probly either don't have local sync enabled, or sending wrong commands to device.

@shmaylibi
Copy link
Author

shmaylibi commented Mar 16, 2018

yes @mexmer i already read this link http://www.libimobiledevice.org/docs/mobilesync.html
i do the same as given in this link.
u said that "you probly sending wrong commands to device"
kindly please explain this more so that i can check by myself.
Please see this code.I m using this code for transfer calender's events.
i know this code is little bit lengthy but please check this sir

mobilesync_error_t CDataToiphone::SetCalenderData(mobilesync_client_t sync_client)
{

Statusinfo objtmpstatus;
CString	strNameofCont = L"";
int nitem = 0;
tableData *tempTable = pFirstCalendar;
KEYString objtmp;
CString strtmp = L"";
//get data from LList
while (tempTable != NULL)
{
	CreateCountFile();
	KEYString objtmpTable;
	int nnCCounTab = 0;
	int nLenCocccc = tempTable->listOfKeyValue.GetCount();
	for (int i = 0; i<nLenCocccc; i++)
	{
		objtmpTable = tempTable->listOfKeyValue.GetAt(i);
		if (objtmpTable.strKey.Compare(L"title") == 0)
		{
			strNameofCont = objtmpTable.strValString;
			i = nLenCocccc;
		}
	}
	objtmpstatus.strID = strNameofCont;
	int count = 0,
		i = 0,
		err = 0;
	plist_t data = NULL;
	plist_t msg = NULL;
	plist_t response_t = NULL;
	char * response = NULL;
	char * checkresponse = NULL;
	char * sameresponse = NULL;
	char * sameresponse22 = NULL;
	char * sameresponsealert = NULL;
	char * rkey = NULL;
	char * xml = NULL;
	unsigned int xml_size = 0;
	/* 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.Calendars"));
	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_uint(107));
	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 MOBILESYNC_E_SUCCESS;
	}
	plist_free(msg);
	msg = NULL;
	err = mobilesync_receive(sync_client, &msg);
	if (err != 0)
	{
		//printf("mobilesync_receive %d, exiting.\n", err);
		return MOBILESYNC_E_SUCCESS;
	}
	response_t = NULL;
	response = NULL;
	response_t = plist_array_get_item(msg, 0);
	plist_get_string_val(response_t, &response);
//=============================================================================//
	msg = plist_new_array();
	plist_array_append_item(msg, plist_new_string("DLMessagePing"));
	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;
	CString strTtt;
	strTtt.Empty();
	strTtt = L"This is another one on24feb 2015";
	LPCSTR pszNonUnicode;
	USES_CONVERSION;
	pszNonUnicode = W2A(strTtt.LockBuffer());
	strTtt.UnlockBuffer();
	int strL = strTtt.GetLength();
	const char* newid24 = pszNonUnicode;
	const TCHAR* charVal1 = (LPTSTR)(LPCTSTR)(objtmp.strKey);
	msg = plist_new_array();
	plist_array_append_item(msg, plist_new_string("SDMessageProcessChanges"));
	plist_array_append_item(msg, plist_new_string("com.apple.Calendars"));
	plist_t contactMainInfoDict = plist_new_dict();
	int nLenCount = tempTable->listOfKeyValue.GetCount();
	for (int i = 0; i<nLenCount; i++)
	{
		objtmp = tempTable->listOfKeyValue.GetAt(i);
		char *keyInsert = NULL;
		char *valInsert = NULL, *valInsert11 = NULL;
		keyInsert = ConvertstringCharToString(objtmp.strKey);
		valInsert = ConvertstringCharToString(objtmp.strValString);		
if (objtmp.strKey.Compare(L"dateModified") == 0 || objtmp.strKey.Compare(L"dateCreated") == 0)
		{
			uint32_t timeinSeconds = getSecsSinceEpoch(1970, 3, 1, 14, 2, 2, 28);
			plist_dict_insert_item(contactMainInfoDict, keyInsert, plist_new_date(timeinSeconds, 0));
		}
		else if (objtmp.strKey.Compare(L"read only") == 0)
		{
			uint64_t intVal = StrToInt(objtmp.strValString);
			plist_dict_insert_item(contactMainInfoDict, keyInsert, plist_new_uint(intVal));
		}
		else if (objtmp.strKey.Compare(L"colorComponents") == 0)
		{
			istringstream iss(valInsert);
			string s;
			int i = 0;
			uint64_t int41[5];
			while (getline(iss, s, ' '))
			{
				CString intss;
				intss.Format(_T("%S"), s.c_str());
				if (!intss.IsEmpty())
				{
					int41[i] = StrToInt(intss);
				}
				i++;
			}
			plist_t msgColor = plist_new_array();
			plist_array_append_item(msgColor, plist_new_uint(int41[0]));
			plist_array_append_item(msgColor, plist_new_uint(int41[1]));
			plist_array_append_item(msgColor, plist_new_uint(int41[2]));
			plist_array_append_item(msgColor, plist_new_uint(int41[3]));
			plist_dict_insert_item(contactMainInfoDict, "colorComponents", msgColor);
			plist_dict_insert_item(contactMainInfoDict, "com.apple.syncservices.RecordEntityName", plist_new_string("com.apple.calendars.Calendar"));
		}
		else
		{
			plist_dict_insert_item(contactMainInfoDict, keyInsert, plist_new_string(valInsert));
		}
		delete keyInsert;
		delete valInsert;
	}
	plist_t dict1 = plist_new_dict();
	char * nkey = "1/190";//
	plist_dict_insert_item(dict1, nkey, contactMainInfoDict);
	plist_array_append_item(msg, dict1);
	plist_array_append_item(msg, plist_new_bool(1));
	plist_t dict = plist_new_dict();
	xml = NULL;
	xml_size = 0;
	plist_array_append_item(msg, dict);
	plist_t array2 = plist_new_array();
	plist_dict_insert_item(dict, "SyncDeviceLinkAllRecordsOfPulledEntityTypeSentKey", plist_new_bool(1));
	plist_dict_insert_item(dict, "SyncDeviceLinkEntityNamesKey", array2);
	plist_array_append_item(array2, plist_new_string("com.apple.calendars.Calendar"));
	xml = NULL;
	err = mobilesync_send(sync_client, msg);
	plist_free(array2);
	plist_free(dict);
	plist_free(msg);
	msg = NULL;
	xml_size = 0;
	err = mobilesync_receive(sync_client, &msg);
	xml_size = 0;
	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 */														
			printf("%s\n", xml);
	////////////Response//////////////////////
	response_t = NULL;
	if (msg != NULL)
	{
		checkresponse = NULL;
		response = NULL;
		response_t = plist_array_get_item(msg, 0);
		plist_get_string_val(response_t, &response);
		checkresponse = response;
	}
	if (strcmp(checkresponse, "SDMessageRemapRecordIdentifiers") == 0)
	{
		response_t = NULL;
		response = NULL;
		sameresponse = NULL;
		plist_t Item = NULL;
		response_t = plist_array_get_item(msg, 1);
		plist_get_string_val(response_t, &response);
		if (strcmp(response, "com.apple.Calendars") == 0)
		{
			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 = sameresponse22 = response;
				}
			}
		}
	}
	tableData *tempTableEvent = pFirstCalEvent;
	while(tempTableEvent!=NULL)
	{
		if(tempTableEvent->CalendarKeyId.Find(tempTable->KeyId)>=0)
		{
			xml = NULL;
			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.Calendars"));
			contactMainInfoDict = plist_new_dict();				
			plist_t array26 = plist_new_array();			
			plist_array_append_item(array26, plist_new_string(sameresponse));
			plist_dict_insert_item(contactMainInfoDict, "calendar", array26);
			sameresponse22 = sameresponse;
			int nLenCount = tempTableEvent->listOfKeyValue.GetCount();
			for (int i = 0; i<nLenCount; i++)
			{
				objtmp = tempTableEvent->listOfKeyValue.GetAt(i);
				char *keyInsert = NULL;
				char *valInsert = NULL, *valInsert11 = NULL;
				keyInsert = ConvertstringCharToString(objtmp.strKey);
				valInsert = ConvertstringCharToString(objtmp.strValString);

				if (objtmp.strKey.Compare(L"start date") == 0 || objtmp.strKey.Compare(L"end date") == 0)
				{
					//////////3march15//1984-03-01T02:02:28Z
					TimeDateSonds TimeDateSondstmp;
					TimeDateSondstmp = GetDateTime(objtmp.strValString);
					intTimeDateSonds intTimeDateSondstemp;
					intTimeDateSondstemp = GetDateTimetoInt(TimeDateSondstmp);
					uint32_t timeinSeconds122 = getSecsSinceEpoch(2001, 10, 21, 16, 5, 5, 0);
					//uint32_t timeinSeconds = getSecsSinceEpoch(1970, 3, 1, 14, 2, 2, 28);
					uint32_t timeinSeconds;
					//timeinSeconds = getSecsSinceEpoch(1986,intTimeDateSondstemp.iMonth,intTimeDateSondstemp.iDate,intTimeDateSondstemp.iYear,intTimeDateSondstemp.iHour,intTimeDateSondstemp.iMinute,intTimeDateSondstemp.iSeconds);
					timeinSeconds = getSecsSinceEpoch(1986, intTimeDateSondstemp.iMonth, intTimeDateSondstemp.iDate, intTimeDateSondstemp.iYear, intTimeDateSondstemp.iHour, intTimeDateSondstemp.iMinute, intTimeDateSondstemp.iSeconds);
					timeinSeconds = timeinSeconds - 481630577;
					plist_dict_insert_item(contactMainInfoDict, keyInsert, plist_new_date(timeinSeconds, 0));// 414086872  478624467  447002410
				}
				else if (objtmp.strKey.Compare(L"dates") == 0)
				{
					//////////3march15//1984-03-01T02:02:28Z
					//uint32_t timeinSeconds = getSecsSinceEpoch(1970,3,1,14,2,2,28);
					//plist_dict_insert_item(contactMainInfoDict , keyInsert, plist_new_date(timeinSeconds,0));// 414086872  478624467  447002410
				}
				else if (objtmp.strKey.Compare(L"read only") == 0)
				{
					//objtmp.strValString
					uint64_t intVal = StrToInt(objtmp.strValString);
					plist_dict_insert_item(contactMainInfoDict, keyInsert, plist_new_uint(intVal));
				}
				else if (objtmp.strKey.Compare(L"calendar") == 0)
				{
					istringstream iss(valInsert);
					string s;
					plist_t msgColor = plist_new_array();
					plist_array_append_item(msgColor, plist_new_string(valInsert));

					//plist_dict_insert_item(contactMainInfoDict, "calendar", msgColor);
					//plist_dict_insert_item(contactMainInfoDict , "com.apple.syncservices.RecordEntityName", plist_new_string("com.apple.calendars.Event"));
				}
				else
				{
					plist_dict_insert_item(contactMainInfoDict, keyInsert, plist_new_string(valInsert));
				}
				delete keyInsert;
				delete valInsert;
			}
			plist_t dict12 = plist_new_dict();
			dict12 = plist_new_dict();
			///6 oct 14///
			//char * nkey1 ="2/9";
			//char * nkey1 =(char *)(tempTableEvent->KeyId).GetString();//.GetBuffer((tempTableEvent->KeyId).GetLength());
			char * nkey1 = convertToCharArr(tempTableEvent->KeyId);
			plist_dict_insert_item(dict12, nkey1, contactMainInfoDict);//"{A63CF3AD-B01A-48A8-BB5B-598CE69394CE}"														
			plist_array_append_item(msg, dict12);
			plist_array_append_item(msg, plist_new_bool(1));
			plist_t dict22 = plist_new_dict();
			plist_array_append_item(msg, dict22);
			// plist_array_append_item(msg, plist_new_string("___EmptyParameterString___"));
			plist_t array22 = plist_new_array();
			plist_dict_insert_item(dict22, "SyncDeviceLinkAllRecordsOfPulledEntityTypeSentKey", plist_new_bool(1));
			plist_dict_insert_item(dict22, "SyncDeviceLinkEntityNamesKey", array22);
			plist_array_append_item(array22, plist_new_string("com.apple.calendars.Event"));
			xml = NULL;
			xml_size = 0;
			err = mobilesync_send(sync_client, msg);
			plist_free(array22);
			plist_free(dict22);
			plist_free(dict12);
			plist_free(msg);
			msg = NULL;
			err = mobilesync_receive(sync_client, &msg);
			response_t = NULL;
			if (msg != NULL)
			{
				checkresponse = NULL;
				response = NULL;
				response_t = plist_array_get_item(msg, 0);
				plist_get_string_val(response_t, &response);
				checkresponse = response;
			}
			if (strcmp(response, "SDMessageRemapRecordIdentifiers") == 0)
			{
				response_t = NULL;
				response = NULL;
				sameresponsealert = NULL;
				plist_t Item = NULL;
				response_t = plist_array_get_item(msg, 1);
				plist_get_string_val(response_t, &response);
				if (strcmp(response, "com.apple.Calendars") == 0)
				{
					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, nkey1);
						plist_type type = plist_get_node_type(Item);
						if (type == PLIST_STRING)
						{
							plist_get_string_val(Item, &response);
							sameresponsealert = response;
							int vipin = 0;
						};
					}
				}	
			}
			//plist_free(array26);
		}
			tempTableEvent=tempTableEvent->pnext;
	}//while
	 ///////////////////////////add alert //////////////////////
	 ////////////Response//////////////////////
	response_t = NULL;
	if (msg != NULL)
	{
		checkresponse = NULL;
		response = NULL;
		response_t = plist_array_get_item(msg, 0);
		plist_get_string_val(response_t, &response);
		checkresponse = response;
	}
	if (strcmp(response, "SDMessageRemapRecordIdentifiers") == 0)
	{
		response_t = NULL;
		response = NULL;
		sameresponse = NULL;
		plist_t Item = NULL;
		response_t = plist_array_get_item(msg, 1);
		plist_get_string_val(response_t, &response);
		if (strcmp(response, "com.apple.Calendars") == 0)
		{
			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;
					int vipin = 0;
				}
			}
		}
	}
	xml = NULL;
	plist_free(msg);
	msg = NULL;
	msg = plist_new_array();
	plist_array_append_item(msg, plist_new_string("SDMessageFinishSessionOnDevice"));
	plist_array_append_item(msg, plist_new_string("com.apple.Calendars"));
	xml = NULL;
	err = mobilesync_send(sync_client, msg);
	plist_free(msg);
	msg = NULL;
	err = mobilesync_receive(sync_client, &msg);
	xml = NULL;			
	tempTable = tempTable->pnext;
}
DeleteCalendarLists();
return MOBILESYNC_E_SUCCESS;

}

After this @mexmer i got another error acc. to different ios x phone means by this code i create a recovered folder like calendar in calender's app.Only recovered folder is create no calender's event transferred in both ios x iphone.
then in ios 10.3.3 ,it is create
img_0001 pic ios 10 3 3

but in ios 11.2.5, it is not
img_0002 pic ios11 2 5

please help me why this happened

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants