Skip to content

Commit

Permalink
Merge pull request #139 from louis77/development
Browse files Browse the repository at this point in the history
Release v1.5.4
  • Loading branch information
technosf authored Oct 14, 2024
2 parents d3bd9cd + b5de002 commit ad594a4
Show file tree
Hide file tree
Showing 23 changed files with 1,220 additions and 537 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

# This job runs in a special container designed for building Flatpaks for AppCenter
container:
image: ghcr.io/elementary/flatpak-platform/runtime:6
image: ghcr.io/elementary/flatpak-platform/runtime:8
options: --privileged

# Steps represent a sequence of tasks that will be executed as part of the job
Expand All @@ -21,7 +21,7 @@ jobs:
- uses: actions/checkout@v4

# Builds your flatpak manifest using the Flatpak Builder action
- uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v3
- uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v6.3
with:
# This is the name of the Bundle file we're building and can be anything you like
bundle: Tuner.flatpak
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ build-aux
*~
.vscode
.buildconfig
.flatpak-builder
.flatpak-builder
code.sh
favicon.ico
tuner.code-workspace
47 changes: 47 additions & 0 deletions DEVELOP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# ![icon](docs/logo_01.png) Develop, Build and Contribute to Tuner [![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](http://www.gnu.org/licenses/gpl-3.0)


Discover and Listen to your favourite internet radio stations.

## Overview

