public NokiaContactsProvider(IGUICallbacks host, SyncEngine syncEngine)
		{
			owner = host;
			this.syncEngine = syncEngine;
		}
		public void Init(string providerSpecified, bool noneProvider)
		{
			syncEngine = new SyncEngine(this, Owner is EssentialWindow);
			
			this.noneProvider = noneProvider;

			if (noneProvider)
			{
				this.lastSyncMessage.Content = "Choose your current provider.";
				this.lastSyncMessage.Visibility = Visibility.Visible;
			}

			try
			{
				if (!IsNET35Installed())
					throw new System.Exception("Windows Live is unavailable. Install .NET 3.5 Framework.");

				Assembly a = LoadLocalAssembly(
					System.IO.Path.GetDirectoryName(
						Assembly.GetExecutingAssembly().Location)
					+ "\\Synrc.WindowsLive.dll");

				Type t = a.GetType("Synrc.LiveContactsProvider");
				live = Activator.CreateInstance(t, new object[] { this, syncEngine }) as ISyncSource;

				//live = new LiveContactsProvider(this, syncEngine);
			}
			catch (Exception excp)
			{
				syncButton.DropDown.Items.Remove(GetSyncMenuItemByName("WindowsLive"));

				this.lastSyncMessage.Content = excp.Message;
				this.lastSyncMessage.Visibility = Visibility.Visible;
			}

			try
			{
				if (!IsOutlookInstalled())
					throw new System.Exception("Outlook not installed.");

				//Assembly a = LoadLocalAssembly("Synrc.Outlook.dll");
				//Type t = a.GetType("Synrc.OutlookContactsProvider");
				//outlook = Activator.CreateInstance(t, new object[] { this, syncEngine}) as ISyncSource;

				outlook = new OutlookContactsProvider(this, syncEngine);
			}
			catch (System.IO.FileNotFoundException e)
			{
				Process reg = new Process();
				reg.StartInfo.FileName = "regsvr32.exe";
				reg.StartInfo.Arguments = "/s Redemption.dll";
				reg.StartInfo.UseShellExecute = false;
				reg.StartInfo.CreateNoWindow = true;
				reg.StartInfo.RedirectStandardOutput = true;
				reg.Start();
				reg.WaitForExit();
				reg.Close();

				outlook = new OutlookContactsProvider(this, syncEngine);
			}
			catch (Exception e)
			{
				syncButton.DropDown.Items.Remove(GetSyncMenuItemByName("Outlook"));
			}

			vista = new WindowsContactsProvider(this, syncEngine);
			gmail = new GmailContactsProvider(this, syncEngine);


			if (IsNokiaInstalled())
			{
				nokia = new NokiaContactsProvider(this, syncEngine);
				nokiaDiscoverer = new NokiaDiscoverer(this, nokia as NokiaContactsProvider);
				this.syncButton.DropDown.Opened += new RoutedEventHandler(DropDown_Opened);
				nokiaDiscoverer.DiscoveryTask();
			}

			if (!noneProvider)
			{
				switch (providerSpecified)
				{
					case "gmail": currentProvider = gmail; break;
					case "windows": currentProvider = vista; break;
					case "live": currentProvider = live; break;
					case "outlook": currentProvider = outlook; break;
					default: currentProvider = vista; break;
				}

				syncButton.DropDown.Items.Remove(GetSyncMenuItemByName(currentProvider.Name));

				searchContext = syncEngine.Sync(currentProvider, currentProvider);
			}

			DataContext = searchContext;
		}
		public WindowsContactsProvider(IGUICallbacks host, SyncEngine syncEngine)
		{
			owner = host;
			manager = new ContactManager();
			this.syncEngine = syncEngine;
		}
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
			syncEngine = new SyncEngine(this, false);

			this.lastSyncMessage.Content = "Choose your current provider.";
			this.lastSyncMessage.Visibility = Visibility.Visible;

			try
			{
				if (!IsNET35Installed())
					throw new System.Exception("Windows Live is unavailable. Install .NET 3.5 Framework.");

				Assembly a = LoadLocalAssembly(
					System.IO.Path.GetDirectoryName(
						Assembly.GetExecutingAssembly().Location) 
					+ "\\Synrc.WindowsLive.dll");
				
				Type t = a.GetType("Synrc.LiveContactsProvider");
				live = Activator.CreateInstance(t, new object[] { this, syncEngine }) as ISyncSource;

				//live = new LiveContactsProvider(this, syncEngine);
			}
			catch (Exception excp)
			{
				syncButton.DropDown.Items.Remove(GetSyncMenuItemByName("WindowsLive"));

				this.lastSyncMessage.Content = excp.Message;
				this.lastSyncMessage.Visibility = Visibility.Visible;
			}

			try
			{
				if (!IsOutlookInstalled())
				throw new System.Exception("Outlook not installed.");

				//Assembly a = LoadLocalAssembly("Synrc.Outlook.dll");
				//Type t = a.GetType("Synrc.OutlookContactsProvider");
				//outlook = Activator.CreateInstance(t, new object[] { this, syncEngine}) as ISyncSource;

				outlook = new OutlookContactsProvider(this, syncEngine);
			}
			catch
			{
				syncButton.DropDown.Items.Remove(GetSyncMenuItemByName("Outlook"));
			}

			vista = new WindowsContactsProvider(this, syncEngine);
			gmail = new GmailContactsProvider(this, syncEngine);
			

			if (IsNokiaInstalled())
			{
				nokia = new NokiaContactsProvider(this, syncEngine);
				nokiaDiscoverer = new NokiaDiscoverer(this, nokia as NokiaContactsProvider);
				this.syncButton.DropDown.Opened += new RoutedEventHandler(DropDown_Opened);
				nokiaDiscoverer.DiscoveryTask();
			}
			
			currentProvider = null;

			//searchContext = syncEngine.Sync(currentProvider, currentProvider);

			DataContext = searchContext;
        }
		public OutlookContactsProvider(IGUICallbacks host, SyncEngine syncEngine)
		{
			owner = host;

			outlookApp = new Microsoft.Office.Interop.Outlook.ApplicationClass();
			Microsoft.Office.Interop.Outlook.NameSpace ns = outlookApp .GetNamespace("MAPI");
			nsObject = ns.MAPIOBJECT;

			if (!IsRedemptionInstalled())
			{
				Process reg = new Process();
				reg.StartInfo.FileName = "regsvr32.exe";
				reg.StartInfo.Arguments = "/s Redemption.dll";
				reg.StartInfo.UseShellExecute = false;
				reg.StartInfo.CreateNoWindow = true;
				reg.StartInfo.RedirectStandardOutput = true;
				reg.Start();
				reg.WaitForExit();
				reg.Close();
			}
			else
			{
			}

			rdoSession = new RDOSessionClass();
			try
			{
				rdoSession.MAPIOBJECT = nsObject;
			}
			catch
			{
				Microsoft.Office.Interop.Outlook.MAPIFolder mf = outlookApp.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts);
				string pstPath = GetStorePath(mf.StoreID);
				//string pstPath = @"C:\Users\maxim\AppData\Local\Microsoft\Outlook\Outlook.pst";
				rdoSession.LogonPstStore(pstPath, 1, "", "", 0);
			}
			
			rdoAddressBook = rdoSession.AddressBook;
			rdoAddressList = rdoAddressBook.GAL;
			rdoFld = rdoSession.GetDefaultFolder(rdoDefaultFolders.olFolderContacts);
			rdoItems = rdoFld.Items;

			this.syncEngine = syncEngine;
		}
		public GmailContactsProvider(IGUICallbacks host, SyncEngine syncEngine)
		{
			this.syncEngine = syncEngine;
			owner = host;
		}