After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 672998 - (LFe) Support Connman Network Manager in gUPnP Context Manager
(LFe)
Support Connman Network Manager in gUPnP Context Manager
Status: RESOLVED FIXED
Product: GUPnP
Classification: Other
Component: gupnp
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: GUPnP Maintainers
GUPnP Maintainers
Depends on:
Blocks:
 
 
Reported: 2012-03-28 14:28 UTC by Ludovic Ferrandis
Modified: 2012-05-03 14:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Connman support. Patch V0 - Cover letter (843 bytes, patch)
2012-03-28 14:29 UTC, Ludovic Ferrandis
none Details | Review
Connman support - Patch V0 - Initial release (32.48 KB, patch)
2012-03-28 14:30 UTC, Ludovic Ferrandis
none Details | Review
Connman support. Patch V1 - Cover letter (936 bytes, patch)
2012-03-28 15:16 UTC, Ludovic Ferrandis
none Details | Review
Connman support - Patch V1 - Initial release (32.27 KB, patch)
2012-03-28 15:16 UTC, Ludovic Ferrandis
reviewed Details | Review
Connman support. Patch V2 - Cover letter (1.04 KB, patch)
2012-03-29 13:15 UTC, Ludovic Ferrandis
none Details | Review
Connman support - Patch V2 - Initial release (32.10 KB, patch)
2012-03-29 13:17 UTC, Ludovic Ferrandis
none Details | Review
Connman support. Patch v3 - Cover letter (1.11 KB, patch)
2012-04-05 09:56 UTC, Ludovic Ferrandis
none Details | Review
Connman support - Patch v3 - Initial release (32.01 KB, patch)
2012-04-05 09:57 UTC, Ludovic Ferrandis
none Details | Review
Connman support. Patch v4 - Cover letter (1.44 KB, patch)
2012-04-20 15:37 UTC, Ludovic Ferrandis
none Details | Review
Connman support - Patch v4 - Initial release (31.50 KB, patch)
2012-04-20 15:38 UTC, Ludovic Ferrandis
none Details | Review
Connman based Context Manager. Patch v5 - Cover letter (1.51 KB, patch)
2012-04-27 09:12 UTC, Ludovic Ferrandis
none Details | Review
Connman based Context Manager - Patch v5 - Initial implementation (32.25 KB, patch)
2012-04-27 09:13 UTC, Ludovic Ferrandis
reviewed Details | Review
Connman based Context Manager. Patch v6 - Cover letter (1.58 KB, patch)
2012-05-02 15:44 UTC, Ludovic Ferrandis
committed Details | Review
Connman based Context Manager - Patch v6 - Initial implementation (32.38 KB, patch)
2012-05-02 15:44 UTC, Ludovic Ferrandis
committed Details | Review

Description Ludovic Ferrandis 2012-03-28 14:28:27 UTC
Add a new feature to support Connman in gUPnP Context.

