unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] [ELPA] Implement connman in enwc
@ 2024-03-29 22:10 Noé Lopez via Emacs development discussions.
  2024-04-01 22:51 ` Richard Stallman
  0 siblings, 1 reply; 8+ messages in thread
From: Noé Lopez via Emacs development discussions. @ 2024-03-29 22:10 UTC (permalink / raw)
  To: dunni; +Cc: emacs-devel, noelopez

[-- Attachment #1: Type: text/plain, Size: 586 bytes --]

Hi,

I've recently stumbled upon the enwc package, it said connman support
was experimental so I tried it and since there was no commits since a few
years I started finishing it myself.

Here is a patch that updates it to finish the connman support. I'm
sending it to emacs-devel because I understand it's hosted at ELPA (?)
If this is not the right place please tell me what needs to be done for
sending patches to inactive packages, thanks.

In the near future I would also like to finish the info manual that was
started for this package.

All the best,
Noé Lopez


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Finish-Connman-backend.patch --]
[-- Type: text/x-patch, Size: 8677 bytes --]

From b36714fd5aea523ec868227aecbe9579aa57c780 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?No=C3=A9=20Lopez?= <noelopez@free.fr>
Date: Fri, 29 Mar 2024 16:32:50 +0100
Subject: [PATCH] Finish Connman backend

* enwc-cm.el: Finish backend.

* enwc.el: Update package metadata and document the changes.
---
 doc/enwc.texi | 10 ++++++
 enwc-cm.el    | 97 ++++++++++++++++++++++++++++++++-------------------
 enwc.el       |  9 +++--
 3 files changed, 76 insertions(+), 40 deletions(-)

diff --git a/doc/enwc.texi b/doc/enwc.texi
index dddb66df7d..154c2dcae1 100644
--- a/doc/enwc.texi
+++ b/doc/enwc.texi
@@ -75,4 +75,14 @@ First, the path to ENWC must be added to the @var{load-path} variable.  Then, in
 
 Now, simply press @kbd{M+x}, and type @kbd{ENWC}, and press @kbd{RET}.  ENWC will begin scanning for networks on the wireless interface, and display them in its buffer.
 
+@node Configuration
+@chapter Configuration
+
+TODO
+
+@node Commands
+@chapter Commands
+
+TODO
+
 @bye
diff --git a/enwc-cm.el b/enwc-cm.el
index 0dc64a7118..a94a772de3 100644
--- a/enwc-cm.el
+++ b/enwc-cm.el
@@ -1,4 +1,4 @@
-;; enwc-cm.el --- The ConnMan back-end to ENWC.
+;; enwc-cm.el --- The ConnMan back-end to ENWC. -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2012-2017 Free Software Foundation, Inc.
 
@@ -94,31 +94,31 @@
   (concat enwc-cm-dbus-technology-path "ethernet"))
 
 (defun enwc-cm-get-network (id)
-  (nth id (enwc-cm-get-services)))
+  (assoc id (enwc-cm-get-services) #'string=))
 
 ;; connect
-(defun enwc-cm-connect (wired id)
-  (let ((path (concat enwc-cm-dbus-service-path (number-to-string id))))
-    (dbus-call-method :system
-                      enwc-cm-dbus-service
-                      path
-                      enwc-cm-dbus-service-interface
-                      "Connect")))
+(defun enwc-cm-connect (nw &optional wired)
+  (dbus-call-method :system
+                    enwc-cm-dbus-service
+                    nw
+                    enwc-cm-dbus-service-interface
+                    "Connect"))
 
 ;; disconnect
 (defun enwc-cm-disconnect (wired)
   (dbus-call-method :system
                     enwc-cm-dbus-service
-                    "/net/connman/service/CONNECTED-SERVICE"
+                    (enwc-cm-get-current-nw-id wired)
                     enwc-cm-dbus-service-interface
                     "Disconnect"))
 
 ;; scan
-(defun enwc-cm-scan (wired)
+(defun enwc-cm-scan (&optional wired)
   (let ((path (if wired
                   (enwc-cm-get-wired-tech-path)
                 (enwc-cm-get-wifi-tech-path))))
     (dbus-call-method-asynchronously :system
+				     enwc-cm-dbus-service
                                      path
                                      enwc-cm-dbus-technology-interface
                                      "Scan"
@@ -148,17 +148,22 @@
   (let ((network (enwc-cm-get-network id)))
     (car (cadr (assoc prop (cadr network))))))
 
-(defun enwc-cm-get-network-props (id wired)
+(defun enwc-cm-get-nw-props (id wired)
   (let ((network (enwc-cm-get-network id))
         props)
     ;; network should be a pair, (path . props)
     (unless network
       (error "Invalid Network Id %d" id))
     (setq props (cadr network))
-    (mapcar
-     (lambda (det)
-       (enwc-cm-dict-assoc props det))
-     enwc-cm-details-list)))
+    (let ((values (mapcar
+		   (lambda (det)
+		     (enwc-cm-dict-assoc props det))
+		   enwc-cm-details-list))))
+    `((essid . ,(or (enwc-cm-dict-assoc props "Name") "[hidden]"))
+	     (bssid . ,(enwc-cm-dict-assoc props "Ethernet/Address"))
+	     (strength . ,(enwc-cm-dict-assoc props "Strength"))
+	     (encrypt . ,(enwc-cm-dict-assoc props "Security"))
+	     (channel . ,(or (enwc-cm-dict-assoc props "Channel") 0)))))
 
 (defun enwc-cm-get-wireless-network-property (id prop)
   (enwc-cm-get-nw-prop id prop))