Tuner is hosted on Github, and linked to Flathub so as releases are pushed Flathub will automatically update its repositary. It is writen in [Vala](https://vala.dev/), a C#/Java/JavaFX-like language with a self-hosting compiler that generates C code and uses the GObject type system and wrapping a number of GTK libraries. It uses [Meson](https://mesonbuild.com/) as its build system.



### Dependencies

```bash
granite
gstreamer-1.0
gstreamer-player-1.0
gtk+-3.0
json-glib-1.0
libgee-0.8
libsoup-3.0
meson
vala
```

### Building

Make sure you have the dependencies installed:

```bash
sudo apt install git valac meson
sudo apt install libgtk-3-dev libgee-0.8-dev libgranite-dev libgstreamer1.0-dev libgstreamer-plugins-bad1.0-dev libsoup-3.0-dev libjson-glib-dev
```

Clone the repo and drop into the Tuner directory. Configure Meson for development debug build, build Tuner with Ninja, and run the result:

```bash
meson setup --buildtype=debug builddir
ninja -C builddir
./builddir/com.github.louis77.tuner
```


```bash
meson configure -Dprefix=/usr
sudo ninja install
```
36 changes: 8 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Things I need help with:

### Flathub

Tuner is available on Flathub, but there are some known bugs:
Tuner is available asa Flatpak on Flathub:
https://flathub.org/apps/details/com.github.louis77.tuner

### elementary OS
Expand Down Expand Up @@ -83,7 +83,7 @@ While I hacked on this App, I discovered so many cool and new stations, which ma

## Features

- Uses radio-browser.info catalog
- Uses [radio-browser.info](https://www.radio-browser.info/) radio station catalog
- Presets various selection of stations (random, top, trending, genres)
- Save favourite stations
- Sends a click count to radio-browser.info on station click
Expand All @@ -102,38 +102,18 @@ While I hacked on this App, I discovered so many cool and new stations, which ma
* `TUNER_API` - a `:` separated list of API servers to read from, e.g.
* `export TUNER_API="de1.api.radio-browser.info:nl1.api.radio-browser.info"; com.github.louis77.tuner`

## Dependencies

```bash
granite
gtk+-3.0
gstreamer-1.0
gstreamer-player-1.0
libsoup-3.0
json-glib-1.0
libgee-0.8
meson
vala
```

## Building
## Build, Maintance and Development of Tuner

Make sure you have the dependencies installed:
Building, developing and maintianing **Tuner** is detailed seperately and in detail in the [DEVELOP](DEVELOP.md) markdown.

```bash
sudo apt install git valac meson
sudo apt install libgtk-3-dev libgee-0.8-dev libgranite-dev libgstreamer1.0-dev libgstreamer-plugins-bad1.0-dev libsoup-3.0-dev libjson-glib-dev
```

Then clone this repo and build it locally:
## Support

Feature request, observations and Issues can be documented with tickets on [Github](https://github.com/louis77/tuner/issues)

```bash
meson build && cd build
meson configure -Dprefix=/usr
sudo ninja install
```

## Known Issues
### Known Issues

- If AAC/AAC+ streams don't play (found on Elementary OS 6) install the following dependency:

Expand Down
12 changes: 12 additions & 0 deletions data/com.github.louis77.tuner.appdata.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@
</provides>

<releases>
<release version="1.5.4" date="2024-10-10">
<description>
<p>Maintanance release:</p>
<ul>
<li>Added API server lookup via SRV and backup via JSON, plus randomization</li>
<li>Added JSON validation for empty nodes</li>
<li>Refactored libsoup calls out to HttpClient.vala</li>
<li>Refactored loading of favicons to Favicon.vala</li>
<li>Turned off TLS checks for HTTP calls to avoid non loading of favicons with invalid certs</li>
</ul>
</description>
</release>
<release version="1.5.3" date="2024-09-22">
<description>
<p>Maintanance release:</p>
Expand Down
4 changes: 2 additions & 2 deletions data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ endforeach
i18n.merge_file (
input: meson.project_name () + '.desktop.in',
output: meson.project_name () + '.desktop',
po_dir: join_paths (meson.source_root (), 'po', 'extra'),
po_dir: join_paths (meson.project_source_root(), 'po', 'extra'),
type: 'desktop',
install: true,
install_dir: join_paths (get_option ('datadir'), 'applications')
Expand All @@ -26,7 +26,7 @@ i18n.merge_file (
i18n.merge_file (
input: meson.project_name () + '.appdata.xml.in',
output: meson.project_name () + '.appdata.xml',
po_dir: join_paths (meson.source_root (), 'po', 'extra'),
po_dir: join_paths (meson.project_source_root(), 'po', 'extra'),
install: true,
install_dir: join_paths (get_option ('datadir'), 'metainfo')
)
Expand Down
3 changes: 2 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
project (
'com.github.louis77.tuner',
'vala', 'c',
version: '1.5.3'
version: '1.5.4'
)

# if meson.get_compiler ('vala').get_id() == 'valac'
Expand All @@ -24,6 +24,7 @@ add_project_arguments (
config_data = configuration_data()
config_data.set_quoted('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir')))
config_data.set_quoted('GETTEXT_PACKAGE', meson.project_name())
config_data.set_quoted('VERSION', meson.project_version())
config_file = configure_file(
input: 'src/Config.vala.in',
output: '@BASENAME@',
Expand Down
2 changes: 1 addition & 1 deletion po/extra/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Install metadata translations
i18n.gettext ('extra',
args: [
'--directory=' + meson.source_root (),
'--directory=' + meson.project_source_root(),
'--from-code=UTF-8'
],
install: false
Expand Down
2 changes: 1 addition & 1 deletion po/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Install main translations
i18n.gettext (meson.project_name (),
args: [
'--directory=' + meson.source_root (),
'--directory=' + meson.project_source_root(),
'--from-code=UTF-8',
'-cTRANSLATORS'
],
Expand Down
33 changes: 32 additions & 1 deletion src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
* SPDX-FileCopyrightText: 2020-2022 Louis Brauer <[email protected]>
*/

/**
Application
Entry point for Tuner
*/
/**
* @brief Entry point for Tuner application
*/
public class Tuner.Application : Gtk.Application {

public GLib.Settings settings { get; construct; }
Expand All @@ -12,7 +20,7 @@ public class Tuner.Application : Gtk.Application {

public Window window;

public const string APP_VERSION = "1.5.3";
public const string APP_VERSION = VERSION;
public const string APP_ID = "com.github.louis77.tuner";
public const string STAR_CHAR = "";
public const string UNSTAR_CHAR = "";
Expand All @@ -21,13 +29,19 @@ public class Tuner.Application : Gtk.Application {
{ "resume-window", on_resume_window }
};

/**
* @brief Constructor for the Application
*/
public Application () {
Object (
application_id: APP_ID,
flags: ApplicationFlags.FLAGS_NONE
);
}

/**
* @brief Construct block for initializing the application
*/
construct {
GLib.Intl.setlocale (LocaleCategory.ALL, "");
GLib.Intl.bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
Expand All @@ -46,8 +60,15 @@ public class Tuner.Application : Gtk.Application {
add_action_entries(ACTION_ENTRIES, this);
}

/**
* @brief Singleton instance of the Application
*/
public static Application _instance = null;

/**
* @brief Getter for the singleton instance
* @return The Application instance
*/
public static Application instance {
get {
if (_instance == null) {
Expand All @@ -57,6 +78,9 @@ public class Tuner.Application : Gtk.Application {
}
}

/**
* @brief Activates the application
*/
protected override void activate() {
if (window == null) {
window = new Window (this, player);
Expand All @@ -68,10 +92,17 @@ public class Tuner.Application : Gtk.Application {

}

/**
* @brief Resumes the window
*/
private void on_resume_window() {
window.present();
}

/**
* @brief Ensures a directory exists
* @param path The directory path to ensure
*/
private void ensure_dir (string path) {
var dir = File.new_for_path (path);

Expand Down
1 change: 1 addition & 0 deletions src/Config.vala.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
public const string GETTEXT_PACKAGE = @GETTEXT_PACKAGE@;
public const string LOCALEDIR = @LOCALEDIR@;
public const string VERSION = @VERSION@;
2 changes: 1 addition & 1 deletion src/Main.vala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* SPDX-License-Identifier: GPL-3.0-or-later
* SPDX-FileCopyrightText: 2020-2022 Louis Brauer <[email protected]>
*/

public static int main (string[] args) {
Gst.init (ref args);

Expand Down
36 changes: 22 additions & 14 deletions src/Models/StationStore.vala
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,30 @@
* SPDX-FileCopyrightText: 2020-2022 Louis Brauer <[email protected]>
*/

// StationStore can store and retrieve a collection of stations
// in a JSON file
/**
StationStore
Store and retrieve a collection of stations in a JSON file, i.e. favorites
Uses libgee for data structures.
*/

using Gee;

namespace Tuner.Model {

public class StationStore : Object {
private ArrayList<Station> _store;
private File _data_file;
private File _favorites_file;

public StationStore (string data_path) {
public StationStore (string favorites_path) {
Object ();

_store = new ArrayList<Station> ();
_data_file = File.new_for_path (data_path);
_favorites_file = File.new_for_path (favorites_path);
ensure ();
load ();
debug (@"store initialized in path $data_path");
debug (@"store initialized in path $favorites_path");
}

public void add (Station station) {
Expand All @@ -43,7 +48,7 @@ public class StationStore : Object {
// Non-racy approach is to try to create the file first
// and ignore errors if it already exists
try {
var df = _data_file.create (FileCreateFlags.PRIVATE);
var df = _favorites_file.create (FileCreateFlags.PRIVATE);
df.close ();
debug (@"store created");
} catch (Error e) {
Expand All @@ -56,16 +61,19 @@ public class StationStore : Object {
Json.Parser parser = new Json.Parser ();

try {
var stream = _data_file.read ();
var stream = _favorites_file.read ();
parser.load_from_stream (stream);
stream.close ();
} catch (Error e) {
warning (@"store: unable to load data, does it exist? $(e.message)");
}

Json.Node node = parser.get_root ();
Json.Array array = node.get_array ();
array.foreach_element ((a, i, elem) => {
Json.Node? node = parser.get_root ();

if ( node == null ) return; // No favorites store

Json.Array array = node.get_array (); // Json-CRITICAL **: 21:02:51.821: json_node_get_array: assertion 'JSON_NODE_IS_VALID (node)' failed
array.foreach_element ((a, i, elem) => { // json_array_foreach_element: assertion 'array != NULL' failed
Station station = Json.gobject_deserialize (typeof (Station), elem) as Station;
// TODO This should probably not be here but in
// DirectoryController
Expand All @@ -88,8 +96,8 @@ public class StationStore : Object {
var data = serialize ();

try {
_data_file.delete ();
var stream = _data_file.create (
_favorites_file.delete ();
var stream = _favorites_file.create (
FileCreateFlags.REPLACE_DESTINATION | FileCreateFlags.PRIVATE
);
var s = new DataOutputStream (stream);
Expand Down Expand Up @@ -130,4 +138,4 @@ public class StationStore : Object {
}
}

}
}
Loading

0 comments on commit ad594a4

Please sign in to comment.