~townsend/libertine/1.4.3-release

« back to all changes in this revision

Viewing changes to liblibertine/libertine.cpp

  • Committer: Chris Townsend
  • Author(s): Chris Townsend, Larry Price, Stephen M. Webb
  • Date: 2016-10-31 17:20:44 UTC
  • mfrom: (94.157.50 devel)
  • Revision ID: christopher.townsend@canonical.com-20161031172044-74b8604iab6nw1t2
* Use libertine-lxc-manager when starting/stopping a container for libertine-container-manager operations if the session DBus is available.  If not, fallback to l-c-m starting/stopping the container. (LP: #1628587)
* Add a new entry to ContainersConfig for keeping track of running processes in a container. (LP: #1632729)
* libertine-launch: refactored core components of application session management.
* Split out Xmir helper apps into their own package.
* Add support for starting pasted and matchbox for snap based/ containerless apps in U8. (LP: #1637535)
* Add implementation for libertine gui as a system-settings plugin. (LP: #1623946)
* Manually require archive name during archive configuration.
* Add a warning to the top of ContainersConfig.json advising users not to edit the file.
* Missing error dialogs in PackageInfoView when fetching version results in an error.
* Avoid searching for apps based on empty directories.
* Bump version to 1.4.3. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
19
 */
20
20
#include "liblibertine/libertine.h"
21
 
#include "libertine/ContainerConfigList.h"
22
 
#include "libertine/LibertineConfig.h"
 
21
 
 
22
#include "common/ContainerConfigList.h"
 
23
#include "common/LibertineConfig.h"
23
24
 
24
25
 
25
26
namespace
77
78
  GError* error = nullptr;
78
79
  GArray* apps = g_array_new(TRUE, TRUE, sizeof(gchar*));
79
80
 
80
 
  auto globalPath = g_build_filename("/", g_strdup(path), GLOBAL_APPLICATIONS, nullptr);
81
 
  error = list_apps_from_path(globalPath, container_id, apps);
82
 
  if (error != nullptr)
 
81
  if (path != nullptr)
83
82
  {
84
 
    g_free(globalPath);
85
 
    g_free(path);
86
 
    g_error_free(error);
87
 
    return (gchar**)g_array_free(apps, FALSE);
 
83
      auto global_path = g_build_filename("/", g_strdup(path), GLOBAL_APPLICATIONS, nullptr);
 
84
      error = list_apps_from_path(global_path, container_id, apps);
 
85
      if (error != nullptr)
 
86
      {
 
87
        g_free(global_path);
 
88
        g_free(path);
 
89
        g_error_free(error);
 
90
        return (gchar**)g_array_free(apps, FALSE);
 
91
      }
 
92
      g_free(global_path);
88
93
  }
89
 
  g_free(globalPath);
 
94
  g_free(path);
90
95
 
91
96
  auto home_path = libertine_container_home_path(container_id);
92
 
  auto local_path = g_build_filename(home_path, LOCAL_APPLICATIONS, nullptr);
 
97
  if (home_path != nullptr)
 
98
  {
 
99
      auto local_path = g_build_filename(home_path, LOCAL_APPLICATIONS, nullptr);
 
100
 
 
101
      error = list_apps_from_path(local_path, container_id, apps);
 
102
      if (error != nullptr)
 
103
      {
 
104
        g_error_free(error); // free error, but return previously found apps
 
105
      }
 
106
      g_free(local_path);
 
107
  }
93
108
  g_free(home_path);
94
109
 
95
 
  error = list_apps_from_path(local_path, container_id, apps);
96
 
  if (error != nullptr)
97
 
  {
98
 
    g_error_free(error); // free error, but return previously found apps
99
 
  }
100
 
  g_free(local_path);
101
 
 
102
 
  g_free(path);
103
110
  return (gchar**)g_array_free(apps, FALSE);
104
111
}
105
112
 
130
137
gchar *
131
138
libertine_container_path(const gchar * container_id)
132
139
{
133
 
  gchar * path = NULL;
134
 
  g_return_val_if_fail(container_id != NULL, NULL);
 
140
  gchar * path = nullptr;
 
141
  g_return_val_if_fail(container_id != nullptr, nullptr);
135
142
 
136
 
  path = g_build_filename(g_get_user_cache_dir(), "libertine-container", container_id, "rootfs", NULL);
 
143
  path = g_build_filename(g_get_user_cache_dir(), "libertine-container", container_id, "rootfs", nullptr);
137
144
 
138
145
  if (g_file_test(path, G_FILE_TEST_EXISTS))
139
146
  {
142
149
  else
143
150
  {
144
151
    g_free(path);
145
 
    return NULL;
 
152
    return nullptr;
146
153
  }
147
154
}
148
155
 
150
157
gchar *
151
158
libertine_container_home_path(const gchar * container_id)
152
159
{
153
 
  gchar * path = NULL;
154
 
  g_return_val_if_fail(container_id != NULL, NULL);
 
160
  gchar * path = nullptr;
 
161
  g_return_val_if_fail(container_id != nullptr, nullptr);
155
162
 
156
 
  path = g_build_filename(g_get_user_data_dir(), "libertine-container", "user-data", container_id, NULL);
 
163
  path = g_build_filename(g_get_user_data_dir(), "libertine-container", "user-data", container_id, nullptr);
157
164
 
158
165
  if (g_file_test(path, G_FILE_TEST_EXISTS))
159
166
  {
162
169
  else
163
170
  {
164
171
    g_free(path);
165
 
    return NULL;
 
172
    return nullptr;
166
173
  }
167
174
 
168
175
}
173
180
{
174
181
  guint container_count;
175
182
  guint i;
176
 
  gchar * container_name = NULL;
 
183
  gchar * container_name = nullptr;
177
184
  LibertineConfig config;
178
185
  ContainerConfigList container_list(&config);
179
186
  QVariant id;