public static void DACPInfoCrashReporterCallback(TextWriter writer) { writer.WriteLine("Library Information"); DACPServer server = ServerManager.CurrentServer; if (server != null) { writer.Write("-> Connection status: "); if (server.IsConnected) { writer.WriteLine("Connected"); } else { writer.WriteLine("Disconnected"); } writer.WriteLine("-> Version: " + server.ServerVersionString); writer.WriteLine("-> Protocol: " + server.ServerVersion.ToString("x").ToUpper()); writer.WriteLine("-> DMAP: " + server.ServerDMAPVersion.ToString("x").ToUpper()); writer.WriteLine("-> DAAP: " + server.ServerDAAPVersion.ToString("x").ToUpper()); } else { writer.WriteLine("-> No server connected"); } }
protected void DetachServerEvents(DACPServer server) { if (server == null) return; server.PropertyChanged -= DACPServer_PropertyChanged; }
private void btnAssemblyInfo_Click(object sender, RoutedEventArgs e) { if (assemblyInfoCount-- == 0) { Komodex.Analytics.CrashReporter.LogMessage(Komodex.Common.Phone.PhoneUtility.GetFormattedIsolatedStorageContents(), "Isolated Storage Report", true); MessageBox.Show(Assembly.GetExecutingAssembly().FullName); MessageBox.Show(DACPServer.GetAssemblyName()); MessageBox.Show(Assembly.GetCallingAssembly().FullName); } }
public void UpdateSingleSelectionMode(bool useTransitions) { DACPServer server = ServerManager.CurrentServer; if (server == null) return; if (server.IsCurrentlyPlayingVideo) SetSingleSelectionMode(true, useTransitions); else SetSingleSelectionMode(false, useTransitions); }
protected override void DialogService_Closed(object sender, EventArgs e) { base.DialogService_Closed(sender, e); DACPServer server = DataContext as DACPServer; if (server != null) { server.PropertyChanged -= DACPServer_PropertyChanged; } }
protected override void DialogService_Opened(object sender, EventArgs e) { base.DialogService_Opened(sender, e); DACPServer server = DataContext as DACPServer; if (server != null) { server.PropertyChanged += DACPServer_PropertyChanged; } UpdateKeyboardVisibility(); }
protected void DetachServerEvents(DACPServer server) { if (server == null) { return; } server.PropertyChanged -= Server_PropertyChanged; if (server == _attachedServer) { _attachedServer = null; } }
private void DetachServerEvents(DACPServer server) { if (server == null) { return; } server.PropertyChanged -= CurrentServer_PropertyChanged; server.AirPlaySpeakerUpdate -= CurrentServer_AirPlaySpeakerUpdate; server.LibraryUpdate -= CurrentServer_LibraryUpdate; if (server == _attachedServer) { _attachedServer = null; } }
public static DACPDatabase GetDatabase(DACPServer server, DACPNodeDictionary nodes) { DatabaseType type = (DatabaseType)nodes.GetInt("mdbk"); switch (type) { case DatabaseType.Main: case DatabaseType.Shared: case DatabaseType.InternetRadio: default: return(new DACPDatabase(server, nodes)); case DatabaseType.iTunesRadio: return(new iTunesRadioDatabase(server, nodes)); } }
protected void AttachServerEvents(DACPServer server) { if (server == _attachedServer) { return; } DetachServerEvents(_attachedServer); if (server == null) { return; } server.PropertyChanged += Server_PropertyChanged; _attachedServer = server; }
public static void ChooseServer(ServerConnectionInfo info) { DisconnectCurrentServer(); CurrentServer = null; ConnectionState = ServerConnectionState.NoLibrarySelected; if (!PairedServers.Contains(info)) { _log.Info("Setting current server to null..."); SelectedServerInfo = null; return; } _log.Info("Setting current server to: '{0}' ({1})", info.Name, info.ServiceID); SelectedServerInfo = info; WakeServer(); AutoConnect(); }
private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e) { if (_ignorePasswordChanges) { return; } DACPServer server = DataContext as DACPServer; if (server == null || !server.IsConnected) { return; } string obscured = new string('*', ((PasswordBox)sender).Password.Length); server.BindableAppleTVKeyboardString = obscured; }
private void AttachServerEvents(DACPServer server) { // Make sure we only attach once and to one server at a time if (server == _attachedServer) { return; } DetachServerEvents(_attachedServer); if (server == null) { return; } server.PropertyChanged += CurrentServer_PropertyChanged; server.AirPlaySpeakerUpdate += CurrentServer_AirPlaySpeakerUpdate; server.LibraryUpdate += CurrentServer_LibraryUpdate; _attachedServer = server; }
protected void ConnectToServer() { if (_server != null) { return; } if (!IsPINValid()) { return; } _currentUtility = libraryPicker.SelectedItem as DiscoveredPairingUtility; if (_currentUtility == null) { return; } string serviceID = _currentUtility.ServiceID; if (!BonjourManager.DiscoveredServers.ContainsKey(serviceID)) { MessageBox.Show(LocalizedStrings.LibraryCouldNotBeLocated, LocalizedStrings.LibraryConnectionErrorTitle, MessageBoxButton.OK); return; } _libraryService = BonjourManager.DiscoveredServers[serviceID]; string hostname = _libraryService.IPAddresses[0].ToString(); string pairingCode = string.Format("{0:0000}{0:0000}{0:0000}{0:0000}", pinTextBox.IntValue.Value); _server = new DACPServer(hostname, _libraryService.Port, pairingCode); UpdateWizardItem(true); _log.Info("Connecting to server with ID '{0}' at {1}:{2}...", serviceID, _server.Hostname, _server.Port); HandleServerConnection(_server.ConnectAsync()); }
protected virtual DACPDatabase GetDatabase(DACPServer server) { return(server.GetDatabaseByID(_databaseID)); }
public DACPDatabase(DACPServer server, DACPNodeDictionary nodes) : base(server, nodes) { }
protected async void ConnectToServer() { if (_server != null) { return; } if (!HasValidData()) { return; } string host; int port; ParseHostname(out host, out port); string pairingCode = string.Format("{0:0000}{0:0000}{0:0000}{0:0000}", pinTextBox.IntValue.Value); try { _server = new DACPServer(host, port, pairingCode); } catch { MessageBox.Show(LocalizedStrings.LibraryConnectionErrorBody, LocalizedStrings.LibraryConnectionErrorTitle, MessageBoxButton.OK); _server = null; UpdateWizardItem(true); return; } UpdateWizardItem(true); var result = await _server.ConnectAsync(); switch (result) { case ConnectionResult.Success: // Save the server connection info ServerConnectionInfo info = new ServerConnectionInfo(); info.Name = _server.LibraryName; info.PairingCode = _server.PairingCode; info.LastHostname = _server.Hostname; info.LastIPAddress = _server.Hostname; info.LastPort = _server.Port; // Get the service ID for Bonjour // In iTunes 10.1 and later, the service name comes from ServiceID (parameter aeIM). // In foo_touchremote the service name is the same as the database ID (parameter mper). // In MonkeyTunes, the service ID is not available from the database query. TODO. if (_server.MainDatabase.ServiceID > 0) { info.ServiceID = _server.MainDatabase.ServiceID.ToString("x16").ToUpper(); } else { info.ServiceID = _server.MainDatabase.PersistentID.ToString("x16").ToUpper(); } ServerManager.AddServerInfo(info); ServerManager.ChooseServer(info); Hide(); NavigationManager.GoToFirstPage(); break; case ConnectionResult.InvalidPIN: MessageBox.Show(LocalizedStrings.LibraryPINErrorBody, LocalizedStrings.LibraryPINErrorTitle, MessageBoxButton.OK); _server = null; UpdateWizardItem(true); break; case ConnectionResult.ConnectionError: MessageBox.Show(LocalizedStrings.LibraryConnectionErrorBody, LocalizedStrings.LibraryConnectionErrorTitle, MessageBoxButton.OK); _server = null; UpdateWizardItem(true); break; } }
public iTunesRadioDatabase(DACPServer server, DACPNodeDictionary nodes) : base(server, nodes) { }
private void UpdateKeyboardVisibility() { DACPServer server = DataContext as DACPServer; if (server == null) { return; } if (server.IsAppleTVKeyboardVisible) { Trackpad.Visibility = Visibility.Collapsed; Keyboard.Visibility = Visibility.Visible; var inputScope = new InputScope(); var keyboardType = server.CurrentAppleTVKeyboardType; switch (keyboardType) { case AppleTVKeyboardType.Email: inputScope.Names.Add(new InputScopeName() { NameValue = InputScopeNameValue.EmailNameOrAddress }); break; case AppleTVKeyboardType.Standard: default: inputScope.Names.Add(new InputScopeName() { NameValue = InputScopeNameValue.Default }); break; } KeyboardTextBox.InputScope = inputScope; if (keyboardType == AppleTVKeyboardType.Password) { _ignorePasswordChanges = true; KeyboardPasswordBox.Password = string.Empty; KeyboardTextBox.Visibility = Visibility.Collapsed; KeyboardPasswordBox.Visibility = Visibility.Visible; KeyboardPasswordBox.Focus(); _ignorePasswordChanges = false; } else { _ignorePasswordChanges = true; KeyboardPasswordBox.Visibility = Visibility.Collapsed; KeyboardTextBox.Visibility = Visibility.Visible; KeyboardTextBox.Focus(); } } else { Keyboard.Visibility = Visibility.Collapsed; Trackpad.Visibility = Visibility.Visible; } }
private static void AutoConnect() { if (SelectedServerInfo == null) { return; } if (CurrentServer == null) { DACPServer newServer = GetDACPServer(SelectedServerInfo); if (newServer == null) { ConnectionState = ServerConnectionState.LookingForLibrary; return; } CurrentServer = newServer; } else { if (CurrentServer.IsConnected) { return; } bool forceReconnect = false; // Update the IP from Bonjour if we can if (BonjourManager.DiscoveredServers.ContainsKey(SelectedServerInfo.ServiceID)) { var service = BonjourManager.DiscoveredServers[SelectedServerInfo.ServiceID]; var ips = service.IPAddresses.Select(ip => ip.ToString()).ToList(); if (ips.Count > 0 && !ips.Contains(CurrentServer.Hostname)) { CurrentServer.Hostname = ips[0]; forceReconnect = true; } if (CurrentServer.Port != service.Port) { CurrentServer.Port = service.Port; forceReconnect = true; } } if (ConnectionState == ServerConnectionState.ConnectingToLibrary && !forceReconnect) { return; } if (forceReconnect) { _log.Info("Forcing reconnection with a new address/port from Bonjour..."); DisconnectCurrentServer(); } } TrialManager.StartTrial(); if (TrialManager.TrialState == TrialState.Expired) { return; } ConnectionState = ServerConnectionState.ConnectingToLibrary; _log.Info("Connecting to server..."); ConnectCurrentServer(); }
private async void HandleServerConnection(Task <ConnectionResult> task) { var result = await task; switch (result) { case ConnectionResult.Success: _log.Info("Successfully connected to server at {0}:{1}", _server.Hostname, _server.Port); // Notify the pairing utility so it can close if (_currentUtility != null) { _currentUtility.SendPairedNotification(_server.PairingCode); } // Save the server connection info ServerConnectionInfo info = new ServerConnectionInfo(); info.Name = _server.LibraryName; info.ServiceID = _libraryService.Name; info.PairingCode = _server.PairingCode; info.LastHostname = _libraryService.Hostname; info.LastIPAddress = _server.Hostname; info.LastPort = _server.Port; _server = null; ServerManager.AddServerInfo(info); ServerManager.ChooseServer(info); Hide(); NavigationManager.GoToFirstPage(); break; case ConnectionResult.InvalidPIN: MessageBox.Show(LocalizedStrings.LibraryPINErrorBody, LocalizedStrings.LibraryPINErrorTitle, MessageBoxButton.OK); _server = null; UpdateWizardItem(true); break; case ConnectionResult.ConnectionError: // Check whether there are any other IP addresses we could try var ipStrings = _libraryService.IPAddresses.Select(ip => ip.ToString()).ToList(); var ipIndex = ipStrings.IndexOf(_server.Hostname); if (ipIndex >= 0 && ipIndex < (ipStrings.Count - 1)) { ipIndex++; string nextIP = ipStrings[ipIndex]; _server.Hostname = nextIP; _server.Port = _libraryService.Port; _log.Info("Retrying connection on new IP: {0}:{1}", _server.Hostname, _server.Port); HandleServerConnection(_server.ConnectAsync()); return; } // No other IPs, so we can't do anything else // TODO: Display error _server = null; UpdateWizardItem(true); break; } }
private void ServerManager_CurrentServerChanged(object sender, EventArgs e) { CurrentServer = ServerManager.CurrentServer; }