Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client systray support #565

Merged
merged 36 commits into from
May 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7d9bb03
client: Add support for running as a system tray process with icon
Jan 18, 2019
10c7e0f
systray: Use QtConcurrent instead of std::thread
Jan 24, 2019
8c88bfa
systray: Add start & stop functionality
Jan 25, 2019
4890b69
systray: Add support for starting multipass shell terminal
Jan 28, 2019
814f206
systray: Support "suspend" action
Jan 28, 2019
a204222
systray: Add systray icon as a Qt resource
Jan 28, 2019
f5d3396
snap: Add support for building client with systray UI
Jan 29, 2019
64e9917
client: Update copyright date where appropriate
Jan 29, 2019
8112202
snap: Pull in xterm to use for the systray "Open shell" function
Feb 1, 2019
3c4ca5f
systray: Changes based on review feedback
Feb 5, 2019
b0b411a
completions: Add 'systray' command
Feb 5, 2019
cb0c484
completions: Revert 'systray' command
Feb 6, 2019
c00ac73
client: Revert adding the "systray" command to the cli client
Feb 6, 2019
00153fb
systray: Move systray support into its client binary
Feb 6, 2019
41eaec0
snap: Add the GUI application and additional dependency
Feb 7, 2019
95f247e
client: Put make_channel() under common source for clients to use
Feb 7, 2019
e12f2e7
gui: Cleanup of files
Feb 7, 2019
fe2df79
gui_cmd: Add minimal ArgParser class and not use the cli ArgParser
Feb 7, 2019
d83092e
client/cli: Organize files under a 'cli' directory
Feb 8, 2019
a31efa7
client: More refactoring and clean up
Feb 8, 2019
2322128
client/gui: Small changes based on review feedback
Feb 8, 2019
e397a77
snap: Add desktop file and icon for the GUI
Feb 8, 2019
03662c5
client/gui: Add polling timer to check for instance state changes
Feb 20, 2019
3328441
gui: Move unused virtual function definitions to header file
Feb 20, 2019
ed02171
gui: Clean up code a bit
Feb 21, 2019
11bfdfe
gui: Remove 'Start' action since 'shell' now automatically starts ins…
Mar 5, 2019
7da14c6
gui: Fix build failures and issues with last rebase on master
Apr 17, 2019
ded78f1
clang: Revert all irrelevant clang formatting to make review easier
Apr 17, 2019
b007ea7
ci: Freshen the Coverage patch
Apr 18, 2019
0782fdb
build: Fix build failure due to bad merge in last rebase on master
Apr 19, 2019
9963a50
gui: Support retrieving and displaying version and update available
Apr 22, 2019
4f70eaa
client: Use lower case letters in instance status strings
May 7, 2019
c9de357
gui: Use new Multipass icon
May 8, 2019
c35516f
gui: Changes based on review feedback
May 10, 2019
eeacb2f
gui: Add explicit "Start" action when instance is stopped
May 13, 2019
ccea4d9
[gui] rename target to multipass_gui
Saviq May 13, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright © 2017-2018 Canonical Ltd.
# Copyright © 2017-2019 Canonical Ltd.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
Expand All @@ -11,8 +11,6 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Authored by: Alberto Aguirre <[email protected]>

cmake_minimum_required(VERSION 3.1)

Expand Down Expand Up @@ -44,8 +42,7 @@ endif()
add_subdirectory(3rd-party)

# Qt config
find_package(Qt5Core REQUIRED)
find_package(Qt5Network REQUIRED)
find_package(Qt5 COMPONENTS Core Network Widgets REQUIRED)

