prepare v2.2

This commit is contained in:
guinux
2015-03-04 15:55:36 +01:00
parent aea3a143d7
commit eb9ace7b82
89 changed files with 3038 additions and 1696 deletions

View File

@@ -2,20 +2,23 @@
COMMON_VALA_FLAGS = --fatal-warnings \
--pkg=libalpm \
--pkg=gio-2.0 \
--pkg=posix \
--pkg=json-glib-1.0 \
--pkg=libsoup-2.4 \
--vapidir=../vapi \
--Xcc=-I../util \
-X -D_FILE_OFFSET_BITS=64 \
-X -DGETTEXT_PACKAGE="pamac" \
--target-glib=2.38
TRANSACTION_VALA_FLAGS = --pkg=json-glib-1.0 \
--pkg=gtk+-3.0 \
--pkg=gmodule-2.0 \
--pkg=gdk-3.0 \
--pkg=vte-2.91
COMMON_SOURCES = ../util/alpm-util.c \
alpm_config.vala \
common.vala \
pamac_config.vala \
aur.vala \
common.vala
mirrors_config.vala \
package.vala \
MANAGER_GRESOURCE_FILE = ../resources/pamac.manager.gresource.xml
@@ -23,11 +26,12 @@ UPDATER_GRESOURCE_FILE = ../resources/pamac.updater.gresource.xml
INSTALLER_GRESOURCE_FILE = ../resources/pamac.installer.gresource.xml
DIALOGS_FILES = choose_provider_dialog.vala \
transaction_sum_dialog.vala \
transaction_info_dialog.vala \
preferences_dialog.vala \
progress_dialog.vala
TRANSACTION_SOURCES = transaction.vala \
choose_provider_dialog.vala \
transaction_sum_dialog.vala \
transaction_info_dialog.vala \
preferences_dialog.vala \
progress_dialog.vala
binaries: pamac-refresh pamac-daemon pamac-tray pamac-updater pamac-manager pamac-install
@@ -39,69 +43,62 @@ pamac-refresh: refresh.vala
--pkg=gio-2.0 \
refresh.vala
pamac-daemon: ../vapi/libalpm.vapi ../vapi/polkit-gobject-1.vapi $(COMMON_SOURCES) mirrors_config.vala daemon.vala
pamac-tray: common.vala pamac_config.vala tray.vala
valac -o pamac-tray \
--pkg=gio-2.0 \
--pkg=gtk+-3.0 \
--pkg=libnotify \
-X -DGETTEXT_PACKAGE="pamac" \
common.vala \
pamac_config.vala \
tray.vala
pamac-daemon: ../vapi/libalpm.vapi ../vapi/polkit-gobject-1.vapi $(COMMON_SOURCES) alpm_config.vala alpm_utils.vala aur.vala daemon.vala
valac -o pamac-daemon \
$(COMMON_VALA_FLAGS) \
--pkg=posix \
--pkg=json-glib-1.0 \
--pkg=libsoup-2.4 \
--pkg=polkit-gobject-1 \
--thread \
$(COMMON_SOURCES) \
mirrors_config.vala \
alpm_config.vala \
aur.vala \
alpm_utils.vala \
daemon.vala
pamac-tray: ../vapi/libalpm.vapi $(COMMON_SOURCES) tray.vala
valac -o pamac-tray \
$(COMMON_VALA_FLAGS) \
--pkg=gtk+-3.0 \
--pkg=libnotify \
$(COMMON_SOURCES) \
tray.vala
pamac-manager: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(DIALOGS_FILES) choose_dep_dialog.vala history_dialog.vala packages_chooser_dialog.vala ../resources/manager_resources.c package.vala mirrors_config.vala transaction.vala packages_model.vala manager_window.vala manager.vala
pamac-manager: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(TRANSACTION_SOURCES) choose_dep_dialog.vala history_dialog.vala packages_chooser_dialog.vala ../resources/manager_resources.c packages_model.vala manager_window.vala manager.vala
valac -o pamac-manager \
$(COMMON_VALA_FLAGS) \
--pkg=gtk+-3.0 \
--pkg=gmodule-2.0 \
--pkg=gdk-3.0 \
--pkg=vte-2.91 \
$(TRANSACTION_VALA_FLAGS) \
--gresources=$(MANAGER_GRESOURCE_FILE) \
$(COMMON_SOURCES) \
$(DIALOGS_FILES) \
$(TRANSACTION_SOURCES) \
choose_dep_dialog.vala \
history_dialog.vala \
packages_chooser_dialog.vala \
../resources/manager_resources.c \
package.vala \
mirrors_config.vala \
transaction.vala \
packages_model.vala \
manager_window.vala \
manager.vala
pamac-updater: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(DIALOGS_FILES) ../resources/updater_resources.c mirrors_config.vala transaction.vala updater_window.vala updater.vala
pamac-updater: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(TRANSACTION_SOURCES) ../resources/updater_resources.c updater_window.vala updater.vala
valac -o pamac-updater \
$(COMMON_VALA_FLAGS) \
--pkg=gtk+-3.0 \
--pkg=gmodule-2.0 \
--pkg=vte-2.91 \
$(TRANSACTION_VALA_FLAGS) \
--gresources=$(UPDATER_GRESOURCE_FILE) \
$(COMMON_SOURCES) \
$(DIALOGS_FILES) \
$(TRANSACTION_SOURCES) \
../resources/updater_resources.c \
mirrors_config.vala \
transaction.vala \
updater_window.vala \
updater.vala
pamac-install: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(DIALOGS_FILES) ../resources/installer_resources.c mirrors_config.vala transaction.vala installer.vala
pamac-install: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(TRANSACTION_SOURCES) ../resources/installer_resources.c installer.vala
valac -o pamac-install \
$(COMMON_VALA_FLAGS) \
--pkg=gtk+-3.0 \
--pkg=gmodule-2.0 \
--pkg=vte-2.91 \
$(TRANSACTION_VALA_FLAGS) \
--gresources=$(INSTALLER_GRESOURCE_FILE) \
$(COMMON_SOURCES) \
$(DIALOGS_FILES) \
$(TRANSACTION_SOURCES) \
../resources/installer_resources.c \
mirrors_config.vala \
transaction.vala \
installer.vala

View File

