Ejemplo n.º 1
0
		private int ReadContact(DAContentAccessDefinitions.CA_ITEM_ID UID, ref CADataDefinitions.CA_DATA_CONTACT dataContact)
		{
			int hOperHandle = 0;
			int iRet = DAContentAccess.CABeginOperation(m_hCurrentConnection, 0, ref hOperHandle);
			if (iRet != PCCSErrors.CONA_OK)
			{
				//PCCAPIUtils.ShowErrorMessage("CABeginOperation", iRet);
				//syncEngine.CancelSync(PCCAPIUtils.CONAError2String(iRet));

				Dispatcher.Invoke(new SyncCancelEventHandler(owner.CancelSync),
						this, PCCAPIUtils.CONAError2String(iRet), null);
			}
			dataContact.iSize = Marshal.SizeOf(dataContact);
			dataContact.bPICount = 0;
			dataContact.pPIFields = IntPtr.Zero;
			dataContact.bAddressCount = 0;
			dataContact.pAddressFields = IntPtr.Zero;
			dataContact.bNumberCount = 0;
			dataContact.pNumberFields = IntPtr.Zero;
			dataContact.bGeneralCount = 0;
			dataContact.pGeneralFields = IntPtr.Zero;
			// Allocate memory for buffers
			IntPtr buffer = Marshal.AllocHGlobal(Marshal.SizeOf(UID));
			Marshal.StructureToPtr(UID, buffer, true);
			UID.iSize = Marshal.SizeOf(typeof(DAContentAccessDefinitions.CA_ITEM_ID));
			m_pContactBuffer = Marshal.AllocHGlobal(Marshal.SizeOf(dataContact));
			Marshal.StructureToPtr(dataContact, m_pContactBuffer, true);
			iRet = DAContentAccess.CAReadItem(hOperHandle, buffer, DAContentAccessDefinitions.CA_OPTION_USE_CACHE, CADataDefinitions.CA_DATA_FORMAT_STRUCT, m_pContactBuffer);
			if (iRet == PCCSErrors.CONA_OK)
			{
				// Copy data from buffer
				dataContact = (CADataDefinitions.CA_DATA_CONTACT)Marshal.PtrToStructure(m_pContactBuffer, typeof(CADataDefinitions.CA_DATA_CONTACT));
			}
			else
			{
				//PCCAPIUtils.ShowErrorMessage("CAReadItem", iRet);
				//syncEngine.CancelSync(PCCAPIUtils.CONAError2String(iRet));

				Dispatcher.Invoke(new SyncCancelEventHandler(owner.CancelSync),
						this, PCCAPIUtils.CONAError2String(iRet), null);

				Marshal.FreeHGlobal(m_pContactBuffer);
				m_pContactBuffer = IntPtr.Zero;
			}
			Marshal.FreeHGlobal(buffer);
			int iResult = DAContentAccess.CAEndOperation(hOperHandle);
			if (iResult != PCCSErrors.CONA_OK)
			{
				//PCCAPIUtils.ShowErrorMessage("CAEndOperation", iResult);
				//syncEngine.CancelSync(PCCAPIUtils.CONAError2String(iRet));

				Dispatcher.Invoke(new SyncCancelEventHandler(owner.CancelSync),
						this, PCCAPIUtils.CONAError2String(iRet), null);
			}
			return iRet;
		}