function(determine_version OUTPUT_VARIABLE)
execute_process(COMMAND git describe --exact
Expand Down
50 changes: 50 additions & 0 deletions include/multipass/cli/client_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (C) 2019 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

#ifndef MULTIPASS_CLIENT_COMMON_H
#define MULTIPASS_CLIENT_COMMON_H

#include <grpcpp/grpcpp.h>

#include <multipass/cert_provider.h>
#include <multipass/cli/return_codes.h>
#include <multipass/rpc/multipass.grpc.pb.h>
#include <multipass/rpc_connection_type.h>
#include <multipass/ssl_cert_provider.h>

#include <memory>
#include <string>

namespace multipass
{
namespace cmd
{
multipass::ReturnCode standard_failure_handler_for(const std::string& command, std::ostream& cerr,
const grpc::Status& status,
const std::string& error_details = std::string());
bool update_available(const UpdateInfo& update_info);
}

namespace client
{
std::shared_ptr<grpc::Channel> make_channel(const std::string& server_address, RpcConnectionType conn_type,
CertProvider& cert_provider);
std::string get_server_address();
std::unique_ptr<SSLCertProvider> get_cert_provider();
}
} // namespace multipass
#endif // MULTIPASS_CLIENT_COMMON_H
1 change: 1 addition & 0 deletions include/multipass/cli/client_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ namespace platform
void parse_transfer_entry(const QString& entry, QString& path, QString& instance_name);
int getuid();
int getgid();
void open_multipass_shell(const QString& instance_name);
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions include/multipass/cli/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ class Command
{
public:
using UPtr = std::unique_ptr<Command>;
Command(grpc::Channel& channel, Rpc::Stub& stub, std::ostream& cout, std::ostream& cerr)
: rpc_channel{&channel}, stub{&stub}, cout{cout}, cerr{cerr}
{
}

Command(grpc::Channel& channel, Rpc::Stub& stub, Terminal* term)
: rpc_channel{&channel}, stub{&stub}, term{term}, cout{term->cout()}, cerr{term->cerr()}
{
Expand Down
8 changes: 8 additions & 0 deletions snap/gui/multipass-gui.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Desktop Entry]
Name=Multipass
Exec=multipass.gui
Icon=/snap/multipass/current/meta/gui/multipass-gui.png
Type=Application
Terminal=false
Categories=Utility;

Binary file added snap/gui/multipass-gui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 74 additions & 0 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ apps:
QT_PLUGIN_PATH: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/qt5/plugins
command: bin/multipass
completer: etc/bash_completion.d/snap.multipass
gui:
environment:
LD_LIBRARY_PATH: $SNAP/lib:$SNAP/lib/$SNAPCRAFT_ARCH_TRIPLET:$SNAP/usr/lib:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET
PATH: $SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH
QT_PLUGIN_PATH: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/qt5/plugins
command: bin/multipass-gui
libvirt-bin:
command: bin/launch-libvirtd
environment:
Expand Down Expand Up @@ -117,6 +123,26 @@ parts:
stage-packages:
- libproxy1v5

libqt5gui5:
plugin: dump
source:
- on amd64: http://archive.ubuntu.com/ubuntu/pool/main/q/qtbase-opensource-src/libqt5gui5_5.9.5+dfsg-0ubuntu1_amd64.deb
- on i386: http://archive.ubuntu.com/ubuntu/pool/main/q/qtbase-opensource-src/libqt5gui5_5.9.5+dfsg-0ubuntu1_i386.deb
- on armhf: http://ports.ubuntu.com/ubuntu-ports/pool/main/q/qtbase-opensource-src/libqt5gui5_5.9.5+dfsg-0ubuntu1_armhf.deb
- on arm64: http://ports.ubuntu.com/ubuntu-ports/pool/main/q/qtbase-opensource-src/libqt5gui5_5.9.5+dfsg-0ubuntu1_arm64.deb
source-type: deb
stage-packages:
- mesa-common-dev

libqt5widgets5:
plugin: dump
source:
- on amd64: http://archive.ubuntu.com/ubuntu/pool/main/q/qtbase-opensource-src/libqt5widgets5_5.9.5+dfsg-0ubuntu1_amd64.deb
- on i386: http://archive.ubuntu.com/ubuntu/pool/main/q/qtbase-opensource-src/libqt5widgets5_5.9.5+dfsg-0ubuntu1_i386.deb
- on armhf: http://ports.ubuntu.com/ubuntu-ports/pool/main/q/qtbase-opensource-src/libqt5widgets5_5.9.5+dfsg-0ubuntu1_armhf.deb
- on arm64: http://ports.ubuntu.com/ubuntu-ports/pool/main/q/qtbase-opensource-src/libqt5widgets5_5.9.5+dfsg-0ubuntu1_arm64.deb
source-type: deb

libicu:
plugin: dump
source:
Expand All @@ -133,6 +159,34 @@ parts:
- on i386: http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.0g-2ubuntu4.3_i386.deb
- on armhf: http://ports.ubuntu.com/ubuntu-ports/pool/main/o/openssl/libssl1.1_1.1.0g-2ubuntu4.3_armhf.deb
- on arm64: http://ports.ubuntu.com/ubuntu-ports/pool/main/o/openssl/libssl1.1_1.1.0g-2ubuntu4.3_arm64.deb

libharfbuzz0b:
plugin: dump
source:
- on amd64: http://archive.ubuntu.com/ubuntu/pool/main/h/harfbuzz/libharfbuzz0b_1.7.2-1ubuntu1_amd64.deb
- on i386: http://archive.ubuntu.com/ubuntu/pool/main/h/harfbuzz/libharfbuzz0b_1.7.2-1ubuntu1_i386.deb
- on armhf: http://ports.ubuntu.com/ubuntu-ports/pool/main/h/harfbuzz/libharfbuzz0b_1.7.2-1ubuntu1_armhf.deb
- on arm64: http://ports.ubuntu.com/ubuntu-ports/pool/main/h/harfbuzz/libharfbuzz0b_1.7.2-1ubuntu1_arm64.deb
source-type: deb
stage-packages:
- libgraphite2-3

libfreetype6:
plugin: dump
source:
- on amd64: http://archive.ubuntu.com/ubuntu/pool/main/f/freetype/libfreetype6_2.8.1-2ubuntu2_amd64.deb
- on i386: http://archive.ubuntu.com/ubuntu/pool/main/f/freetype/libfreetype6_2.8.1-2ubuntu2_i386.deb
- on armhf: http://ports.ubuntu.com/ubuntu-ports/pool/main/f/freetype/libfreetype6_2.8.1-2ubuntu2_armhf.deb
- on arm64: http://ports.ubuntu.com/ubuntu-ports/pool/main/f/freetype/libfreetype6_2.8.1-2ubuntu2_arm64.deb
source-type: deb

libxcb-xinerama0:
plugin: dump
source:
- on amd64: http://archive.ubuntu.com/ubuntu/pool/main/libx/libxcb/libxcb-xinerama0_1.11.1-1ubuntu1_amd64.deb
- on i386: http://archive.ubuntu.com/ubuntu/pool/main/libx/libxcb/libxcb-xinerama0_1.11.1-1ubuntu1_i386.deb
- on armhf: http://archive.ubuntu.com/ubuntu/pool/main/libx/libxcb/libxcb-xinerama0_1.11.1-1ubuntu1_armhf.deb
- on arm64: http://archive.ubuntu.com/ubuntu/pool/main/libx/libxcb/libxcb-xinerama0_1.11.1-1ubuntu1_arm64.deb
source-type: deb

multipass:
Expand All @@ -141,14 +195,22 @@ parts:
- qtbase5-dev-tools
- libqt5core5a
- libqt5network5
- libqt5gui5
- libqt5widgets5
- libharfbuzz0b
- libfreetype6
- libvirt
- libxcb-xinerama0
plugin: cmake
build-packages:
- build-essential
- cmake-extras
- git
- golang
- libsystemd-dev
stage-packages:
- libgl1
- libpng16-16
source: .
configflags:
- -DCMAKE_BUILD_TYPE=RelWithDebInfo
Expand Down Expand Up @@ -265,6 +327,18 @@ parts:
- iputils-ping
- libatm1

xterm:
plugin: nil
override-pull: ""
stage-packages:
- xterm
stage:
- -usr/lib/x86_64-linux-gnu/libfreetype.so.6
- -usr/share/doc/libfreetype6/FTL.TXT.gz
- -usr/share/doc/libfreetype6/TODO
- -usr/share/doc/libfreetype6/changelog.Debian.gz
- -usr/share/doc/libfreetype6/pcf/README

glue:
plugin: dump
source: snap-wrappers
32 changes: 4 additions & 28 deletions src/client/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright © 2017 Canonical Ltd.
# Copyright © 2017-2019 Canonical Ltd.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
Expand All @@ -11,31 +11,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Authored by: Alberto Aguirre <[email protected]>

add_library(client STATIC
argparser.cpp
client.cpp)

target_link_libraries(client
cert
commands
fmt
formatter
platform
rpc
Qt5::Core)

add_executable(multipass
main.cpp)

target_link_libraries(multipass
client)

install(TARGETS multipass
DESTINATION bin
COMPONENT multipass)

add_subdirectory(cmd)
add_subdirectory(formatter)
add_subdirectory(cli)
add_subdirectory(common)
add_subdirectory(gui)
37 changes: 37 additions & 0 deletions src/client/cli/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright © 2017-2019 Canonical Ltd.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

add_library(client STATIC
argparser.cpp
client.cpp)

target_link_libraries(client
commands
fmt
formatter
rpc
Qt5::Core)

add_executable(multipass
main.cpp)

target_link_libraries(multipass
client)

install(TARGETS multipass
DESTINATION bin
COMPONENT multipass)

add_subdirectory(cmd)
add_subdirectory(formatter)
File renamed without changes.
32 changes: 3 additions & 29 deletions src/client/client.cpp → src/client/cli/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Alberto Aguirre <[email protected]>
*
*/

#include "client.h"
#include "cmd/delete.h"
#include "cmd/exec.h"
Expand All @@ -40,42 +39,17 @@

#include <algorithm>

#include <multipass/cert_provider.h>
#include <multipass/cli/argparser.h>
#include <multipass/cli/client_common.h>
#include <multipass/logging/log.h>
#include <multipass/logging/standard_logger.h>

namespace mp = multipass;
namespace mpl = multipass::logging;

namespace
{
auto make_channel(const std::string& server_address, mp::RpcConnectionType conn_type, mp::CertProvider& cert_provider)
{
std::shared_ptr<grpc::ChannelCredentials> creds;
if (conn_type == mp::RpcConnectionType::ssl)
{
auto opts = grpc::SslCredentialsOptions();
opts.server_certificate_request = GRPC_SSL_REQUEST_SERVER_CERTIFICATE_BUT_DONT_VERIFY;
opts.pem_cert_chain = cert_provider.PEM_certificate();
opts.pem_private_key = cert_provider.PEM_signing_key();
creds = grpc::SslCredentials(opts);
}
else if (conn_type == mp::RpcConnectionType::insecure)
{
creds = grpc::InsecureChannelCredentials();
}
else
{
throw std::runtime_error("Unknown connection type");
}
return grpc::CreateChannel(server_address, creds);
}
} // namespace

mp::Client::Client(ClientConfig& config)
: cert_provider{std::move(config.cert_provider)},
rpc_channel{make_channel(config.server_address, config.conn_type, *cert_provider)},
rpc_channel{mp::client::make_channel(config.server_address, config.conn_type, *cert_provider)},
stub{mp::Rpc::NewStub(rpc_channel)},
term{config.term}
{
Expand Down
3 changes: 1 addition & 2 deletions src/client/client.h → src/client/cli/client.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017 Canonical, Ltd.
* Copyright (C) 2017-2019 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -20,7 +20,6 @@

#include <multipass/cert_provider.h>
#include <multipass/terminal.h>
#include <multipass/cli/cli.h>
#include <multipass/cli/command.h>
#include <multipass/rpc/multipass.grpc.pb.h>
#include <multipass/rpc_connection_type.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Authored by: Alberto Aguirre <[email protected]>

add_library(commands STATIC
animated_spinner.cpp
Expand All @@ -39,6 +37,7 @@ add_library(commands STATIC
${PLATFORM_COMMANDS})

target_link_libraries(commands
client_common
client_platform
scp_client
ssh_client
Expand Down
Loading