@@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014, 2015 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014-2015 Guillaume Benoit <guillaume@manjaro.org>
*
* 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
@@ -100,8 +100,9 @@ namespace Alpm {
public void get_handle () {
Alpm.Errno error;
if (handle != null)
if (handle != null) {
Handle.release (handle);
}
handle = Handle.new (rootdir, dbpath, out error);
if (handle == null) {
stderr.printf ("Failed to initialize alpm library" + " (%s)\n".printf(Alpm.strerror (error)));
@@ -127,12 +128,14 @@ namespace Alpm {
// register dbs
foreach (var repo in repo_order) {
unowned DB db = handle.register_syncdb (repo.name, repo.siglevel);
foreach (var url in repo.urls)
foreach (var url in repo.urls) {
db.add_server (url.replace ("$repo", repo.name).replace ("$arch", handle.arch));
if (repo.usage == 0)
}
if (repo.usage == 0) {
db.usage = DB.Usage.ALL;
else
} else {
db.usage = repo.usage;
}
}
}
@@ -149,11 +152,15 @@ namespace Alpm {
string line;
// Read lines until end of file (null) is reached
while ((line = dis.read_line (null)) != null) {
if (line.length == 0) continue;
if (line.length == 0) {
continue;
}
// ignore whole line and end of line comments
string[] splitted = line.split ("#", 2);
line = splitted[0].strip ();
if (line.length == 0) continue;
if (line.length == 0) {
continue;
}
if (line[0] == '[' && line[line.length-1] == ']') {
current_section = line[1:-1];
if (current_section != "options") {
@@ -165,67 +172,79 @@ namespace Alpm {
splitted = line.split ("=", 2);
string _key = splitted[0].strip ();
string? _value = null;
if (splitted[1] != null)
if (splitted[1] != null) {
_value = splitted[1].strip ();
if (_key == "Include")
}
if (_key == "Include") {
parse_file (_value, current_section);
}
if (current_section == "options") {
if (_key == "GPGDir")
if (_key == "GPGDir") {
gpgdir = _value;
else if (_key == "LogFile")
} else if (_key == "LogFile") {
logfile = _value;
else if (_key == "Architecture") {
if (_value == "auto")
} else if (_key == "Architecture") {
if (_value == "auto") {
arch = Posix.utsname ().machine;
else
} else {
arch = _value;
} else if (_key == "UseDelta")
}
} else if (_key == "UseDelta") {
deltaratio = double.parse (_value);
else if (_key == "UseSysLog")
} else if (_key == "UseSysLog") {
usesyslog = 1;
else if (_key == "CheckSpace")
} else if (_key == "CheckSpace") {
checkspace = 1;
else if (_key == "SigLevel")
} else if (_key == "SigLevel") {
defaultsiglevel = define_siglevel (defaultsiglevel, _value);
else if (_key == "LocalFileSigLevel")
} else if (_key == "LocalFileSigLevel") {
localfilesiglevel = define_siglevel (localfilesiglevel, _value);
else if (_key == "RemoteFileSigLevel")
} else if (_key == "RemoteFileSigLevel") {
remotefilesiglevel = define_siglevel (remotefilesiglevel, _value);
else if (_key == "HoldPkg") {
foreach (string name in _value.split (" "))
} else if (_key == "HoldPkg") {
foreach (string name in _value.split (" ")) {
holdpkgs.append (name);
}
} else if (_key == "SyncFirst") {
syncfirst = _value;
foreach (string name in _value.split (" "))
foreach (string name in _value.split (" ")) {
syncfirsts.append (name);
}
} else if (_key == "CacheDir") {
foreach (string dir in _value.split (" "))
foreach (string dir in _value.split (" ")) {
cachedirs->add_str (dir);
}
} else if (_key == "IgnoreGroup") {
foreach (string name in _value.split (" "))
foreach (string name in _value.split (" ")) {
ignoregroups->add_str (name);
}
} else if (_key == "IgnorePkg") {
ignorepkg = _value;
foreach (string name in _value.split (" "))
foreach (string name in _value.split (" ")) {
ignorepkgs->add_str (name);
}
} else if (_key == "Noextract") {
foreach (string name in _value.split (" "))
foreach (string name in _value.split (" ")) {
noextracts->add_str (name);
}
} else if (_key == "NoUpgrade") {
foreach (string name in _value.split (" "))
foreach (string name in _value.split (" ")) {
noupgrades->add_str (name);
}
}
} else {
foreach (var repo in repo_order) {
if (repo.name == current_section) {
if (_key == "Server")
if (_key == "Server") {
repo.urls += _value;
else if (_key == "SigLevel") {
if (repo.siglevel == Signature.Level.USE_DEFAULT)
} else if (_key == "SigLevel") {
if (repo.siglevel == Signature.Level.USE_DEFAULT) {
repo.siglevel = defaultsiglevel;
}
repo.siglevel = define_siglevel (repo.siglevel, _value);
} else if (_key == "Usage")
} else if (_key == "Usage") {
repo.usage = define_usage (_value);
}
}
}
}
@@ -238,9 +257,9 @@ namespace Alpm {
public void write (HashTable<string,Variant> new_conf) {
var file = GLib.File.new_for_path (conf_path);
if (file.query_exists () == false)
if (file.query_exists () == false) {
GLib.stderr.printf ("File '%s' doesn't exist.\n", conf_path);
else {
} else {
try {
// Open file for reading and wrap returned FileInputStream into a
// DataInputStream, so we can read line by line
@@ -256,32 +275,39 @@ namespace Alpm {
if (line.contains ("IgnorePkg")) {
if (new_conf.contains ("IgnorePkg")) {
string _value = new_conf.get ("IgnorePkg").get_string ();
if (_value == "")
if (_value == "") {
data += "#IgnorePkg =\n";
else
} else {
data += "IgnorePkg = %s\n".printf (_value);
} else
}
} else {
data += line + "\n";
}
} else if (line.contains ("SyncFirst")) {
if (new_conf.contains ("SyncFirst")) {
string _value = new_conf.get ("SyncFirst").get_string ();
if (_value == "")
if (_value == "") {
data += "#SyncFirst =\n";
else
} else {
data += "SyncFirst = %s\n".printf (_value);
} else
}
} else {
data += line + "\n";
}
} else if (line.contains ("CheckSpace")) {
if (new_conf.contains ("CheckSpace")) {
int _value = new_conf.get ("CheckSpace").get_int32 ();
if (_value == 1)
bool _value = new_conf.get ("CheckSpace").get_boolean ();
if (_value == true) {
data += "CheckSpace\n";
else
} else {
data += "#CheckSpace\n";
} else
}
} else {
data += line + "\n";
} else
}
} else {
data += line + "\n";
}
}
// delete the file before rewrite it
file.delete ();
@@ -319,11 +345,11 @@ namespace Alpm {
foreach (string directive in conf_string.split(" ")) {
bool affect_package = false;
bool affect_database = false;
if ("Package" in directive)
if ("Package" in directive) {
affect_package = true;
else if ("Database" in directive)
} else if ("Database" in directive) {
affect_database = true;
else {
} else {
affect_package = true;
affect_database = true;
}
@@ -332,8 +358,9 @@ namespace Alpm {
default_level &= ~Signature.Level.PACKAGE;
default_level |= Signature.Level.PACKAGE_SET;
}
if (affect_database)
if (affect_database) {
default_level &= ~Signature.Level.DATABASE;
}
} else if ("Optional" in directive) {
if (affect_package) {
default_level |= Signature.Level.PACKAGE;
@@ -374,9 +401,9 @@ namespace Alpm {
default_level |= Signature.Level.DATABASE_MARGINAL_OK;
default_level |= Signature.Level.DATABASE_UNKNOWN_OK;
}
}
else
} else {
GLib.stderr.printf("unrecognized siglevel: %s\n", conf_string);
}
}
default_level &= ~Signature.Level.USE_DEFAULT;
return default_level;

75
src/alpm_utils.vala Normal file
View File

@@ -0,0 +1,75 @@
/*
* pamac-vala
*
* Copyright (C) 2015 Guillaume Benoit <guillaume@manjaro.org>
*
* 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; either version 3 of the License, or
* (at your option) any later version.
*
* 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 get of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
public int pkgcmp (Alpm.Package pkg1, Alpm.Package pkg2) {
return strcmp (pkg1.name, pkg2.name);
}
public Alpm.List<unowned Alpm.Package?> search_all_dbs (Alpm.Handle handle, Alpm.List<string?> needles) {
var syncpkgs = new Alpm.List<unowned Alpm.Package?> ();
var result = handle.localdb.search (needles);
foreach (var db in handle.syncdbs) {
if (syncpkgs.length == 0)
syncpkgs = db.search (needles);
else {
syncpkgs.join (db.search (needles).diff (syncpkgs, (Alpm.List.CompareFunc) pkgcmp));
}
}
result.join (syncpkgs.diff (result, (Alpm.List.CompareFunc) pkgcmp));
//result.sort ((Alpm.List.CompareFunc) pkgcmp);
return result;
}
public Alpm.List<unowned Alpm.Package?> group_pkgs (Alpm.Handle handle, string grp_name) {
var result = new Alpm.List<unowned Alpm.Package?> ();
unowned Alpm.Group? grp = handle.localdb.get_group (grp_name);
if (grp != null) {
foreach (var pkg in grp.packages)
result.add (pkg);
}
result.join (Alpm.find_group_pkgs (handle.syncdbs, grp_name).diff (result, (Alpm.List.CompareFunc) pkgcmp));
//result.sort ((Alpm.List.CompareFunc) pkgcmp);
return result;
}
public Alpm.List<unowned Alpm.Package?> all_pkgs (Alpm.Handle handle) {
var syncpkgs = new Alpm.List<unowned Alpm.Package?> ();
var result = new Alpm.List<unowned Alpm.Package?> ();
result = handle.localdb.pkgcache.copy ();
foreach (var db in handle.syncdbs) {
if (syncpkgs.length == 0)
syncpkgs = db.pkgcache.copy ();
else {
syncpkgs.join (db.pkgcache.diff (syncpkgs, (Alpm.List.CompareFunc) pkgcmp));
}
}
result.join (syncpkgs.diff (result, (Alpm.List.CompareFunc) pkgcmp));
//result.sort ((Alpm.List.CompareFunc) pkgcmp);
return result;
}

View File

@@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014-2015 Guillaume Benoit <guillaume@manjaro.org>
*
* 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
@@ -41,11 +41,16 @@ namespace AUR {
}
unowned Json.Node? root = parser.get_root ();
if (root != null) {
prev_inter = root.get_object ().get_array_member ("results");
if (root.get_object ().get_string_member ("type") == "error") {
stderr.printf ("Failed to search %s from AUR\n", needles[0]);
} else {
prev_inter = root.get_object ().get_array_member ("results");
}
}
int length = needles.length;
if (length == 1)
if (length == 1) {
return prev_inter;
}
int i = 1;
var inter = new Json.Array ();
var found = new Json.Array ();
@@ -61,7 +66,11 @@ namespace AUR {
}
root = parser.get_root ();
if (root != null) {
found = root.get_object ().get_array_member ("results");
if (root.get_object ().get_string_member ("type") == "error") {
stderr.printf ("Failed to search %s from AUR\n", needles[i]);
} else {
found = root.get_object ().get_array_member ("results");
}
}
foreach (var prev_inter_node in prev_inter.get_elements ()) {
foreach (var found_node in found.get_elements ()) {
@@ -94,7 +103,11 @@ namespace AUR {
}
unowned Json.Node? root = parser.get_root ();
if (root != null) {
pkg_info = root.get_object ().get_object_member ("results");
if (root.get_object ().get_string_member ("type") == "error") {
stderr.printf ("Failed to get infos about %s from AUR\n", pkgname);
} else {
pkg_info = root.get_object ().get_object_member ("results");
}
}
return pkg_info;
}
@@ -119,7 +132,11 @@ namespace AUR {
}
unowned Json.Node? root = parser.get_root ();
if (root != null) {
results = root.get_object ().get_array_member ("results");
if (root.get_object ().get_string_member ("type") == "error") {
stderr.printf ("Failed to multiinfo %s from AUR\n", builder.str);
} else {
results = root.get_object ().get_array_member ("results");
}
}
return results;
}

View File

@@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
*
* 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

View File

@@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
*
* 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

View File

@@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014-2015 Guillaume Benoit <guillaume@manjaro.org>
*
* 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
@@ -18,7 +18,7 @@
*/
namespace Pamac {
public struct UpdatesInfos {
public struct UpdateInfos {
public string name;
public string version;
public string db_name;
@@ -26,6 +26,12 @@ namespace Pamac {
public uint64 download_size;
}
public struct Updates {
public bool is_syncfirst;
public UpdateInfos[] repos_updates;
public UpdateInfos[] aur_updates;
}
public enum Mode {
MANAGER,
UPDATER
@@ -51,161 +57,3 @@ public string format_size (uint64 size) {
return size_string;
}
}
public int pkgcmp (Alpm.Package pkg1, Alpm.Package pkg2) {
return strcmp (pkg1.name, pkg2.name);
}
public Alpm.List<unowned Alpm.Package?> search_all_dbs (Alpm.Handle handle, Alpm.List<string?> needles) {
var syncpkgs = new Alpm.List<unowned Alpm.Package?> ();
var result = handle.localdb.search (needles);
foreach (var db in handle.syncdbs) {
if (syncpkgs.length == 0)
syncpkgs = db.search (needles);
else {
syncpkgs.join (db.search (needles).diff (syncpkgs, (Alpm.List.CompareFunc) pkgcmp));
}
}
result.join (syncpkgs.diff (result, (Alpm.List.CompareFunc) pkgcmp));
//result.sort ((Alpm.List.CompareFunc) pkgcmp);
return result;
}
public Alpm.List<unowned Alpm.Package?> group_pkgs_all_dbs (Alpm.Handle handle, string grp_name) {
var result = new Alpm.List<unowned Alpm.Package?> ();
unowned Alpm.Group? grp = handle.localdb.get_group (grp_name);
if (grp != null) {
foreach (var pkg in grp.packages)
result.add (pkg);
}
result.join (Alpm.find_group_pkgs (handle.syncdbs, grp_name).diff (result, (Alpm.List.CompareFunc) pkgcmp));
//result.sort ((Alpm.List.CompareFunc) pkgcmp);
return result;
}
public Alpm.List<unowned Alpm.Package?> get_all_pkgs (Alpm.Handle handle) {
var syncpkgs = new Alpm.List<unowned Alpm.Package?> ();
var result = new Alpm.List<unowned Alpm.Package?> ();
result = handle.localdb.pkgcache.copy ();
foreach (var db in handle.syncdbs) {
if (syncpkgs.length == 0)
syncpkgs = db.pkgcache.copy ();
else {
syncpkgs.join (db.pkgcache.diff (syncpkgs, (Alpm.List.CompareFunc) pkgcmp));
}
}
result.join (syncpkgs.diff (result, (Alpm.List.CompareFunc) pkgcmp));
//result.sort ((Alpm.List.CompareFunc) pkgcmp);
return result;
}
public unowned Alpm.Package? get_syncpkg (Alpm.Handle handle, string name) {
unowned Alpm.Package? pkg = null;
foreach (var db in handle.syncdbs) {
pkg = db.get_pkg (name);
if (pkg != null)
break;
}
return pkg;
}
public Pamac.UpdatesInfos[] get_syncfirst_updates (Alpm.Handle handle, GLib.List<string> syncfirsts) {
Pamac.UpdatesInfos infos = Pamac.UpdatesInfos ();
Pamac.UpdatesInfos[] syncfirst_infos = {};
unowned Alpm.Package? pkg = null;
unowned Alpm.Package? candidate = null;
foreach (var name in syncfirsts) {
pkg = Alpm.find_satisfier (handle.localdb.pkgcache, name);
if (pkg != null) {
candidate = pkg.sync_newversion (handle.syncdbs);
if (candidate != null) {
infos.name = candidate.name;
infos.version = candidate.version;
infos.db_name = candidate.db.name;
infos.tarpath = "";
infos.download_size = candidate.download_size;
syncfirst_infos += infos;
}
}
}
return syncfirst_infos;
}
public Pamac.UpdatesInfos[] get_repos_updates (Alpm.Handle handle) {
unowned Alpm.Package? candidate = null;
Pamac.UpdatesInfos infos = Pamac.UpdatesInfos ();
Pamac.UpdatesInfos[] updates = {};
foreach (var local_pkg in handle.localdb.pkgcache) {
// continue only if the local pkg is not in IgnorePkg or IgnoreGroup
if (handle.should_ignore (local_pkg) == 0) {
candidate = local_pkg.sync_newversion (handle.syncdbs);
if (candidate != null) {
infos.name = candidate.name;
infos.version = candidate.version;
infos.db_name = candidate.db.name;
infos.tarpath = "";
infos.download_size = candidate.download_size;
updates += infos;
}
}
}
return updates;
}
public Pamac.UpdatesInfos[] get_aur_updates (Alpm.Handle handle) {
unowned Alpm.Package? sync_pkg = null;
unowned Alpm.Package? candidate = null;
string[] local_pkgs = {};
Pamac.UpdatesInfos infos = Pamac.UpdatesInfos ();
Pamac.UpdatesInfos[] aur_updates = {};
// get local pkgs
foreach (var local_pkg in handle.localdb.pkgcache) {
// continue only if the local pkg is not in IgnorePkg or IgnoreGroup
if (handle.should_ignore (local_pkg) == 0) {
// check updates from AUR only for local packages
foreach (var db in handle.syncdbs) {
sync_pkg = Alpm.find_satisfier (db.pkgcache, local_pkg.name);
if (sync_pkg != null)
break;
}
if (sync_pkg == null) {
// check update from AUR only if no package from dbs will replace it
candidate = local_pkg.sync_newversion (handle.syncdbs);
if (candidate == null) {
local_pkgs += local_pkg.name;
}
}
}
}
// get aur updates
var aur_pkgs = AUR.multiinfo (local_pkgs);
int cmp;
unowned Json.Object pkg_info;
string version;
string name;
foreach (var node in aur_pkgs.get_elements ()) {
pkg_info = node.get_object ();
version = pkg_info.get_string_member ("Version");
name = pkg_info.get_string_member ("Name");
cmp = Alpm.pkg_vercmp (version, handle.localdb.get_pkg (name).version);
if (cmp == 1) {
infos.name = name;
infos.version = version;
infos.db_name = "AUR";
infos.tarpath = pkg_info.get_string_member ("URLPath");
infos.download_size = 0;
aur_updates += infos;
}
}
return aur_updates;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
*
* 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

View File

@@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014-2015 Guillaume Benoit <guillaume@manjaro.org>
*
* 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
@@ -79,9 +79,9 @@ namespace Pamac {
stderr.printf ("%s\n", e.message);
}
run = app.get_is_remote ();
if (run)
if (run) {
return run;
else {
} else {
app = new Application ("org.manjaro.pamac.updater", 0);
try {
app.register ();

View File

@@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014-2015 Guillaume Benoit <guillaume@manjaro.org>
*
* 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
@@ -44,23 +44,26 @@ namespace Pamac {
transaction_info_dialog.expander.set_visible (false);
transaction_info_dialog.run ();
transaction_info_dialog.hide ();
} else
} else {
manager_window = new ManagerWindow (this);
}
}
public override void activate () {
if (pamac_run == false) {
manager_window.present ();
while (Gtk.events_pending ())
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
manager_window.show_all_pkgs ();
}
}
public override void shutdown () {
base.shutdown ();
if (pamac_run == false)
if (pamac_run == false) {
manager_window.transaction.stop_daemon ();
}
}
bool check_pamac_running () {
@@ -73,9 +76,9 @@ namespace Pamac {
stderr.printf ("%s\n", e.message);
}
run = app.get_is_remote ();
if (run)
if (run) {
return run;
else {
} else {
app = new Application ("org.manjaro.pamac.install", 0);
try {
app.register ();

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014-2015 Guillaume Benoit <guillaume@manjaro.org>
*
* 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
@@ -57,9 +57,9 @@ namespace Alpm {
public void parse_file (string path) {
var file = GLib.File.new_for_path (path);
if (file.query_exists () == false)
if (file.query_exists () == false) {
GLib.stderr.printf ("File '%s' doesn't exist.\n", path);
else {
} else {
try {
// Open file for reading and wrap returned FileInputStream into a
// DataInputStream, so we can read line by line
@@ -68,19 +68,25 @@ namespace Alpm {
// Read lines until end of file (null) is reached
while ((line = dis.read_line (null)) != null) {
line = line.strip ();
if (line.length == 0) continue;
if (line[0] == '#') continue;
if (line.length == 0) {
continue;
}
if (line[0] == '#') {
continue;
}
string[] splitted = line.split ("=");
string _key = splitted[0].strip ();
string _value = null;
if (splitted[1] != null)
if (splitted[1] != null) {
_value = splitted[1].strip ();
if (_key == "Method")
}
if (_key == "Method") {
choosen_generation_method = _value;
else if (_key == "OnlyCountry")
} else if (_key == "OnlyCountry") {
choosen_country = _value;
else if (_key == "MirrorlistsDir")
} else if (_key == "MirrorlistsDir") {
mirrorlists_dir = _value.replace ("\"", "");
}
}
} catch (Error e) {
GLib.stderr.printf("%s\n", e.message);
@@ -90,9 +96,9 @@ namespace Alpm {
public void write (HashTable<string,Variant> new_conf) {
var file = GLib.File.new_for_path (conf_path);
if (file.query_exists () == false)
if (file.query_exists () == false) {
GLib.stderr.printf ("File '%s' doesn't exist.\n", file.get_path ());
else {
} else {
try {
// Open file for reading and wrap returned FileInputStream into a
// DataInputStream, so we can read line by line
@@ -105,19 +111,23 @@ namespace Alpm {
if (new_conf.contains ("Method")) {
string _value = new_conf.get ("Method").get_string ();
data += "Method=%s\n".printf (_value);
} else
} else {
data += line + "\n";
}
} else if (line.contains ("OnlyCountry")) {
if (new_conf.contains ("OnlyCountry")) {
string _value = new_conf.get ("OnlyCountry").get_string ();
if (_value == dgettext (null, "Worldwide"))
if (_value == dgettext (null, "Worldwide")) {
data += "#%s\n".printf (line);
else
} else {
data += "OnlyCountry=%s\n".printf (_value);
} else
}
} else {
data += line + "\n";
} else
}
} else {
data += line + "\n";
}
}
// delete the file before rewrite it
file.delete ();

View File

@@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014-2015 Guillaume Benoit <guillaume@manjaro.org>
*
* 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
@@ -18,44 +18,77 @@
*/
namespace Pamac {
public class Package: Object {
public unowned Alpm.Package? alpm_pkg;
public unowned Json.Object? aur_json;
public struct Package {
public string name;
public string version;
public string desc;
public string repo;
public uint64 size;
public string size_string;
public string url;
public string licenses;
public int reason;
public Package (Alpm.Package? alpm_pkg, Json.Object? aur_json) {
if (alpm_pkg != null) {
this.alpm_pkg = alpm_pkg;
this.aur_json = null;
name = alpm_pkg.name;
version = alpm_pkg.version;
if (alpm_pkg.db != null)
repo = alpm_pkg.db.name;
else
repo = "";
desc = alpm_pkg.desc;
repo = alpm_pkg.db != null ? alpm_pkg.db.name : "";
size = alpm_pkg.isize;
size_string = format_size (alpm_pkg.isize);
// alpm pkg url can be null
url = alpm_pkg.url ?? "";
StringBuilder licenses_build = new StringBuilder ();
foreach (var license in alpm_pkg.licenses) {
if (licenses_build.len != 0) {
licenses_build.append (" ");
}
licenses_build.append (license);
}
licenses = licenses_build.str;
reason = alpm_pkg.reason;
} else if (aur_json != null ) {
this.alpm_pkg = null;
this.aur_json = aur_json;
name = aur_json.get_string_member ("Name");
version = aur_json.get_string_member ("Version");
desc = aur_json.get_string_member ("Description");
repo = "AUR";
size = 0;
size_string = "";
url = aur_json.get_string_member ("URL");
licenses = aur_json.get_string_member ("License");
reason = 0;
} else {
this.alpm_pkg = null;
this.aur_json = null;
name = dgettext (null, "No package found");
name = "";
version = "";
desc = "";
repo = "";
size = 0;
size_string = "";
url = "";
licenses= "";
reason = 0;
}
}
}
public struct PackageDetails {
string repo;
string has_signature;
int reason;
string packager;
string install_date;
string[] groups;
string[] backups;
}
public struct PackageDeps {
string repo;
string[] depends;
string[] optdepends;
string[] requiredby;
string[] provides;
string[] replaces;
string[] conflicts;
}
}

View File

@@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014-2015 Guillaume Benoit <guillaume@manjaro.org>
*
* 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
@@ -46,8 +46,9 @@ namespace Pamac {
}
window.get_window ().set_cursor (new Gdk.Cursor (Gdk.CursorType.WATCH));
this.hide ();
while (Gtk.events_pending ())
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
transaction.run ();
}
}

View File

@@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014-2015 Guillaume Benoit <guillaume@manjaro.org>
*
* 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
@@ -20,32 +20,20 @@
namespace Pamac {
public class PackagesModel : Object, Gtk.TreeModel {
private GLib.List<Pamac.Package> all_pkgs;
private GLib.List<Pamac.Package?> all_pkgs;
public ManagerWindow manager_window;
public PackagesModel (Alpm.List<Alpm.Package?>? alpm_pkgs, Json.Array? aur_pkgs, ManagerWindow manager_window) {
public PackagesModel (Pamac.Package[] pkgs, ManagerWindow manager_window) {
this.manager_window = manager_window;
all_pkgs = new GLib.List<Pamac.Package> ();
foreach (unowned Alpm.Package alpm_pkg in alpm_pkgs) {
all_pkgs.append (new Pamac.Package (alpm_pkg, null));
}
bool found;
foreach (var node in aur_pkgs.get_elements ()) {
// add only the packages which are not already in the list
found = false;
foreach (Pamac.Package pkg in all_pkgs) {
if (pkg.name == node.get_object ().get_string_member ("Name")) {
found = true;
break;
}
}
if (found == false) {
all_pkgs.append (new Pamac.Package (null, node.get_object ()));
}
all_pkgs = new GLib.List<Pamac.Package?> ();
foreach (var pkg in pkgs) {
all_pkgs.append (pkg);
}
if (all_pkgs.length () == 0) {
// create a fake "No package found" package
all_pkgs.append (new Pamac.Package (null, null));
var fake_pkg = Pamac.Package (null, null);
fake_pkg.name = dgettext (null, "No package found");
all_pkgs.append (fake_pkg);
}
}
@@ -69,8 +57,7 @@ namespace Pamac {
}
public void get_value (Gtk.TreeIter iter, int column, out Value val) {
Pamac.Package pkg = (Pamac.Package) iter.user_data;
return_if_fail (pkg != null);
Pamac.Package pkg = all_pkgs.nth_data (iter.stamp);
switch (column) {
case 0:
val = Value (typeof (string));
@@ -78,29 +65,30 @@ namespace Pamac {
break;
case 1:
val = Value (typeof (Object));
if (pkg.alpm_pkg != null) {
if (manager_window.transaction.alpm_config.holdpkgs.find_custom (pkg.name, strcmp) != null)
val.set_object (manager_window.locked_icon);
else if (pkg.repo == "local") {
if (manager_window.transaction.to_add.contains (pkg.name))
if (pkg.repo == "local") {
if (manager_window.transaction.should_hold (pkg.name)) {
val.set_object (manager_window.locked_icon);
} else if (manager_window.transaction.to_add.contains (pkg.name)) {
val.set_object (manager_window.to_reinstall_icon);
else if (manager_window.transaction.to_remove.contains (pkg.name))
} else if (manager_window.transaction.to_remove.contains (pkg.name)) {
val.set_object (manager_window.to_remove_icon);
else
} else {
val.set_object (manager_window.installed_icon);
} else if (manager_window.transaction.to_add.contains (pkg.name))
}
} else if (pkg.repo == "AUR") {
if (manager_window.transaction.to_build.contains (pkg.name)) {
val.set_object (manager_window.to_install_icon);
} else {
val.set_object (manager_window.uninstalled_icon);
}
} else if (pkg.name == dgettext (null, "No package found")) {
Object? object = null;
val.set_object (object);
} else if (manager_window.transaction.to_add.contains (pkg.name)) {
val.set_object (manager_window.to_install_icon);
else
} else {
val.set_object (manager_window.uninstalled_icon);
} else if (pkg.aur_json != null) {
if (manager_window.transaction.to_build.contains (pkg.name))
val.set_object (manager_window.to_install_icon);
else
val.set_object (manager_window.uninstalled_icon);
} else {
Object? object = null;
val.set_object (object);
}
}
break;
case 2:
val = Value (typeof (string));
@@ -127,8 +115,6 @@ namespace Pamac {
iter = Gtk.TreeIter ();
int pos = path.get_indices ()[0];
iter.stamp = pos;
Pamac.Package pkg = all_pkgs.nth_data((uint) pos);
iter.user_data = pkg;
return true;
}
@@ -151,8 +137,6 @@ namespace Pamac {
return false;
}
iter.stamp = pos;
Pamac.Package pkg = all_pkgs.nth_data((uint) pos);
iter.user_data = pkg;
return true;
}
@@ -162,8 +146,6 @@ namespace Pamac {
return false;
}
iter.stamp = (--pos);
Pamac.Package pkg = all_pkgs.nth_data((uint) pos);
iter.user_data = pkg;
return true;
}
@@ -189,14 +171,20 @@ namespace Pamac {
return false;
}
// custom get pkg function
public Pamac.Package get_pkg_at_path (Gtk.TreePath path) {
return all_pkgs.nth_data (path.get_indices ()[0]);
}
// custom sort functions
public void sort_by_name (Gtk.SortType order) {
CompareFunc<Pamac.Package> namecmp = (pkg_a, pkg_b) => {
CompareFunc<Pamac.Package?> namecmp = (pkg_a, pkg_b) => {
return strcmp (pkg_a.name, pkg_b.name);
};
all_pkgs.sort (namecmp);
if (order == Gtk.SortType.DESCENDING)
if (order == Gtk.SortType.DESCENDING) {
all_pkgs.reverse ();
}
manager_window.name_column.sort_order = order;
manager_window.state_column.sort_indicator = false;
manager_window.name_column.sort_indicator = true;
@@ -208,28 +196,25 @@ namespace Pamac {
}
public void sort_by_state (Gtk.SortType order) {
CompareFunc<Pamac.Package> statecmp = (pkg_a, pkg_b) => {
CompareFunc<Pamac.Package?> statecmp = (pkg_a, pkg_b) => {
int state_a;
int state_b;
if (pkg_a.alpm_pkg != null) {
if (pkg_a.repo == "local")
if (pkg_a.repo == "local") {
state_a = 0;
else
} else {
state_a = 1;
} else
state_a = 1;
if (pkg_b.alpm_pkg != null) {
if (pkg_b.repo == "local")
}
if (pkg_b.repo == "local") {
state_b = 0;
else
} else {
state_b = 1;
} else
state_b = 1;
}
return (int) (state_a > state_b) - (int) (state_a < state_b);
};
all_pkgs.sort (statecmp);
if (order == Gtk.SortType.DESCENDING)
if (order == Gtk.SortType.DESCENDING) {
all_pkgs.reverse ();
}
manager_window.state_column.sort_order = order;
manager_window.state_column.sort_indicator = true;
manager_window.name_column.sort_indicator = false;
@@ -241,12 +226,13 @@ namespace Pamac {
}
public void sort_by_version (Gtk.SortType order) {
CompareFunc<Pamac.Package> versioncmp = (pkg_a, pkg_b) => {
CompareFunc<Pamac.Package?> versioncmp = (pkg_a, pkg_b) => {
return Alpm.pkg_vercmp (pkg_a.version, pkg_b.version);
};
all_pkgs.sort (versioncmp);
if (order == Gtk.SortType.DESCENDING)
if (order == Gtk.SortType.DESCENDING) {
all_pkgs.reverse ();
}
manager_window.version_column.sort_order = order;
manager_window.state_column.sort_indicator = false;
manager_window.name_column.sort_indicator = false;
@@ -258,12 +244,13 @@ namespace Pamac {
}
public void sort_by_repo (Gtk.SortType order) {
CompareFunc<Pamac.Package> repocmp = (pkg_a, pkg_b) => {
CompareFunc<Pamac.Package?> repocmp = (pkg_a, pkg_b) => {
return strcmp (pkg_a.repo, pkg_b.repo);
};
all_pkgs.sort (repocmp);
if (order == Gtk.SortType.DESCENDING)
if (order == Gtk.SortType.DESCENDING) {
all_pkgs.reverse ();
}
manager_window.repo_column.sort_order = order;
manager_window.state_column.sort_indicator = false;
manager_window.name_column.sort_indicator = false;
@@ -275,22 +262,13 @@ namespace Pamac {
}
public void sort_by_size (Gtk.SortType order) {
CompareFunc<Pamac.Package> sizecmp = (pkg_a, pkg_b) => {
uint64 size_a;
uint64 size_b;
if (pkg_a.alpm_pkg != null)
size_a = pkg_a.size;
else
size_a = 0;
if (pkg_b.alpm_pkg != null)
size_b = pkg_b.size;
else
size_b = 0;
return (int) (size_a > size_b) - (int) (size_a < size_b);
CompareFunc<Pamac.Package?> sizecmp = (pkg_a, pkg_b) => {
return (int) (pkg_a.size > pkg_b.size) - (int) (pkg_a.size < pkg_b.size);
};
all_pkgs.sort (sizecmp);
if (order == Gtk.SortType.DESCENDING)
if (order == Gtk.SortType.DESCENDING) {
all_pkgs.reverse ();
}
manager_window.size_column.sort_order = order;
manager_window.state_column.sort_indicator = false;
manager_window.name_column.sort_indicator = false;

View File

@@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014-2015 Guillaume Benoit <guillaume@manjaro.org>
*
* 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
@@ -40,9 +40,9 @@ namespace Pamac {
public void parse_file (string path) {
var file = GLib.File.new_for_path (path);
if (file.query_exists () == false)
if (file.query_exists () == false) {
GLib.stderr.printf ("File '%s' doesn't exist.\n", path);
else {
} else {
try {
// Open file for reading and wrap returned FileInputStream into a
// DataInputStream, so we can read line by line
@@ -51,19 +51,25 @@ namespace Pamac {
// Read lines until end of file (null) is reached
while ((line = dis.read_line (null)) != null) {
line = line.strip ();
if (line.length == 0) continue;
if (line[0] == '#') continue;
if (line.length == 0) {
continue;
}
if (line[0] == '#') {
continue;
}
string[] splitted = line.split ("=");
string _key = splitted[0].strip ();
string _value = null;
if (splitted[1] != null)
if (splitted[1] != null) {
_value = splitted[1].strip ();
if (_key == "RefreshPeriod")
}
if (_key == "RefreshPeriod") {
refresh_period = int.parse (_value);
else if (_key == "EnableAUR")
} else if (_key == "EnableAUR") {
enable_aur = true;
else if (_key == "RemoveUnrequiredDeps")
} else if (_key == "RemoveUnrequiredDeps") {
recurse = true;
}
}
} catch (GLib.Error e) {
GLib.stderr.printf("%s\n", e.message);
@@ -73,9 +79,9 @@ namespace Pamac {
public void write (HashTable<string,Variant> new_conf) {
var file = GLib.File.new_for_path (conf_path);
if (file.query_exists () == false)
if (file.query_exists () == false) {
GLib.stderr.printf ("File '%s' doesn't exist.\n", conf_path);
else {
} else {
try {
// Open file for reading and wrap returned FileInputStream into a
// DataInputStream, so we can read line by line
@@ -84,33 +90,41 @@ namespace Pamac {
string[] data = {};
// Read lines until end of file (null) is reached
while ((line = dis.read_line (null)) != null) {
if (line.length == 0) continue;
if (line.length == 0) {
continue;
}
if (line.contains ("RefreshPeriod")) {
if (new_conf.contains ("RefreshPeriod")) {
int _value = new_conf.get ("RefreshPeriod").get_int32 ();
data += "RefreshPeriod = %u\n".printf (_value);
} else
} else {
data += line + "\n";
}
} else if (line.contains ("EnableAUR")) {
if (new_conf.contains ("EnableAUR")) {
bool _value = new_conf.get ("EnableAUR").get_boolean ();
if (_value == true)
if (_value == true) {
data += "EnableAUR\n";
else
} else {
data += "#EnableAUR\n";
} else
}
} else {
data += line + "\n";
}
} else if (line.contains ("RemoveUnrequiredDeps")) {
if (new_conf.contains ("RemoveUnrequiredDeps")) {
bool _value = new_conf.get ("RemoveUnrequiredDeps").get_boolean ();
if (_value == true)
if (_value == true) {
data += "RemoveUnrequiredDeps\n";
else
} else {
data += "#RemoveUnrequiredDeps\n";
} else
}
} else {
data += line + "\n";
} else
}
} else {
data += line + "\n";
}
}
// delete the file before rewrite it
file.delete ();

View File

@@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
*
* 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

View File

@@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014-2015 Guillaume Benoit <guillaume@manjaro.org>
*
* 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
@@ -44,8 +44,9 @@ namespace Pamac {
[GtkCallback]
public void on_close_button_clicked () {
this.hide ();
while (Gtk.events_pending ())
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
}
[GtkCallback]
@@ -55,8 +56,9 @@ namespace Pamac {
transaction.spawn_in_term ({"/usr/bin/echo", dgettext (null, "Transaction cancelled") + ".\n"});
this.hide ();
transaction.finished (false);
while (Gtk.events_pending ())
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
}
}
}

View File

@@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
*
* 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

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
*
* 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

View File

@@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
*
* 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

View File

@@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014-2015 Guillaume Benoit <guillaume@manjaro.org>
*
* 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
@@ -27,16 +27,14 @@ const string noupdate_info = _("Your system is up-to-date");
namespace Pamac {
[DBus (name = "org.manjaro.pamac")]
public interface Daemon : Object {
public abstract void refresh (int force, bool emit_signal) throws IOError;
public abstract UpdatesInfos[] get_updates () throws IOError;
public abstract void start_refresh (int force, bool emit_signal) throws IOError;
public abstract async Updates get_updates () throws IOError;
[DBus (no_reply = true)]
public abstract void quit () throws IOError;
}
public class TrayIcon: Gtk.Application {
Notify.Notification notification;
Daemon daemon;
Pamac.Config pamac_config;
bool locked;
uint refresh_timeout_id;
Gtk.StatusIcon status_icon;
@@ -88,8 +86,9 @@ namespace Pamac {
}
void left_clicked () {
if (status_icon.icon_name == "pamac-tray-update")
if (status_icon.icon_name == "pamac-tray-update") {
execute_updater ();
}
}
void execute_updater () {
@@ -117,7 +116,7 @@ namespace Pamac {
if (check_pamac_running () == false) {
start_daemon ();
try {
daemon.refresh (0, false);
daemon.start_refresh (0, false);
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
@@ -126,27 +125,29 @@ namespace Pamac {
}
void check_updates () {
UpdatesInfos[] updates = {};
try {
updates = daemon.get_updates ();
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
uint updates_nb = updates.length;
if (updates_nb == 0) {
this.update_icon (noupdate_icon_name, noupdate_info);
} else {
string info = ngettext ("%u available update", "%u available updates", updates_nb).printf (updates_nb);
this.update_icon (update_icon_name, info);
if (check_pamac_running () == false) {
show_notification (info);
daemon.get_updates.begin ((obj, res) => {
var updates = Updates ();
try {
updates = daemon.get_updates.end (res);
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
}
stop_daemon ();
uint updates_nb = updates.repos_updates.length + updates.aur_updates.length;
if (updates_nb == 0) {
this.update_icon (noupdate_icon_name, noupdate_info);
} else {
string info = ngettext ("%u available update", "%u available updates", updates_nb).printf (updates_nb);
this.update_icon (update_icon_name, info);
if (check_pamac_running () == false) {
show_notification (info);
}
}
stop_daemon ();
});
}
void show_notification (string info) {
//~ notification = new Notification (_("Update Manager"));
//~ var notification = new Notification (_("Update Manager"));
//~ notification.set_body (info);
//~ Gtk.IconTheme icon_theme = Gtk.IconTheme.get_default ();
//~ Gdk.Pixbuf icon = icon_theme.load_icon ("system-software-update", 32, 0);
@@ -157,7 +158,7 @@ namespace Pamac {
//~ notification.add_button (_("Show available updates"), "app.update");
//~ this.send_notification (_("Update Manager"), notification);
try {
notification = new Notify.Notification (_("Update Manager"), info, "system-software-update");
var notification = new Notify.Notification (_("Update Manager"), info, "system-software-update");
notification.add_action ("update", _("Show available updates"), execute_updater);
notification.show ();
} catch (Error e) {
@@ -204,12 +205,11 @@ namespace Pamac {
return true;
}
void launch_refresh_timeout () {
void launch_refresh_timeout (uint refresh_period_in_hours) {
if (refresh_timeout_id != 0) {
pamac_config.reload ();
Source.remove (refresh_timeout_id);
}
refresh_timeout_id = Timeout.add_seconds ((uint) pamac_config.refresh_period*3600, refresh);
refresh_timeout_id = Timeout.add_seconds (refresh_period_in_hours*3600, refresh);
}
public override void startup () {
@@ -219,7 +219,6 @@ namespace Pamac {
base.startup ();
pamac_config = new Pamac.Config ("/etc/pamac.conf");
locked = false;
refresh_timeout_id = 0;
@@ -233,7 +232,8 @@ namespace Pamac {
Notify.init (_("Update Manager"));
refresh ();
launch_refresh_timeout ();
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
launch_refresh_timeout ((uint) pamac_config.refresh_period);
Timeout.add (500, check_pacman_running);
this.hold ();

View File

@@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014-2015 Guillaume Benoit <guillaume@manjaro.org>
*
* 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
@@ -44,19 +44,22 @@ namespace Pamac {
transaction_info_dialog.expander.set_visible (false);
transaction_info_dialog.run ();
transaction_info_dialog.hide ();
} else
} else {
updater_window = new UpdaterWindow (this);
}
}
public override void activate () {
if (pamac_run == false)
if (pamac_run == false) {
updater_window.present ();
}
}
public override void shutdown () {
base.shutdown ();
if (pamac_run == false)
if (pamac_run == false) {
updater_window.transaction.stop_daemon ();
}
}
bool check_pamac_running () {
@@ -69,9 +72,9 @@ namespace Pamac {
stderr.printf ("%s\n", e.message);
}
run = app.get_is_remote ();
if (run)
if (run) {
return run;
else {
} else {
app = new Application ("org.manjaro.pamac.install", 0);
try {
app.register ();

View File

@@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014-2015 Guillaume Benoit <guillaume@manjaro.org>
*
* 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
@@ -17,38 +17,33 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using Gtk;
namespace Pamac {
[GtkTemplate (ui = "/org/manjaro/pamac/updater/updater_window.ui")]
public class UpdaterWindow : Gtk.ApplicationWindow {
[GtkChild]
public Label top_label;
public Gtk.Label top_label;
[GtkChild]
public TreeView updates_treeview;
public Gtk.TreeView updates_treeview;
[GtkChild]
public Label bottom_label;
public Gtk.Label bottom_label;
[GtkChild]
public Button apply_button;
public Gtk.Button apply_button;
public Gtk.ListStore updates_list;
public ListStore updates_list;
public Pamac.Config pamac_config;
public Pamac.Transaction transaction;
public UpdaterWindow (Gtk.Application application) {
Object (application: application);
pamac_config = new Pamac.Config ("/etc/pamac.conf");
updates_list = new Gtk.ListStore (2, typeof (string), typeof (string));
updates_treeview.set_model (updates_list);
transaction = new Transaction (this as ApplicationWindow);
transaction = new Transaction (this as Gtk.ApplicationWindow);
transaction.mode = Mode.UPDATER;
transaction.check_aur = pamac_config.enable_aur;
transaction.finished.connect (on_emit_trans_finished);
transaction.finished.connect (on_transaction_finished);
bottom_label.set_visible (false);
apply_button.set_sensitive (false);
@@ -58,10 +53,9 @@ namespace Pamac {
[GtkCallback]
public void on_preferences_button_clicked () {
bool changes = transaction.run_preferences_dialog (pamac_config);
if (changes) {
transaction.run_preferences_dialog.begin (() => {
set_updates_list.begin ();
}
});
}
[GtkCallback]
@@ -79,7 +73,7 @@ namespace Pamac {
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
transaction.refresh (0);
transaction.start_refresh (0);
}
[GtkCallback]
@@ -87,7 +81,7 @@ namespace Pamac {
this.application.quit ();
}
public void on_emit_trans_finished (bool error) {
public void on_transaction_finished (bool error) {
set_updates_list.begin ();
}
@@ -96,21 +90,16 @@ namespace Pamac {
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
top_label.set_markup ("");
updates_list.clear ();
UpdatesInfos[] updates = {};
try {
updates = transaction.daemon.get_updates ();
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
TreeIter iter;
bottom_label.set_visible (false);
Gtk.TreeIter iter;
string name;
string size;
uint64 dsize = 0;
uint updates_nb = 0;
foreach (UpdatesInfos infos in updates) {
Updates updates = yield transaction.get_updates ();
foreach (UpdateInfos infos in updates.repos_updates) {
name = infos.name + " " + infos.version;
if (infos.download_size != 0) {
size = format_size (infos.download_size);
@@ -118,9 +107,15 @@ namespace Pamac {
size = "";
}
dsize += infos.download_size;
updates_nb++;
updates_list.insert_with_values (out iter, -1, 0, name, 1, size);
}
foreach (UpdateInfos infos in updates.aur_updates) {
name = infos.name + " " + infos.version;
size = "";
updates_nb++;
updates_list.insert_with_values (out iter, -1, 0, name, 1, size);
}
updates_nb = updates.length;
if (updates_nb == 0) {
top_label.set_markup("<b>%s</b>".printf (dgettext (null, "Your system is up-to-date")));
apply_button.set_sensitive (false);
@@ -134,7 +129,6 @@ namespace Pamac {
} else {
bottom_label.set_visible (false);
}
this.get_window ().set_cursor (null);
while (Gtk.events_pending ()) {
Gtk.main_iteration ();