private void InitRemote()
        {
            if (_remote != null)
            {
                _remote.Close();
                _remote.Dispose();
            }
            _remoteConnected = false;
            _remoteLibraryRefreshed = !_config.RefreshOnConnect;

            _remote = ApiHelper.Instance().GetRemoteByApi(null);
            if (_currentRemoteId == 0)
            {
                Logger.Instance().Log("FrontView+", "No current Remote");
                _remoteInfo = new Yatse2Remote { Id = 0, CacheFilled = 1 };
                return;
            }

            var remotes = _database.GetRemote(_currentRemoteId);
            if (remotes.Count < 1)
            {
                Logger.Instance().Log("FrontView+", "No remote found");
                return;
            }

            var remoteInfo = remotes[0];
            Logger.Instance().Log("FrontView+", "Init remote : " + remoteInfo.Id + " - " + remoteInfo.Name + " (" + remoteInfo.Api + " / " + remoteInfo.Version + ")");

            _remote = ApiHelper.Instance().GetRemoteByApi(remoteInfo.Api);
            if (_remote == null)
            {
                Logger.Instance().Log("FrontView+", "Error plugin not loaded for API : " + remoteInfo.Api);
                return;
            }

            _remotePlugin = ApiHelper.Instance().GetRemotePluginByApi(remoteInfo.Api);

            txb_Home_Movies.Visibility = (_remotePlugin.SupportedFunctions().MovieLibrary) ? Visibility.Visible : Visibility.Hidden;
            txb_Home_TvShows.Visibility = (_remotePlugin.SupportedFunctions().TvShowLibrary) ? Visibility.Visible : Visibility.Hidden;
            txb_Home_Artists.Visibility = (_remotePlugin.SupportedFunctions().AudioLibrary) ? Visibility.Visible : Visibility.Hidden;
            txb_Home_Albums.Visibility = (_remotePlugin.SupportedFunctions().AudioLibrary) ? Visibility.Visible : Visibility.Hidden;
            txb_Home_Genres.Visibility = (_remotePlugin.SupportedFunctions().AudioLibrary) ? Visibility.Visible : Visibility.Hidden;

//SupportsRemoteControl
            UpdateButtonVisibility();



            _failedRemoteCheck = false;

            _remote.Configure(remoteInfo.IP, remoteInfo.Port, remoteInfo.Login, remoteInfo.Password);
            _remoteInfo = remoteInfo;

            Helper.Instance.CurrentApi = _remoteInfo.Api;

            //Helper.Instance.UseCoverArt = (bool)_config.CoverArt;

            _yatse2Properties.Api = _remoteInfo.Api;

            ClearFiltersAndDataSource();

            if (_currentGrid.Name == "grd_Home")
            {
                _gridHistory.Clear();
            }
            else
            {
                _gridHistory.Clear();
                _gridHistory.Add("grd_Home");
            }

        }
Beispiel #2
0
        public Yatse2Remote FillRemoteByComboIndex(Yatse2Remote remote, int index)
        {
            if (remote == null)
                return remote;

            remote.Api = _remotePlugins[index].Name;
            remote.ProcessName = "NotNeeded";
            return remote;
        }
Beispiel #3
0
        public bool UpdateRemote(Yatse2Remote remote)
        {
            if (remote == null)
                return false;
            var sqlCmd = _dbConnection.CreateCommand();
            sqlCmd.CommandText =
                @"UPDATE `Remotes` SET Name = ? , Api = ?, ProcessName = ?, IP = ?, Port = ?, MacAddress = ?, Login = ?, Password =  ?, Version = ?, Os = ?, Additional = ?, CacheFilled = ? WHERE Id = @Id;";
            sqlCmd.Parameters.AddWithValue("a1", remote.Name);
            sqlCmd.Parameters.AddWithValue("a2", remote.Api);
            sqlCmd.Parameters.AddWithValue("a3", remote.ProcessName);
            sqlCmd.Parameters.AddWithValue("a4", remote.IP);
            sqlCmd.Parameters.AddWithValue("a5", remote.Port);
            sqlCmd.Parameters.AddWithValue("a6", remote.MacAddress);
            sqlCmd.Parameters.AddWithValue("a7", remote.Login);
            sqlCmd.Parameters.AddWithValue("a8", remote.Password);
            sqlCmd.Parameters.AddWithValue("a9", remote.Version);
            sqlCmd.Parameters.AddWithValue("a10", remote.OS);
            sqlCmd.Parameters.AddWithValue("a12", remote.Additional);
            sqlCmd.Parameters.AddWithValue("a13", remote.CacheFilled);
            sqlCmd.Parameters.AddWithValue("@Id", remote.Id);

            return Query(sqlCmd);
        }
