nut icon indicating copy to clipboard operation
nut copied to clipboard

[DoNotMerge] DBus proof-of-concept

Open EmilienKia opened this issue 7 years ago • 5 comments

Hello,

This is a not-ready-to-merge proof-of-concept of DBus integration of NUT, just to add some views about #526. It only have Get/GetAll/Set introspection for devices. It does not support notifications yet but it is a good starting point for discussions. I will add notification for status soon.

Please test but don't merge it. It is not integrated to autoconf feature detection. Some security configuration files could be required by some distributions (.conf in /etc/dbus-1/system.d). Moreover no performance nor leak detection have been done.

Enjoy,

Emilien

EmilienKia avatar Mar 06 '18 07:03 EmilienKia

Per Travis, doc/nut.dict should learn a new word : dbus (in whatever spelling/casing is correct) to pass configure.txt spellcheck.

jimklimov avatar Mar 09 '18 08:03 jimklimov

Hello Jim, thanks for the tip.

EmilienKia avatar Mar 09 '18 08:03 EmilienKia

@EmilienKia : Some merge conflicts cropped up while this PR was waiting, the Makefile one is trivial, but the one in code wants you to revise what is right :)

jimklimov avatar Oct 09 '20 10:10 jimklimov

@EmilienKia : thanks for the code resync bump; as for the content of feature set you intended to have, is this still a "DoNotMerge"? ;)

jimklimov avatar Oct 24 '20 17:10 jimklimov

@EmilienKia : probably the master branch evolved since you branched for this PoC; there are complaints about inconsistencies in netset.c in Travis CI e.g. https://travis-ci.org/github/networkupstools/nut/jobs/737634477 :

/usr/lib/ccache/gcc -DHAVE_CONFIG_H -I. -I../include   -I/home/travis/build/networkupstools/nut/tmp/include  -I../include   -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/home/travis/build/networkupstools/nut/tmp/include  -Wall -Wsign-compare -MT netset.o -MD -MP -MF $depbase.Tpo -c -o netset.o netset.c &&\

mv -f $depbase.Tpo $depbase.Po

netset.c: In function 'set_var':

netset.c:39:23: error: 'ups' undeclared (first use in this function)
  val = sstate_getinfo(ups, var);
                       ^

netset.c:39:23: note: each undeclared identifier is reported only once for each function it appears in

netset.c:42:10: warning: 'return' with a value, in function returning void
   return SET_VAR_CHECK_VAL_VAR_NOT_SUPPORTED;
          ^

netset.c:47:10: warning: 'return' with a value, in function returning void
   return SET_VAR_CHECK_VAL_READONLY;
          ^

netset.c:59:11: warning: 'return' with a value, in function returning void
    return SET_VAR_CHECK_VAL_SET_FAILED;
           ^

netset.c:63:11: warning: 'return' with a value, in function returning void
    return SET_VAR_CHECK_VAL_TOO_LONG;
           ^

netset.c:84:11: warning: 'return' with a value, in function returning void
    return SET_VAR_CHECK_VAL_INVALID_VALUE;
           ^

netset.c:106:11: warning: 'return' with a value, in function returning void
    return SET_VAR_CHECK_VAL_INVALID_VALUE;
           ^

netset.c:110:9: warning: 'return' with a value, in function returning void
  return SET_VAR_CHECK_VAL_OK;
         ^

netset.c:37:6: warning: unused variable 'have_tracking_id' [-Wunused-variable]
  int have_tracking_id = 0;
      ^

netset.c:36:17: warning: unused variable 'esc' [-Wunused-variable]
  char cmd[SMALLBUF], esc[SMALLBUF];
                 ^

netset.c:36:7: warning: unused variable 'cmd' [-Wunused-variable]
  char cmd[SMALLBUF], esc[SMALLBUF];
       ^

netset.c: At top level:

netset.c:113:13: error: conflicting types for 'set_var'
 static void set_var(nut_ctype_t *client, const char *upsname, const char *var,
             ^

netset.c:30:13: note: previous definition of 'set_var' was here
 static void set_var(nut_ctype_t *client, const char *upsname, const char *var,
             ^

netset.c: In function 'set_var':

netset.c:162:11: error: 'cmd' undeclared (first use in this function)
  snprintf(cmd, sizeof(cmd), "SET %s \"%s\"",
           ^

netset.c:163:29: error: 'esc' undeclared (first use in this function)
   var, pconf_encode(newval, esc, sizeof(esc)));
                             ^

netset.c:166:6: error: 'tracking_id' undeclared (first use in this function)
  if (tracking_id && *tracking_id) {
      ^

netset.c:170:3: error: 'have_tracking_id' undeclared (first use in this function)
   have_tracking_id = 1;
   ^

netset.c: In function 'net_set':

netset.c:225:3: error: too many arguments to function 'set_var'
   set_var(client, arg[1], arg[2], arg[3], tracking_id);
   ^
netset.c:113:13: note: declared here
 static void set_var(nut_ctype_t *client, const char *upsname, const char *var,
             ^

netset.c: At top level:
netset.c:30:13: warning: 'set_var' defined but not used [-Wunused-function]
 static void set_var(nut_ctype_t *client, const char *upsname, const char *var,
             ^

Makefile:554: recipe for target 'netset.o' failed
make[1]: *** [netset.o] Error 1
make[1]: Leaving directory '/home/travis/build/networkupstools/nut/server'
Makefile:549: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1

jimklimov avatar Oct 24 '20 18:10 jimklimov