Skip to content

Commit

Permalink
[WIP] netusagemonitor@pdcurtis Update to version 3.2.5 (#1771)
Browse files Browse the repository at this point in the history
* netusagemonitor@pdcurtis Update to version 3.2.5

* netusagemonitor@pdcurtis Update to version 3.2.5.1
  • Loading branch information
pdcurtis authored and jaszhix committed Apr 24, 2018
1 parent 33b76b8 commit 8a4995b
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
### Changelog covering recent significant changes

## 3.2.5

* Changes to check which network manager libraries are in use and choose which to use - addresses/solves issue #1647 with Fedora versions 27 and higher.
* Note that there may be problems with option of disconnecting the network manager when data usage limit is exceeded so checks are needed under NM before the issue can be marked as closed.
* Use xdg-open in place of gedit or xed to allow use on more distros
* Update README.md

## 3.2.4

* Change method of inhibiting display of vnstati image when vnstati not installed or enabled in settings by substituting a tiny image instead of use of an extra mainBox.
Expand All @@ -25,7 +32,7 @@ Support new facility on Cinnamon Spices Web Site to display a CHANGELOG.md

* Harmonise with code writen by author for vnstat@cinnamon.org

##3.2.0
## 3.2.0

* Remove duplicate let declarations occurances in common coding for Cinnamon 3.4 thanks to @NikoKraus [#604]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,8 @@ The Network Usage Monitor Applet (NUMA) enables one to continuously display the
* For full facilities including use of notifications, audible alerts and statistics the ```gir1.2-gtop-2.0 vnstat vnstati zenity sox libsox-fmt-mp3``` libraries must be installed. They can be installed by the synaptic package manager or with the terminal command:
```sudo apt-get install gir1.2-gtop-2.0 vnstat vnstati zenity sox libsox-fmt-mp3``
* Cinnamon Version 2.2 or higher ie. It can be used with all supported versions of Mint.

## Warning about use on Distributions other than Mint:

* This Applet was originally designed to be used with Cinnamon running under Mint and has largely been tested under Mint.
* It currently assumes the NMClient and NetworkManager libraries are available and in use as is the case in Mint versions up to 18.3 and most other current distro versions.
* It cannot be loaded on Fedora 27 (and possibly future versions of Linux Mint or other distros) due to the move from NMClient and NetworkManager libraries to NM.
* Attempting to add this applet on Fedora 27 may cause Cinnamon to continually crash (issue #1647).
* It currently assumes the NMClient and NetworkManager libraries are in use as is the case in Mint versions up to 18.3 and most other current distro versions.
* The latest versions can also switch to the more recent NM library if the NetworkManager Library is not available.

## Features:

Expand Down
47 changes: 40 additions & 7 deletions netusagemonitor@pdcurtis/files/netusagemonitor@pdcurtis/applet.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,38 @@ const Lang = imports.lang;
const Mainloop = imports.mainloop;
const PopupMenu = imports.ui.popupMenu;
const St = imports.gi.St;
const NetworkManager = imports.gi.NetworkManager;
const Main = imports.ui.main;
const Settings = imports.ui.settings; // Needed for settings API
const Clutter = imports.gi.Clutter; // Needed for vnstat addition
const ModalDialog = imports.ui.modalDialog; // Needed for Modal Dialog used in Alert
const NMClient = imports.gi.NMClient; // Needed for modifications to NM calls
const Gettext = imports.gettext; // ++ Needed for translations

// Code for selecting network manager thanks to Jason Hicks
let tryFn = function(fn, errCb) {
try {
return fn();
} catch (e) {
if (typeof errCb === 'function') {
errCb(e);
}
}
}

let CONNECTED_STATE, NMClient_new, newNM;
// Fallback to the new version.
tryFn(function() {
const NMClient = imports.gi.NMClient;
const NetworkManager = imports.gi.NetworkManager;
CONNECTED_STATE = NetworkManager.DeviceState ? NetworkManager.DeviceState.ACTIVATED : 0;
NMClient_new = NMClient.Client.new;
newNM = false;
}, function() {
const NM = imports.gi.NM;
CONNECTED_STATE = NM.DeviceState.ACTIVATED;
NMClient_new = NM.Client.new;
newNM = true;
});

// Localisation/translation support - moved up and slightly non standard due to GTOP test which follows.
var UUID = "netusagemonitor@pdcurtis";
Gettext.bindtextdomain(UUID, GLib.get_home_dir() + "/.local/share/locale");
Expand Down Expand Up @@ -234,12 +258,15 @@ MyApplet.prototype = {

this.applet_running = true; //** New

this._client = NMClient.Client.new(); //++
// More code for selecting network manager thanks to Jason Hicks
let args = newNM ? [null] : [];
this._client = NMClient_new.apply(this, args);

if (this.versionCompare( GLib.getenv('CINNAMON_VERSION') ,"3.0" ) <= 0 ){
this.textEd = "gedit";
} else {
this.textEd = "xed";
// this.textEd = "xed";
this.textEd = "xdg-open";
}

this.abortFlag = true;
Expand Down Expand Up @@ -406,7 +433,7 @@ MyApplet.prototype = {
if (interfaces != null) {
for (let i = 0; i < interfaces.length; i++) {
let iname = interfaces[i].get_iface();
if (iname == name && interfaces[i].state == NetworkManager.DeviceState.ACTIVATED) {
if (iname == name && interfaces[i].state == CONNECTED_STATE) {
return true;
}
}
Expand Down Expand Up @@ -792,7 +819,7 @@ Note Odysius has used the index 0 (zero) to insert the menu section to position

networkingDisable: function () {
if(!this.abortFlag) {
this._client.networking_enabled = false; // Call to NMClient
this._client.networking_enabled = false; // Need to check with NM library
alertModalNetworkingDisabled = new AlertDialog_(("THE DATA USAGE LIMIT HAS BEEN EXCEEDED\n\nAll Network connections managed by the Network Manager have been Disabled\n\nYou will need to use the Network Manager Applet to Re-enable them\nwhen the data usage problem has been resolved\n\n Some connections using ppp0 may not have been disabled or may need to be restarted manually"));
alertModalNetworkingDisabled.open();
} else {
Expand Down Expand Up @@ -1181,5 +1208,11 @@ Transition to new cinnamon-spices-applets repository from github.com/pdcurtis/ci
* Change method of inhibiting display of vnstati image when vnstati not installed or enabled in settings by substituting a tiny image instead of use of an extra mainBox which led to CJS warnings.
* Improved notification when vnstat and vnstati not installed
* Tidy up code
* Better formatting of CHANGELOG.md
* Better formatting of CHANGELOG.md
## 3.2.4.1
* Changes to README.md to alert users to problems on Fedora 27 with changes in network manager libraries - issue #1647
## 3.2.5
* Changes to check which network manager libraries are in use and choose which to use - addresses/solves issue #1647 with Fedora versions 27 and higher.
* Note that there may be problems with option of disconnecting the network manager when data usage limit is exceeded so checks are needed under NM before the issue can be marked as closed.
* Use xdg-open in place of gedit or xed to allow use on more distros
*/
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,9 @@ Transition to new cinnamon-spices-applets repository from github.com/pdcurtis/ci
* Improved notification when vnstat and vnstati not installed
* Tidy up code
* Better formatting of CHANGELOG.md
## 3.2.4.1
* Changes to README.md to alert users to problems on Fedora 27 with changes in network manager libraries - issue #1647
## 3.2.5
* Changes to check which network manager libraries are in use and choose which to use - addresses/solves issue #1647 with Fedora versions 27 and higher.
* Use xdg-open in place of gedit or xed to allow use on more distros
* Note that there may be problems with option of disconnecting the network manager when data usage limit is exceeded so checks are needed under NM before the issue can be marked as closed.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"uuid": "netusagemonitor@pdcurtis",
"name": "Network Data Usage Monitor",
"description": "A Comprehensive Data Usage Monitor with alerts and cumulative data functions",
"version": "3.2.4"
"version": "3.2.5"
}

0 comments on commit 8a4995b

Please sign in to comment.