Beispiel #4
0
        public long InsertRemote(Yatse2Remote remote)
        {
            if (remote == null)
                return 0;
            var sqlCmd = _dbConnection.CreateCommand();
            sqlCmd.CommandText =
                @"INSERT INTO `Remotes` ( Name, Api, ProcessName, IP, Port, MacAddress, Login, Password, Version, Os, Additional, CacheFilled)  
                  VALUES ( ?,?,?,?,?,?,?,?,?,?,?,?);";
            sqlCmd.Parameters.AddWithValue("a1", remote.Name);
            sqlCmd.Parameters.AddWithValue("a2", remote.Api);
            sqlCmd.Parameters.AddWithValue("a3", remote.ProcessName);
            sqlCmd.Parameters.AddWithValue("a4", remote.IP);
            sqlCmd.Parameters.AddWithValue("a5", remote.Port);
            sqlCmd.Parameters.AddWithValue("a6", remote.MacAddress);
            sqlCmd.Parameters.AddWithValue("a7", remote.Login);
            sqlCmd.Parameters.AddWithValue("a8", remote.Password);
            sqlCmd.Parameters.AddWithValue("a9", remote.Version);
            sqlCmd.Parameters.AddWithValue("a10", remote.OS);
            sqlCmd.Parameters.AddWithValue("a11", remote.Additional);
            sqlCmd.Parameters.AddWithValue("a12", remote.CacheFilled);

            return QueryInsert(sqlCmd);
        }
Beispiel #5
0
 private Collection<Yatse2Remote> QueryRemote(SQLiteCommand query)
 {
     var remotes = new Collection<Yatse2Remote>();
     if (!_connected) return remotes;
     try
     {
         LogQuery(query);
         var sqldReader = query.ExecuteReader();
         while (sqldReader.Read())
         {
             var remote = new Yatse2Remote
             {
                 Id = GetLong(sqldReader, "Id"),
                 Name = GetString(sqldReader, "Name"),
                 Api = GetString(sqldReader, "Api"),
                 ProcessName = GetString(sqldReader, "ProcessName"),
                 IP = GetString(sqldReader, "IP"),
                 Port = GetString(sqldReader, "Port"),
                 MacAddress = GetString(sqldReader, "MacAddress"),
                 Login = GetString(sqldReader, "Login"),
                 Password = GetString(sqldReader, "Password"),
                 Version = GetString(sqldReader, "Version"),
                 OS = GetString(sqldReader, "Os"),
                 Additional = GetString(sqldReader, "Additional"),
                 CacheFilled = GetLong(sqldReader, "CacheFilled")
             };
             remotes.Add(remote);
         }
         sqldReader.Dispose();
         query.Dispose();
     }
     catch (SQLiteException e)
     {
         Log(e.Message);
     }
     return remotes;
 }
        private void btn_Remotes_Add_Click(object sender, RoutedEventArgs e)
        {
            btn_Settings_Remotes_Edit_Accept.Content = GetLocalizedString(14);

            ApiHelper.Instance().FillApiComboBox(lst_Settings_Remotes_Edit_Api, null);
            _remoteInfoEdit = new Yatse2Remote { OS = "Unknown" };
            grd_Settings_Remotes_Edit.DataContext = _remoteInfoEdit;

            grd_Settings_Remotes_Edit.Visibility = Visibility.Visible;
            //_yatse2Properties.ShowSettingsRemotesEdit = true;
        }