Ejemplo n.º 2
0
		public void ReadNumbers(PIMNumbers n, CADataDefinitions.CA_DATA_ITEM pimData)
		{
            if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_TEL)
            {
				n.Telephone.Add(Marshal.PtrToStringUni(pimData.pCustomData));
            }
            else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_TEL_HOME)
            {
				n.Home.Add(Marshal.PtrToStringUni(pimData.pCustomData));
            }
            else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_TEL_WORK)
            {
				n.Work.Add(Marshal.PtrToStringUni(pimData.pCustomData));
            }
            else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_TEL_PREF)
            {
				n.Preffered.Add(Marshal.PtrToStringUni(pimData.pCustomData));
            }
            else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_TEL_CAR)
            {
				n.Car.Add(Marshal.PtrToStringUni(pimData.pCustomData));
            }
            else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_TEL_DATA)
            {
				n.Data.Add(Marshal.PtrToStringUni(pimData.pCustomData));
            }
            else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_MOBILE)
            {
				n.Mobile.Add(Marshal.PtrToStringUni(pimData.pCustomData));
            }
            else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_MOBILE_HOME)
            {
				n.MobileHome.Add(Marshal.PtrToStringUni(pimData.pCustomData));
            }
            else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_MOBILE_WORK)
            {
				n.MobileWork.Add(Marshal.PtrToStringUni(pimData.pCustomData));
            }
            else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_PAGER)
            {
				n.Pager.Add(Marshal.PtrToStringUni(pimData.pCustomData));
            }
            else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_FAX)
            {
				n.Fax.Add(Marshal.PtrToStringUni(pimData.pCustomData));
            }
            else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_FAX_HOME)
            {
				n.FaxHome.Add(Marshal.PtrToStringUni(pimData.pCustomData));
            }
            else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_FAX_WORK)
            {
				n.FaxWork.Add(Marshal.PtrToStringUni(pimData.pCustomData));
			}
			else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_VIDEO)
			{
				n.Video.Add(Marshal.PtrToStringUni(pimData.pCustomData));
			}
			else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_VIDEO_HOME)
			{
				n.VideoHome.Add(Marshal.PtrToStringUni(pimData.pCustomData));
			}
			else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_VIDEO_WORK)
			{
				n.VideoWork.Add(Marshal.PtrToStringUni(pimData.pCustomData));
			}
			else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_VOIP)
			{
				n.VoIP.Add(Marshal.PtrToStringUni(pimData.pCustomData));
			}
			else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_VOIP_HOME)
			{
				n.VoIPHome.Add(Marshal.PtrToStringUni(pimData.pCustomData));
			}
			else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_VOIP_WORK)
			{
				n.VoIPWork.Add(Marshal.PtrToStringUni(pimData.pCustomData));
			}
			else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_TEL_PREF)
			{
				n.Preffered.Add(Marshal.PtrToStringUni(pimData.pCustomData));
			}
		}
Ejemplo n.º 3
0
		public void ReadPersonalInfo(PIMPersonalInfo c, CADataDefinitions.CA_DATA_ITEM pimData)
		{
            if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_NAME)
            {
				c.Name = Marshal.PtrToStringUni(pimData.pCustomData);
            } 
			else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_FN)
            {
				c.FirstName = Marshal.PtrToStringUni(pimData.pCustomData);
            }
            else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_MN)
            {
				c.MiddleName = Marshal.PtrToStringUni(pimData.pCustomData);
            }
            else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_LN)
            {
				c.LastName = Marshal.PtrToStringUni(pimData.pCustomData);
            }
            else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_TITLE)
            {
				c.Title = Marshal.PtrToStringUni(pimData.pCustomData);
            }
            else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_SUFFIX)
            {
				c.Suffix = Marshal.PtrToStringUni(pimData.pCustomData);
            }
            else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_COMPANY)
            {
				c.Company = Marshal.PtrToStringUni(pimData.pCustomData);
            }
            else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_JOB_TITLE)
            {
				c.JobTitle = Marshal.PtrToStringUni(pimData.pCustomData);
            }
            else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_BIRTHDAY)
            {
            }
            else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_PICTURE)
            {
            }
            else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_NICKNAME)
            {
				c.Nick = Marshal.PtrToStringUni(pimData.pCustomData);
            }
            else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_FORMAL_NAME)
            {
				c.FormalName = Marshal.PtrToStringUni(pimData.pCustomData);
            }
            else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_GIVEN_NAME_PRONUNCIATION)
            {
				c.GivenNamePronunciation = Marshal.PtrToStringUni(pimData.pCustomData);
            }
            else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_FAMILY_NAME_PRONUNCIATION)
            {
                c.FamilyNamePronunciation = Marshal.PtrToStringUni(pimData.pCustomData);
            }
            else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_COMPANY_NAME_PRONUNCIATION)
            {
                c.CompanyNamePronunciation = Marshal.PtrToStringUni(pimData.pCustomData);
            }
		}
Ejemplo n.º 4
0
		public void ReadAddresses(PIMAddresses a, CADataDefinitions.CA_DATA_ITEM pimData)
		{
			CADataDefinitions.CA_DATA_POSTAL_ADDRESS postal;
			postal = (CADataDefinitions.CA_DATA_POSTAL_ADDRESS)Marshal.PtrToStructure(pimData.pCustomData, typeof(CADataDefinitions.CA_DATA_POSTAL_ADDRESS));
						
			if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_POSTAL)
            {
                a.Postal = Marshal.PtrToStringUni(pimData.pCustomData);
            }
            else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_POSTAL_BUSINESS)
            {
                a.Business = Marshal.PtrToStringUni(pimData.pCustomData);
            }
            else if (pimData.iFieldSubType == CADataDefinitions.CA_FIELD_SUB_TYPE_POSTAL_PRIVATE)
            {
				a.Private = Marshal.PtrToStringUni(pimData.pCustomData);
			}

			a.City = postal.pstrCity;
			a.Country = postal.pstrCountry;
			a.POBox = postal.pstrPOBox;
			a.PostalCode = postal.pstrPostalCode;
			a.State = postal.pstrState;
			a.Street = postal.pstrStreet;

		}