The goal is to update this feature to follow Connman new features when they will be available, like "Network Zone" or Network Type (Cellular, Wifi, ...)
This context exists to support features that won't/can't be supported in the Linux Context Manager.
Comment 1 Ludovic Ferrandis 2012-03-28 14:29:54 UTC
Created attachment 210783 [details] [review]
Connman support. Patch V0 - Cover letter
Comment 2 Ludovic Ferrandis 2012-03-28 14:30:35 UTC
Created attachment 210784 [details] [review]
Connman support - Patch V0 - Initial release
Comment 3 Ross Burton 2012-03-28 14:36:39 UTC
In general don't use G_UNLIKELY unless you've demonstrated that it's a worthwhile optimisation.
Comment 4 Ludovic Ferrandis 2012-03-28 14:39:18 UTC
(In reply to comment #3)
> In general don't use G_UNLIKELY unless you've demonstrated that it's a
> worthwhile optimisation.

Ok. I will remove them all from next version.
PS: I just follow the "style" from NM Context Manager
Comment 5 Ross Burton 2012-03-28 14:46:41 UTC
In that case it's wrong too. :)
Comment 6 Ludovic Ferrandis 2012-03-28 14:53:22 UTC
(In reply to comment #5)
> In that case it's wrong too. :)

:D
Doc on G_LIKELY & G_UNLIKELY is pretty.. hem... brief.
Any hint on when or why to use/don't use these macro.
Comment 7 Ross Burton 2012-03-28 14:58:19 UTC
They inject instructions that tell the processor to make specific optimisations and manipulate the predictions.  Unless you know that the changes actually make a real world difference, there isn't any gain in doing so and you can actually hurt performance by overriding the CPU.
Comment 8 Ludovic Ferrandis 2012-03-28 15:00:01 UTC
(In reply to comment #7)
> They inject instructions that tell the processor to make specific optimisations
> and manipulate the predictions.  Unless you know that the changes actually make
> a real world difference, there isn't any gain in doing so and you can actually
> hurt performance by overriding the CPU.

ok. I will check all macros.
Thanks.
Comment 9 Jens Georg 2012-03-28 15:15:43 UTC
Tests would be really awesome. We've neglected that way too long.
Comment 10 Ludovic Ferrandis 2012-03-28 15:16:24 UTC
Created attachment 210789 [details] [review]
Connman support. Patch V1 - Cover letter
Comment 11 Ludovic Ferrandis 2012-03-28 15:16:55 UTC
Created attachment 210790 [details] [review]
Connman support - Patch V1 - Initial release
Comment 12 Ludovic Ferrandis 2012-03-28 15:25:14 UTC
(In reply to comment #9)
> Tests would be really awesome. We've neglected that way too long.

I'm not sure the saving time will be significant.
These macros are use in loops that parse Connman services or dictionaries.
Connman services is more often a very short list as dictionaries used in this code.

If you are really interested, I could make some tests and post the results. But I don't think they will be amazing.
Comment 13 Jens Georg 2012-03-28 16:31:44 UTC
Sorry, I meant unit/functional tests. Not tests related to the G_(UN)LIKELY stuff.
Comment 14 Jens Georg 2012-03-29 10:31:09 UTC
Review of attachment 210790 [details] [review]:

There's some weird newlines going on in gupnp-connman-manager.c

::: libgupnp/gupnp-connman-manager.h
@@ +28,3 @@
+
+GType
+gupnp_connman_manager_get_type (void) G_GNUC_CONST;

Please use G_GNUC_INTERNAL to not pollute the symbol space (and annoy the Debian packager). Yes, that's wrong in the other context managers as well.

@@ +62,3 @@
+        GUPnPContextManagerClass parent_class;
+
+        /* future padding */

You probably don't need this, this is an internal class. (I know, you followed the lead)

@@ +71,3 @@
+
+gboolean
+gupnp_connman_manager_is_available      (void);

Please use G_GNUC_INTERNAL (s.a.)
Comment 15 Ludovic Ferrandis 2012-03-29 13:15:58 UTC
Created attachment 210868 [details] [review]
Connman support. Patch V2 - Cover letter
Comment 16 Ludovic Ferrandis 2012-03-29 13:17:44 UTC
Created attachment 210869 [details] [review]
Connman support - Patch V2 - Initial release
Comment 17 Ludovic Ferrandis 2012-04-05 09:56:14 UTC
Created attachment 211361 [details] [review]
Connman support. Patch v3 - Cover letter 

v3:
Fix assigment bug (== instead of =)
Remove unused variable
Comment 18 Ludovic Ferrandis 2012-04-05 09:57:01 UTC
Created attachment 211362 [details] [review]
Connman support - Patch v3 - Initial release
Comment 19 Ludovic Ferrandis 2012-04-19 10:53:19 UTC
Please do not use V3 patches.
I will post a new version soon/today as soon as I finish some tests.
In the move to Connman 1.0, some dbus api has changed.
I've fixed the code and squash some bugs.
Thanks.
Comment 20 Ludovic Ferrandis 2012-04-20 15:37:36 UTC
Created attachment 212432 [details] [review]
Connman support. Patch v4 - Cover letter 

v4: Use new Connman dbus API
         - Remove signal ServicesAdded & ServicesRemoved
         - Use ServicesChanged
    Factorize and rename some functions for consistency
    Call g_object_set when a context property has changed, so "notify" 
    signal will be emitted.
    Always get service name, not only for wifi services.
    
v3: Fix assigment bug (== instead of =)
    Remove unused variable

v2: Integrate Jens comments:
    - Use G_GNUC_INTERNAL macro when needed.
    - Remove unused and unnecessary structure members.

v1: Remove G_UNLIKELY & G_LIKELY macro. No need for such optimization.

v0: Initial release.

Add the capability to use Connman in Context Manager
Comment 21 Ludovic Ferrandis 2012-04-20 15:38:16 UTC
Created attachment 212433 [details] [review]
Connman support - Patch v4 - Initial release
Comment 22 Ludovic Ferrandis 2012-04-20 15:39:09 UTC
This should be the last version of the patch unless you found something.
Regards.
Comment 23 Zeeshan Ali 2012-04-20 15:46:55 UTC
Review of attachment 212433 [details] [review]:

Good log messages are not just nice but also good for history so I'll do a bit of nitpicking (bike-shedding if you may): You are not adding "Connman support in GUPNPContext" but rather "Add ConnMan based context manager". Also there is no release involved. Reader of commit history will get confused if you use the word 'release' here.
Comment 24 Ludovic Ferrandis 2012-04-20 15:52:06 UTC
(In reply to comment #23)
> Review of attachment 212433 [details] [review]:
> 
> Good log messages are not just nice but also good for history so I'll do a bit
> of nitpicking (bike-shedding if you may): You are not adding "Connman support
> in GUPNPContext" but rather "Add ConnMan based context manager". Also there is
> no release involved. Reader of commit history will get confused if you use the
> word 'release' here.

Do you want I upload new version of the patches or will you update the messages if you decide to accept the patch?
Comment 25 Zeeshan Ali 2012-04-20 16:04:23 UTC
Review of attachment 212433 [details] [review]:

::: libgupnp/gupnp-connman-manager.c
@@ +1,2 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.

Are you certain that this code is not based on any other code? Ignore this comment if its not but please keep the original copyrights and author info otherwise.

@@ +349,3 @@
+        (void) g_variant_iter_init (&iter, data);
+
+        while (g_variant_iter_loop (&iter, "(&o@a{sv})", &path, &dict)) {

There is a really long block in this while leading into multiple levels of indentation. Could you please refactor this code somewhat so this function isn't that long?

@@ +373,3 @@
+
+                if (eth != NULL) {
+                        (void) g_variant_lookup (eth, "Interface", "s", &iface);

Is this '(void)' really needed? You seem to have used it in other places as well, please remove all occurances unless I'm missing something and this is really needed?

@@ +446,3 @@
+
+        while (g_variant_iter_next (&iter, "&o", &path)) {
+

remove redundant newlines like these (i-e first line of if/else/while/for/ blocks doesn't need to be empty).

@@ +474,3 @@
+        manager = GUPNP_CONNMAN_MANAGER (user_data);
+
+	//~ { "ServicesChanged",   "a(oa{sv})ao" },

Remove commented-out code.

@@ +506,3 @@
+                g_warning ("Error fetching service list: %s", error->message);
+                g_error_free (error);
+                return;

"Add a newline before each return, break, throw, continue etc. if it is not the only statement in that block" from coding style doc: http://gupnp.org/coding-style

@@ +660,3 @@
+        object_class = G_OBJECT_CLASS (gupnp_connman_manager_parent_class);
+
+        if (object_class->constructed != NULL) {

No braces for single statement blocks. This is one multiple places in this file alone.

@@ +696,3 @@
+gupnp_connman_manager_is_available (void)
+{
+        GDBusProxy      *dbus_proxy;

just one space between 'GDBusProxy' and '*dbus_proxy' and align the rest according to this. Same in a few other functions.
Comment 26 Zeeshan Ali 2012-04-20 16:07:46 UTC
(In reply to comment #24)
> (In reply to comment #23)
> > Review of attachment 212433 [details] [review] [details]:
> > 
> > Good log messages are not just nice but also good for history so I'll do a bit
> > of nitpicking (bike-shedding if you may): You are not adding "Connman support
> > in GUPNPContext" but rather "Add ConnMan based context manager". Also there is
> > no release involved. Reader of commit history will get confused if you use the
> > word 'release' here.
> 
> Do you want I upload new version of the patches or will you update the messages
> if you decide to accept the patch?

I'm only doing the review and i'm probably not going to be the one pushing your patch in the end so you'll have to do it.
Comment 27 Ludovic Ferrandis 2012-04-27 09:12:12 UTC
Created attachment 212937 [details] [review]
Connman based Context Manager. Patch v5 - Cover letter

v5: Integrate Zeeshan Ali comments
    Fix Copyright header
    Split long function
    Fix coding style issues
    
v4: Use new Connman dbus API
         - Remove signal ServicesAdded & ServicesRemoved
         - Use ServicesChanged
    Factorize and rename some functions for consistency
    Call g_object_set when a context property has changed, so "notify" 
    signal will be emitted.
    Always get service name, not only for wifi services.
    
v3: Fix assigment bug (== instead of =)
    Remove unused variable

v2: Integrate Jens Georg comments:
    - Use G_GNUC_INTERNAL macro when needed.
    - Remove unused and unnecessary structure members.

v1: Remove G_UNLIKELY & G_LIKELY macro. No need for such optimization.

v0: Initial implementation.
Comment 28 Ludovic Ferrandis 2012-04-27 09:13:12 UTC
Created attachment 212938 [details] [review]
Connman based Context Manager - Patch v5 - Initial implementation
Comment 29 Zeeshan Ali 2012-04-28 02:59:22 UTC
Review of attachment 212938 [details] [review]:

Otherwise it looks very good from non-functional POV at least. So if Jens has tested this, he can push it once you correct this tiny issues. Thanks for your patience on this BTW!

::: libgupnp/gupnp-connman-manager.c
@@ +208,3 @@
+                    (g_strcmp0 (state_str, "ready") == 0))
+                        new_state = CM_SERVICE_STATE_ACTIVE;
+                else new_state = CM_SERVICE_STATE_INACTIVE;

else block belong in a separate line

@@ +743,3 @@
+                g_warning ("Failed to connect to Connman: %s", error->message);
+                g_error_free (error);
+                return ret;

new line before return in here too.
Comment 30 Jens Georg 2012-05-02 11:02:34 UTC
Ok, after some struggle (debian shipping a _really_ old version of connman) got it to work. Seems to be working.
Comment 31 Ludovic Ferrandis 2012-05-02 15:44:11 UTC
Created attachment 213303 [details] [review]
Connman based Context Manager. Patch v6 - Cover letter

v6: Check Connman package version
    Fix coding style issues
    
v5: Integrate Zeeshan Ali comments
    Fix Copyright header
    Split long function
    Fix coding style issues
    
v4: Use new Connman dbus API
         - Remove signal ServicesAdded & ServicesRemoved
         - Use ServicesChanged
    Factorize and rename some functions for consistency
    Call g_object_set when a context property has changed, so "notify" 
    signal will be emitted.
    Always get service name, not only for wifi services.
    
v3: Fix assigment bug (== instead of =)
    Remove unused variable

v2: Integrate Jens Georg comments:
    - Use G_GNUC_INTERNAL macro when needed.
    - Remove unused and unnecessary structure members.

v1: Remove G_UNLIKELY & G_LIKELY macro. No need for such optimization.

v0: Initial implementation.
Comment 32 Ludovic Ferrandis 2012-05-02 15:44:41 UTC
Created attachment 213304 [details] [review]
Connman based Context Manager - Patch v6 - Initial implementation