@@ -193,17 +198,17 @@
   (member (enwc-cm-dict-assoc (cadr service) "State")
           '("ready" "online")))
 
-(defun enwc-cm--find-connected-service (services num)
+(defun enwc-cm--find-connected-service (services)
   (if services
       (if (enwc-cm-is-connected-p (car services))
-          num
-        (enwc-cm--find-connected-service (cdr services) (1+ num)))
-    -1))
+          (car services)
+        (enwc-cm--find-connected-service (cdr services)))
+    nil))
 
-(defun enwc-cm-get-current-nw-id ()
+(defun enwc-cm-get-current-nw-id (wired) ;TODO : handle wired
   "Get the current network id."
   (let* ((services (enwc-cm-get-services)))
-    (enwc-cm--find-connected-service services 0)))
+    (car (enwc-cm--find-connected-service services))))
 
 ;; save-profile
 (defun enwc-cm-set-nw-prop (nw prop val &optional wired)
@@ -252,7 +257,7 @@
                     enwc-cm-dbus-manager-interface
                     "GetServices"))
 
-(defun enwc-cm-get-networks ()
+(defun enwc-cm-get-networks (&optional wired) ;TODO : handle wired
   (let ((services (enwc-cm-get-services)))
     (mapcar 'car services)))
 
@@ -293,15 +298,15 @@ FIELDS is an associative list of requested fields."
 (defmacro enwc-cm-agent-register-method (method)
   "Register a method METHOD with D-Bus.
 METHOD is assumed to be the camel-case D-Bus method."
-  `((dbus-register-method :session
-                          enwc-cm-dbus-agent-service
-                          enwc-cm-dbus-agent-path
-                          enwc-cm-dbus-agent-interface
-                          ,method
-                          (quote ,(car (read-from-string
-                                        (concat
-                                         "enwc-cm-agent-"
-                                         (enwc-cm-method-to-defun method))))))))
+  `(dbus-register-method :session
+                         enwc-cm-dbus-agent-service
+                         enwc-cm-dbus-agent-path
+                         enwc-cm-dbus-agent-interface
+                         ,method
+                         (quote ,(car (read-from-string
+                                       (concat
+                                        "enwc-cm-agent-"
+                                        (enwc-cm-method-to-defun method)))))))
 
 ;; Run during setup.
 (defun enwc-cm-setup ()
@@ -318,11 +323,11 @@ METHOD is assumed to be the camel-case D-Bus method."
   (enwc-cm-agent-register-method "Cancel")
 
   (dbus-call-method :system
-                    enwc-cm-dbus-manager-service
-                    enwc-cm-dbus-manager-path
+                    enwc-cm-dbus-service
+                    "/"
                     enwc-cm-dbus-manager-interface
                     "RegisterAgent"
-                    :string enwc-cm-dbus-agent-path))
+                    :object-path enwc-cm-dbus-agent-path))
 
 
 ;; (defun enwc-cm-get-encryption-type (id)
@@ -363,6 +368,28 @@ METHOD is assumed to be the camel-case D-Bus method."
 ;;     (enwc-cm-set-nw-prop wired id "Nameservers.Configuration"
 ;;                          new-dns-config)))
 
+
+(defun enwc-cm-can-load-p ()
+  (dbus-ping :system enwc-cm-dbus-service))
+
+(defun enwc-cm-is-wired ()		;TODO
+  nil)
+
+(enwc-register-backend
+ (make-enwc-backend
+  :key 'cm
+  :can-load-p #'enwc-cm-can-load-p
+  :load #'enwc-cm-setup
+  :unload #'enwc-cm-unload
+  :network-ids #'enwc-cm-get-networks
+  :scan #'enwc-cm-scan
+  :connect #'enwc-cm-connect
+  :disconnect #'enwc-cm-disconnect
+  :current-nw-id #'enwc-cm-get-current-nw-id
+  :is-connecting-p #'enwc-cm-check-connecting-p
+  :nw-props #'enwc-cm-get-nw-props
+  :is-wired-p #'enwc-cm-is-wired))
+
 (provide 'enwc-cm)
 
 ;; Local Variables:
diff --git a/enwc.el b/enwc.el
index 5bd01a5382..015dc41d01 100644
--- a/enwc.el
+++ b/enwc.el
@@ -3,8 +3,8 @@
 ;; Copyright (C) 2012-2017 Free Software Foundation, Inc.
 
 ;; Author: Ian Dunn <dunni@gnu.org>
-;; Keywords: external, network, wicd, manager, nm
-;; Version: 2.0
+;; Keywords: external, network, wicd, manager, nm, connman
+;; Version: 2.1
 ;; Package-Requires: ((emacs "25.1"))
 ;; Homepage: https://savannah.nongnu.org/p/enwc
 
@@ -30,14 +30,13 @@
 ;; ENWC is the Emacs Network Client.  It is designed to provide a front-end to
 ;; various network managers, such as NetworkManager and Wicd.
 ;;
-;; Currently, only NetworkManager and Wicd are supported, although experimental
-;; support exists for Connman.
+;; Currently, NetworkManager, Wicd and Connman are supported.
 ;;
 ;; In order to use this package, add
 ;;
 ;; (setq enwc-default-backend BACKEND-SYMBOL)
 ;;
-;; where BACKEND-SYMBOL is either 'wicd or 'nm, to your .emacs file (or other init
+;; where BACKEND-SYMBOL is either 'wicd, 'nm or 'cm, to your .emacs file (or other init
 ;; file).
 ;;
 ;; Then you can just run `enwc' to start everything.
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] [ELPA] Implement connman in enwc
  2024-03-29 22:10 [PATCH] [ELPA] Implement connman in enwc Noé Lopez via Emacs development discussions.
@ 2024-04-01 22:51 ` Richard Stallman
  2024-04-02 13:06   ` Noé Lopez via Emacs development discussions.
  0 siblings, 1 reply; 8+ messages in thread
From: Richard Stallman @ 2024-04-01 22:51 UTC (permalink / raw)
  To: Noé Lopez; +Cc: dunni, emacs-devel, noelopez

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

Could you please tell us in a few lines what ENWC does?
Also, what connman support does, concretely?

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] [ELPA] Implement connman in enwc
  2024-04-01 22:51 ` Richard Stallman
@ 2024-04-02 13:06   ` Noé Lopez via Emacs development discussions.
  2024-04-04 22:42     ` Richard Stallman
  2024-04-04 22:42     ` Richard Stallman
  0 siblings, 2 replies; 8+ messages in thread
From: Noé Lopez via Emacs development discussions. @ 2024-04-02 13:06 UTC (permalink / raw)
  To: rms; +Cc: dunni, emacs-devel, noelopez

Richard Stallman <rms@gnu.org> writes:

> [[[ To any NSA and FBI agents reading my email: please consider    ]]]
> [[[ whether defending the US Constitution against all enemies,     ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>
> Could you please tell us in a few lines what ENWC does?

Hi,

ENWC is an emacs package who's purpose is to display and manage internet
connections through diffent backends. That means listing available wi-fi
networks and connecting to them from emacs. On gnu/linux backends this
is usually NetworkManager, wicd or connman (maybe other packages
exist). AFAIK these packages interface with the linux kernel to manage
these connections, and they all provide a D-BUS interface for
applications that want to manage wifi, this is ENWC's use case.

From what I can see, ENWC has been created in 2013, then rebooted in
2017 by Ian Dunn but abandoned again since, though in a working state
for NetworkManager, the ConnMan back-end has not been updated.

        https://mail.gnu.org/archive/html/emacs-devel/2012-12/msg00368.html
        https://mail.gnu.org/archive/html/emacs-devel/2017-02/msg00583.html

As of right now ENWC is hosted on savannah and is inactive since the
reboot in 2017.

       https://savannah.nongnu.org/projects/enwc

And to answer your 2012 question, it uses mostly asynchronous requests,
except for when connecting, but that should be easily fixable.

       https://mail.gnu.org/archive/html/emacs-devel/2012-12/msg00391.html

> Also, what connman support does, concretely?

ConnMan support makes the package compatible with another back-end, my
patch only finishes the work that was started a few years ago.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] [ELPA] Implement connman in enwc
  2024-04-02 13:06   ` Noé Lopez via Emacs development discussions.
@ 2024-04-04 22:42     ` Richard Stallman
  2024-04-04 22:42     ` Richard Stallman
  1 sibling, 0 replies; 8+ messages in thread
From: Richard Stallman @ 2024-04-04 22:42 UTC (permalink / raw)
  To: Noé Lopez; +Cc: dunni, emacs-devel, noelopez

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

Thanks for the explanation.
It sounds useful.  It may require some careful attention
from a security expert.

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] [ELPA] Implement connman in enwc
  2024-04-02 13:06   ` Noé Lopez via Emacs development discussions.
  2024-04-04 22:42     ` Richard Stallman
@ 2024-04-04 22:42     ` Richard Stallman
  2024-04-05 20:00       ` Noé Lopez via Emacs development discussions.
  1 sibling, 1 reply; 8+ messages in thread
From: Richard Stallman @ 2024-04-04 22:42 UTC (permalink / raw)
  To: Noé Lopez; +Cc: dunni, emacs-devel, noelopez

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

It sounds useful.
Would you be interested in trying to restart the work?
-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] [ELPA] Implement connman in enwc
  2024-04-04 22:42     ` Richard Stallman
@ 2024-04-05 20:00       ` Noé Lopez via Emacs development discussions.
  2024-04-08 22:30         ` Richard Stallman
  0 siblings, 1 reply; 8+ messages in thread
From: Noé Lopez via Emacs development discussions. @ 2024-04-05 20:00 UTC (permalink / raw)
  To: rms; +Cc: dunni, emacs-devel, noelopez

Richard Stallman <rms@gnu.org> writes:

> [[[ To any NSA and FBI agents reading my email: please consider    ]]]
> [[[ whether defending the US Constitution against all enemies,     ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>
> It sounds useful.
> Would you be interested in trying to restart the work?

Yes, I would be interested. This is why I did this patch, I'd also like
to finish the documentation and improve the network listing buffer.

--
Noé Lopez



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] [ELPA] Implement connman in enwc
  2024-04-05 20:00       ` Noé Lopez via Emacs development discussions.
@ 2024-04-08 22:30         ` Richard Stallman
  2024-04-14 13:01           ` Noé Lopez via Emacs development discussions.
  0 siblings, 1 reply; 8+ messages in thread
From: Richard Stallman @ 2024-04-08 22:30 UTC (permalink / raw)
  To: Noé Lopez; +Cc: dunni, emacs-devel, noelopez

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > Yes, I would be interested. This is why I did this patch, I'd also like
  > to finish the documentation and improve the network listing buffer.

Thank you.

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] [ELPA] Implement connman in enwc
  2024-04-08 22:30         ` Richard Stallman
@ 2024-04-14 13:01           ` Noé Lopez via Emacs development discussions.
  0 siblings, 0 replies; 8+ messages in thread
From: Noé Lopez via Emacs development discussions. @ 2024-04-14 13:01 UTC (permalink / raw)
  To: rms; +Cc: dunni, emacs-devel, noelopez

Hi,

I've pushed my changes to a fork repository at
https://framagit.org/nll/enwc, but I'm not sure how I'm supposed to do
my changes without breaking any copyright/gpl.

As I understand, the code is part of GNU Emacs because it's in ELPA, and
its copyright is assigned to the FSF. My changes are not part of emacs
so are not subject to my copyright assignment. Does that mean I need to
add a second header to the files I changed mentionning my name and that
my work is also under gpl but not part of emacs ?

Then, the documentation mentions copyright directly to Ian Dunn, so I
suppose that doesn't count as part of emacs ? To modify it I would need
to change its title and other FDL stuff. Or I could rewrite it all,
since its only a few lines right now.

Should I change the name of the project, and update the copyright
information and add a notice that this is a modified version of ENWC, or
is it possible/legal to make my repository the new ELPA source, and make
my work part of emacs, which would mean all copyright to the FSF so no
need to update headers ?



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-04-14 13:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-29 22:10 [PATCH] [ELPA] Implement connman in enwc Noé Lopez via Emacs development discussions.
2024-04-01 22:51 ` Richard Stallman
2024-04-02 13:06   ` Noé Lopez via Emacs development discussions.
2024-04-04 22:42     ` Richard Stallman
2024-04-04 22:42     ` Richard Stallman
2024-04-05 20:00       ` Noé Lopez via Emacs development discussions.
2024-04-08 22:30         ` Richard Stallman
2024-04-14 13:01           ` Noé Lopez via Emacs development discussions.

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).