Re: [RAUC] Antwort: Re: Antwort: Re: Antwort: Re: Antwort: Re: Antwort: D-Bus control Qt

2021-08-03 Thread Stahl, Michael
I solved my problems. Now I want to share my solution. Many thanks to Eugen 
Wiens who gave the most important input.

Summary:
1. Create a Data Class
2. Register the Data Class
3. Implement operators for marshalling
4. Install signal notification for PropertyChange signal
5. Pip the DBus data into the data class

1. Data Class
raucprogress.cpp
#include "raucprogress.h"


QDBusArgument <<(QDBusArgument , const RaucProgress& 
parameterProgress)

{

argument.beginStructure();

argument << parameterProgress.m_Progress;

argument << parameterProgress.m_Message;

argument << parameterProgress.m_Additional;

argument.endStructure();

return argument;

}


const QDBusArgument >>(const QDBusArgument , RaucProgress& 
parameterProgress)

{

argument.beginStructure();

argument >> parameterProgress.m_Progress;

argument >> parameterProgress.m_Message;

argument >> parameterProgress.m_Additional;

argument.endStructure();

return argument;

}


raucprogress.h

#ifndef RAUCPROGRESS_H


#define RAUCPROGRESS_H

#include 

#include 

#include 

#include 

class RaucProgress

{

public:

int m_Progress;

QString m_Message;

int m_Additional;

};

QDBusArgument <<(QDBusArgument , const RaucProgress 
);

const QDBusArgument >>(const QDBusArgument , RaucProgress 
);

#endif // RAUCPROGRESS_H


2. Register the Data Class

notifier.cpp:

// this is one of the magic statements

Q_DECLARE_METATYPE(RaucProgress)


3. Register the Data Class

notifier.cpp:

Notifier::Notifier()

{

qRegisterMetaType();

  qDBusRegisterMetaType();

}



4. Install signal notification for PropertyChange signal

notifier.cpp:

int Notifier::Init()


{

if (!QDBusConnection::sessionBus().isConnected()) {

 fprintf(stderr, "Cannot connect to the D-Bus session bus.\n"

 "To start it, run:\n"

 "\teval `dbus-launch --auto-syntax`\n");

 return 1;

 }

dbus_iface = new QDBusInterface ( "de.pengutronix.rauc",

  "/",

  "de.pengutronix.rauc.Installer",

  QDBusConnection::systemBus() );

if (dbus_iface->isValid() == false)

{

return 1;

}


connect(dbus_iface, SIGNAL(Completed(int)),this,SLOT(UpdateFinished(int)));


if (QDBusConnection::systemBus().connect("de.pengutronix.rauc", 
//Service

 "/",   
//Path

 "org.freedesktop.DBus.Properties", 
//Interface

 "PropertiesChanged",

 this,

 SLOT(propertyChanged(const 
QString& ,

  const 
QMap& ,

  const 
QStringList&  {

qDebug() << "PropertiesChanged signal connected successfully to slot";

} else {

 qDebug() << "PropertiesChanged signal connection was not successful";

 return 1;

}

return 0;

}


5. Pip the DBus data into the data class

notifier.cpp


void Notifier::propertyChanged(const QString text , const QMap map, const QStringList list){


RaucProgress parameterProgress;

map["Progress"].value() >> parameterProgress;

qDebug() << parameterProgress.m_Progress;

    qDebug() << parameterProgress.m_Message;

}


I hope it can be useful for people who have similar problems as I.


Kind Regards


Michael



Von: eugen.wi...@jumo.net 
Gesendet: Dienstag, 3. August 2021 13:14
An: Stahl, Michael 
Cc: RAUC@pengutronix.de ; RAUC 

Betreff: Antwort: Re: [RAUC] Antwort: Re: Antwort: Re: Antwort: Re: Antwort: 
D-Bus control Qt

Hi Michael,

sounds good.



Von:"Stahl, Michael" 
An:"RAUC@pengutronix.de" 
Kopie:RAUC 
Datum:03.08.2021 13:00
Betreff:Re: [RAUC] Antwort: Re: Antwort: Re: Antwort: Re: Antwort: 
D-Bus control Qt
Gesendet von:"RAUC" 




I found the issue

You have to connect to the systemBus not to the sessionBus!

if(QDBusConnection::systemBus().connect("de.pengutronix.rauc",  
  //Service
 "/",  //Path
 "org.freedesktop.DBus.Properties",//Interface
 "PropertiesChanged",
   

Re: [RAUC] Antwort: Re: Antwort: Re: Antwort: Re: Antwort: D-Bus control Qt

2021-08-03 Thread Stahl, Michael
I found the issue

You have to connect to the systemBus not to the sessionBus!

if (QDBusConnection::systemBus().connect("de.pengutronix.rauc", 
//Service

 "/",   //Path

 "org.freedesktop.DBus.Properties", //Interface

 "PropertiesChanged",

 this,

 SLOT(propertyChanged(const QString& ,

  const QMap& ,

  const QStringList&  {


qDebug() << "PropertiesChanged signal connected successfully to slot";

} else {

qDebug() << "PropertiesChanged signal connection was not successful";

}

Now I my function propertyChanged is called every time the property changes.

If you use
export QDBUS_DEBUG=1
you get a lot of debug output. It is very useful.

The next step is to extract the informations of the QMap.



Von: Stahl, Michael 
Gesendet: Dienstag, 3. August 2021 10:27
An: eugen.wi...@jumo.net 
Cc: RAUC@pengutronix.de ; RAUC 

Betreff: AW: Antwort: Re: [RAUC] Antwort: Re: Antwort: Re: Antwort: D-Bus 
control Qt

Hi Euen,

I know but I am stucking. I am polling the propery "Operation". Just when it 
changes from "idle" to "installing" I subscribe the PropertiesChanged signal 
but without success. I tried several connect strings but all without success.


if (QDBusConnection::sessionBus().connect("de.pengutronix.rauc",

 "/",

 "org.freedesktop.DBus.Properties",

 "PropertiesChanged",

 this,

 SLOT(propertyChanged(const QString& ,

  const QMap& ,

  const QStringList& 

{

qDebug() << "PropertiesChanged signal connected successfully to slot";

} else {

qDebug() << "PropertiesChanged signal connection was not successful";

}

Please can you tell me how to subcribe the PropertiesChanged signal?


Von: eugen.wi...@jumo.net 
Gesendet: Dienstag, 3. August 2021 08:27
An: Stahl, Michael 
Cc: RAUC@pengutronix.de ; RAUC 

Betreff: Antwort: Re: [RAUC] Antwort: Re: Antwort: Re: Antwort: D-Bus control Qt

Hi Michael,

you can connect to a property change on dbus level. That is the way we do it.


"RAUC"  schrieb am 03.08.2021 08:21:32:

> Von: "Stahl, Michael" 
> An: "eugen.wi...@jumo.net" 
> Kopie: "RAUC" , "RAUC@pengutronix.de"
> 
> Datum: 03.08.2021 08:21
> Betreff: Re: [RAUC] Antwort: Re:  Antwort: Re:  Antwort:  D-Bus control Qt
> Gesendet von: "RAUC" 
>
> Hi Eugen,
>
> thanks again. I implemented the signal and now I get the signal that
> the update is finished.
> But thats the only signal that rauc is provided, isn't it? To get
> the progress I have to poll the property, or are there general
> signals on the dbus that I can connect to?
>
> Do you read the property "Progress" like
> QDBusInterface iface( "de.pengutronix.rauc",
>  "/",
>  "de.pengutronix.rauc.Installer",
>  QDBusConnection::systemBus() );
> QVariant property = iface.property("Progress");
> MyProgress parameterProgress;
> property.value() >> parameterProgress;
>
> or did you use another possibility?
> If I use the above I get a message five times and the marshaled data (
> m_Progress, m_Message, ..) are always empty.
> QDBusArgument: read from a write-only object

>
> Von: eugen.wi...@jumo.net 
> Gesendet: Montag, 2. August 2021 16:53
> An: Stahl, Michael 
> Cc: RAUC@pengutronix.de ; RAUC  boun...@pengutronix.de>
> Betreff: Antwort: Re: [RAUC] Antwort: Re: Antwort: D-Bus control Qt
>
> Hi Michael,
>
> "RAUC"  schrieb am 02.08.2021 16:29:18:
>
> > Von: "Stahl, Michael" 
> > An: "eugen.wi...@jumo.net" 
> > Kopie: RAUC , "RAUC@pengutronix.de"
> > 
> > Datum: 02.08.2021 16:29
> > Betreff: Re: [RAUC] Antwort: Re:  Antwort:  D-Bus control Qt
> > Gesendet von: "RAUC" 
> >
> > Okay, thanks a lot.
> >
> > A last question. Is it correct that I have to poll the "Progress"
> > property or is there any signal system where I can subcribe to get a
> > notifi

Re: [RAUC] Antwort: Re: Antwort: Re: Antwort: Re: Antwort: D-Bus control Qt

2021-08-03 Thread Stahl, Michael
I found the issue

You have to connect to the systemBus not to the sessionBus!

if (QDBusConnection::systemBus().connect("de.pengutronix.rauc", 
//Service

 "/",   //Path

 "org.freedesktop.DBus.Properties", //Interface

 "PropertiesChanged",

 this,

 SLOT(propertyChanged(const QString& ,

  const QMap& ,

  const QStringList&  {


qDebug() << "PropertiesChanged signal connected successfully to slot";

} else {

qDebug() << "PropertiesChanged signal connection was not successful";

}

Now I my function propertyChanged is called every time the property changes.

If you use

Von: RAUC  im Auftrag von Stahl, Michael 

Gesendet: Dienstag, 3. August 2021 10:27
An: eugen.wi...@jumo.net 
Cc: RAUC ; RAUC@pengutronix.de 

Betreff: Re: [RAUC] Antwort: Re: Antwort: Re: Antwort: Re: Antwort: D-Bus 
control Qt

Hi Euen,

I know but I am stucking. I am polling the propery "Operation". Just when it 
changes from "idle" to "installing" I subscribe the PropertiesChanged signal 
but without success. I tried several connect strings but all without success.


if (QDBusConnection::sessionBus().connect("de.pengutronix.rauc",

 "/",

 "org.freedesktop.DBus.Properties",

 "PropertiesChanged",

 this,

 SLOT(propertyChanged(const QString& ,

  const QMap& ,

  const QStringList& 

{

qDebug() << "PropertiesChanged signal connected successfully to slot";

} else {

qDebug() << "PropertiesChanged signal connection was not successful";

}

Please can you tell me how to subcribe the PropertiesChanged signal?


Von: eugen.wi...@jumo.net 
Gesendet: Dienstag, 3. August 2021 08:27
An: Stahl, Michael 
Cc: RAUC@pengutronix.de ; RAUC 

Betreff: Antwort: Re: [RAUC] Antwort: Re: Antwort: Re: Antwort: D-Bus control Qt

Hi Michael,

you can connect to a property change on dbus level. That is the way we do it.


"RAUC"  schrieb am 03.08.2021 08:21:32:

> Von: "Stahl, Michael" 
> An: "eugen.wi...@jumo.net" 
> Kopie: "RAUC" , "RAUC@pengutronix.de"
> 
> Datum: 03.08.2021 08:21
> Betreff: Re: [RAUC] Antwort: Re:  Antwort: Re:  Antwort:  D-Bus control Qt
> Gesendet von: "RAUC" 
>
> Hi Eugen,
>
> thanks again. I implemented the signal and now I get the signal that
> the update is finished.
> But thats the only signal that rauc is provided, isn't it? To get
> the progress I have to poll the property, or are there general
> signals on the dbus that I can connect to?
>
> Do you read the property "Progress" like
> QDBusInterface iface( "de.pengutronix.rauc",
>  "/",
>  "de.pengutronix.rauc.Installer",
>  QDBusConnection::systemBus() );
> QVariant property = iface.property("Progress");
> MyProgress parameterProgress;
> property.value() >> parameterProgress;
>
> or did you use another possibility?
> If I use the above I get a message five times and the marshaled data (
> m_Progress, m_Message, ..) are always empty.
> QDBusArgument: read from a write-only object

>
> Von: eugen.wi...@jumo.net 
> Gesendet: Montag, 2. August 2021 16:53
> An: Stahl, Michael 
> Cc: RAUC@pengutronix.de ; RAUC  boun...@pengutronix.de>
> Betreff: Antwort: Re: [RAUC] Antwort: Re: Antwort: D-Bus control Qt
>
> Hi Michael,
>
> "RAUC"  schrieb am 02.08.2021 16:29:18:
>
> > Von: "Stahl, Michael" 
> > An: "eugen.wi...@jumo.net" 
> > Kopie: RAUC , "RAUC@pengutronix.de"
> > 
> > Datum: 02.08.2021 16:29
> > Betreff: Re: [RAUC] Antwort: Re:  Antwort:  D-Bus control Qt
> > Gesendet von: "RAUC" 
> >
> > Okay, thanks a lot.
> >
> > A last question. Is it correct that I have to poll the "Progress"
> > property or is there any signal system where I can subcribe to get a
> > notification at every change of progress status?
>
> We are using a dbus signal. You can connect to it with Q

Re: [RAUC] Antwort: Re: Antwort: Re: Antwort: Re: Antwort: D-Bus control Qt

2021-08-03 Thread Stahl, Michael
Hi Euen,

I know but I am stucking. I am polling the propery "Operation". Just when it 
changes from "idle" to "installing" I subscribe the PropertiesChanged signal 
but without success. I tried several connect strings but all without success.


if (QDBusConnection::sessionBus().connect("de.pengutronix.rauc",

 "/",

 "org.freedesktop.DBus.Properties",

 "PropertiesChanged",

 this,

 SLOT(propertyChanged(const QString& ,

  const QMap& ,

  const QStringList& 

{

qDebug() << "PropertiesChanged signal connected successfully to slot";

} else {

qDebug() << "PropertiesChanged signal connection was not successful";

}

Please can you tell me how to subcribe the PropertiesChanged signal?

____
Von: eugen.wi...@jumo.net 
Gesendet: Dienstag, 3. August 2021 08:27
An: Stahl, Michael 
Cc: RAUC@pengutronix.de ; RAUC 

Betreff: Antwort: Re: [RAUC] Antwort: Re: Antwort: Re: Antwort: D-Bus control Qt

Hi Michael,

you can connect to a property change on dbus level. That is the way we do it.


"RAUC"  schrieb am 03.08.2021 08:21:32:

> Von: "Stahl, Michael" 
> An: "eugen.wi...@jumo.net" 
> Kopie: "RAUC" , "RAUC@pengutronix.de"
> 
> Datum: 03.08.2021 08:21
> Betreff: Re: [RAUC] Antwort: Re:  Antwort: Re:  Antwort:  D-Bus control Qt
> Gesendet von: "RAUC" 
>
> Hi Eugen,
>
> thanks again. I implemented the signal and now I get the signal that
> the update is finished.
> But thats the only signal that rauc is provided, isn't it? To get
> the progress I have to poll the property, or are there general
> signals on the dbus that I can connect to?
>
> Do you read the property "Progress" like
> QDBusInterface iface( "de.pengutronix.rauc",
>  "/",
>  "de.pengutronix.rauc.Installer",
>  QDBusConnection::systemBus() );
> QVariant property = iface.property("Progress");
> MyProgress parameterProgress;
> property.value() >> parameterProgress;
>
> or did you use another possibility?
> If I use the above I get a message five times and the marshaled data (
> m_Progress, m_Message, ..) are always empty.
> QDBusArgument: read from a write-only object

>
> Von: eugen.wi...@jumo.net 
> Gesendet: Montag, 2. August 2021 16:53
> An: Stahl, Michael 
> Cc: RAUC@pengutronix.de ; RAUC  boun...@pengutronix.de>
> Betreff: Antwort: Re: [RAUC] Antwort: Re: Antwort: D-Bus control Qt
>
> Hi Michael,
>
> "RAUC"  schrieb am 02.08.2021 16:29:18:
>
> > Von: "Stahl, Michael" 
> > An: "eugen.wi...@jumo.net" 
> > Kopie: RAUC , "RAUC@pengutronix.de"
> > 
> > Datum: 02.08.2021 16:29
> > Betreff: Re: [RAUC] Antwort: Re:  Antwort:  D-Bus control Qt
> > Gesendet von: "RAUC" 
> >
> > Okay, thanks a lot.
> >
> > A last question. Is it correct that I have to poll the "Progress"
> > property or is there any signal system where I can subcribe to get a
> > notification at every change of progress status?
>
> We are using a dbus signal. You can connect to it with Qt.
>
> Best regards,
> Eugen
> Diese E-Mail kann vertrauliche und/oder rechtlich gesch?tzte
> Informationen beinhalten und ist ausschlie?lich f?r die im Verteiler
> genannten Personen bestimmt. Das unerlaubte Kopieren sowie die
> unbefugte Weitergabe dieser Mail sind nicht gestattet. Bitte
> benachrichtigen Sie uns gegebenenfalls telefonisch oder mit Antwort-
> Mail, falls Sie nicht der richtige Adressat dieser E-Mail sind.
> Bitte l?schen Sie diese Nachricht und alle Anh?nge dazu unverz?
> glich. Falls nicht ausdr?cklich vermerkt, ist diese E-Mail keine
> rechtlich bindende Vereinbarung.
>
> Kommanditgesellschaft: JUMO GmbH & Co. KG, Sitz: 36039 Fulda,
> Amtsgericht Fulda HRA 302, Pers?nlich haftende Gesellschafterin: M.
> K. JUCHHEIM GmbH, Sitz: 36039 Fulda, Amtsgericht Fulda HRB 17,
> Gesch?ftsf?hrer: Dipl.-Ing. Bernhard Juchheim, Dipl.-Kfm. Michael
> Juchheim, Dipl.-Ing. Dimitrios Charisiadis
> Ust.-Id.-Nr.: DE 112411234___
> RAUC mailing list

Diese E-Mail kann vertrauliche und/oder rechtlich gesch?tzte Informationen 
beinhalten und ist ausschlie?lich f?r die im Verteiler genannten Personen 
bestimmt. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Ma

Re: [RAUC] Antwort: Re: Antwort: Re: Antwort: D-Bus control Qt

2021-08-03 Thread Stahl, Michael
Hi Eugen,

thanks again. I implemented the signal and now I get the signal that the update 
is finished.
But thats the only signal that rauc is provided, isn't it? To get the progress 
I have to poll the property, or are there general signals on the dbus that I 
can connect to?

Do you read the property "Progress" like
QDBusInterface iface( "de.pengutronix.rauc",

 "/",

 "de.pengutronix.rauc.Installer",

 QDBusConnection::systemBus() );

QVariant property = iface.property("Progress");

MyProgress parameterProgress;

property.value() >> parameterProgress;

or did you use another possibility?
If I use the above I get a message five times and the marshaled data 
(m_Progress, m_Message, ..) are always empty.
QDBusArgument: read from a write-only object





Von: eugen.wi...@jumo.net 
Gesendet: Montag, 2. August 2021 16:53
An: Stahl, Michael 
Cc: RAUC@pengutronix.de ; RAUC 

Betreff: Antwort: Re: [RAUC] Antwort: Re: Antwort: D-Bus control Qt

Hi Michael,

"RAUC"  schrieb am 02.08.2021 16:29:18:

> Von: "Stahl, Michael" 
> An: "eugen.wi...@jumo.net" 
> Kopie: RAUC , "RAUC@pengutronix.de"
> 
> Datum: 02.08.2021 16:29
> Betreff: Re: [RAUC] Antwort: Re:  Antwort:  D-Bus control Qt
> Gesendet von: "RAUC" 
>
> Okay, thanks a lot.
>
> A last question. Is it correct that I have to poll the "Progress"
> property or is there any signal system where I can subcribe to get a
> notification at every change of progress status?

We are using a dbus signal. You can connect to it with Qt.

Best regards,
Eugen

Diese E-Mail kann vertrauliche und/oder rechtlich gesch?tzte Informationen 
beinhalten und ist ausschlie?lich f?r die im Verteiler genannten Personen 
bestimmt. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail 
sind nicht gestattet. Bitte benachrichtigen Sie uns gegebenenfalls telefonisch 
oder mit Antwort-Mail, falls Sie nicht der richtige Adressat dieser E-Mail 
sind. Bitte l?schen Sie diese Nachricht und alle Anh?nge dazu unverz?glich. 
Falls nicht ausdr?cklich vermerkt, ist diese E-Mail keine rechtlich bindende 
Vereinbarung.

Kommanditgesellschaft: JUMO GmbH & Co. KG, Sitz: 36039 Fulda, Amtsgericht Fulda 
HRA 302, Pers?nlich haftende Gesellschafterin: M. K. JUCHHEIM GmbH, Sitz: 36039 
Fulda, Amtsgericht Fulda HRB 17, Gesch?ftsf?hrer: Dipl.-Ing. Bernhard Juchheim, 
Dipl.-Kfm. Michael Juchheim, Dipl.-Ing. Dimitrios Charisiadis
Ust.-Id.-Nr.: DE 112411234
___
RAUC mailing list


Re: [RAUC] Antwort: Re: Antwort: D-Bus control Qt

2021-08-02 Thread Stahl, Michael
Okay, thanks a lot.

A last question. Is it correct that I have to poll the "Progress" property or 
is there any signal system where I can subcribe to get a notification at every 
change of progress status?




Von: eugen.wi...@jumo.net 
Gesendet: Montag, 2. August 2021 15:36
An: Stahl, Michael 
Cc: RAUC@pengutronix.de ; RAUC 

Betreff: Antwort: Re: [RAUC] Antwort: D-Bus control Qt

Hi Michael,

"RAUC"  schrieb am 02.08.2021 15:20:25:

> Von: "Stahl, Michael" 
> An: "eugen.wi...@jumo.net" 
> Kopie: "RAUC@pengutronix.de" 
> Datum: 02.08.2021 15:20
> Betreff: Re: [RAUC] Antwort:  D-Bus control Qt
> Gesendet von: "RAUC" 
>
> Hi Eugen,
>
> I think I got it.
>
> MyProgress.cpp:
> Q_DECLARE_METATYPE(MyProgress)
>
> QDBusArgument <<(QDBusArgument , const MyProgress&
> parameterProgress)
> {
> argument.beginStructure();
> argument << parameterProgress.m_Progress;
> argument << parameterProgress.m_Message;
> argument << parameterProgress.m_Additional;
> argument.endStructure();
> return argument;
> }
>
> const QDBusArgument >>(const QDBusArgument , MyProgress&
> parameterProgress)
> {
> argument.beginStructure();
> argument >> parameterProgress.m_Progress;
> argument >> parameterProgress.m_Message;
> argument >> parameterProgress.m_Additional;
> argument.endStructure();
> return argument;
> }
>
> MyProgress ::MyProgress(){
> qRegisterMetaType();
> qDBusRegisterMetaType();
> }
>
> MyProgress.h:
> #ifndef MYPROGRESS_H

> #define MYPROGRESS_H
>

> #include 
> #include 
> #include 
> #include 
>
> class MyProgress
> {
> public:
> MyProgress();
> ~MyProgress();
> int m_Progress;
> QString m_Message;
> int m_Additional;
> public slots:
> friend QDBusArgument <<(QDBusArgument , const
> RaucProgress );
> friend const QDBusArgument >>(const QDBusArgument ,
> RaucProgress );
> };
> #endif // MYPROGRESS_H
>
> update.cpp:
> ...
> QDBusInterface interface( "de.pengutronix.rauc",

>   "/",
>   "de.pengutronix.rauc.Installer",
>   QDBusConnection::systemBus() );
>
> if (interface.isValid() == true)
> {
> qDebug() << "interface is valid";
>   qDebug() << "Read property (Progress)";
>QVariant property = interface.property("Progress");
>   property.value() >> parameterProgress;
>qDebug() << parameterProgress.m_Progress;
>qDebug() << parameterProgress.m_Message;
>  }
> ...
>
> parameterProgress is delcared in the update.h
>
> I have a last question. Maybe you can answer it. Why have I add the
> keyword "friend" in front of the QDBusArguments? I wount compile without it.
If you add the operators as a member, you Qt has problem to find them. We 
implement the operators outside of the class. As "normal" functions not as 
Member Methods. Qt is searching "operator >> ( Type, Type)" and not as Member 
of a class.

>
> Many thanks.
>
> Kind regards
> Michael
>
> Von: RAUC  im Auftrag von Stahl,
> Michael 
> Gesendet: Montag, 2. August 2021 14:45
> An: eugen.wi...@jumo.net 
> Cc: RAUC@pengutronix.de 
> Betreff: Re: [RAUC] Antwort: D-Bus control Qt
>
> Hi Eugen,
>
> thanks for the informations. They were very useful. Some lines are
> familiar to me because I tested a lot.
> But I still need some support.
>
> This is the way I request the property:
>
> MyProgress parameterProgress;
> QDBusInterface interface( "de.pengutronix.rauc",
> "/",
> "de.pengutronix.rauc.Installer",
> QDBusConnection::systemBus() );
> QVariant property = interface.property("Progress");
> property.value() >> parameterProgress;
>
> No I get a compiler error:
> no match for operator>>'(opernad types are 'QDBusArgument' and 'MyProgress')
>
> I think I do the registration an the installing of the oparators wrong.
>
> The registration is done in the constructor of MyProgress:
> MyProgress ::MyProgress(){
> qRegisterMetaType();
> qDBusRegisterMetaType();
> }
>
> The magic statement I place in top of my MyProcess.cpp
> // this is one of the magic statements
> Q_DECLARE_METATYPE(MyProgress)
>
> But where exactly do you place the operators? Al

Re: [RAUC] Antwort: D-Bus control Qt

2021-08-02 Thread Stahl, Michael
Hi Eugen,

I think I got it.

MyProgress.cpp:
Q_DECLARE_METATYPE(MyProgress)


QDBusArgument <<(QDBusArgument , const MyProgress& 
parameterProgress)

{

argument.beginStructure();

argument << parameterProgress.m_Progress;

argument << parameterProgress.m_Message;

argument << parameterProgress.m_Additional;

argument.endStructure();

return argument;

}


const QDBusArgument >>(const QDBusArgument , MyProgress& 
parameterProgress)

{

argument.beginStructure();

argument >> parameterProgress.m_Progress;

argument >> parameterProgress.m_Message;

argument >> parameterProgress.m_Additional;

argument.endStructure();

return argument;

}



MyProgress ::MyProgress(){

qRegisterMetaType();

qDBusRegisterMetaType();

}


MyProgress.h:

#ifndef MYPROGRESS_H


#define MYPROGRESS_H

#include 

#include 

#include 

#include 


class MyProgress

{

public:

MyProgress();

~MyProgress();

int m_Progress;

QString m_Message;

int m_Additional;

public slots:

friend QDBusArgument <<(QDBusArgument , const 
RaucProgress );

friend const QDBusArgument >>(const QDBusArgument , 
RaucProgress );

};

#endif // MYPROGRESS_H



update.cpp:

...

QDBusInterface interface( "de.pengutronix.rauc",


  "/",

  "de.pengutronix.rauc.Installer",

  QDBusConnection::systemBus() );


if (interface.isValid() == true)

{

qDebug() << "interface is valid";

  qDebug() << "Read property (Progress)";

   QVariant property = interface.property("Progress");

  property.value() >> parameterProgress;

   qDebug() << parameterProgress.m_Progress;

   qDebug() << parameterProgress.m_Message;

}

...



parameterProgress is delcared in the update.h


I have a last question. Maybe you can answer it. Why have I add the keyword 
"friend" in front of the QDBusArguments? I wount compile without it.


Many thanks.


Kind regards

Michael





Von: RAUC  im Auftrag von Stahl, Michael 

Gesendet: Montag, 2. August 2021 14:45
An: eugen.wi...@jumo.net 
Cc: RAUC@pengutronix.de 
Betreff: Re: [RAUC] Antwort: D-Bus control Qt

Hi Eugen,

thanks for the informations. They were very useful. Some lines are familiar to 
me because I tested a lot.
But I still need some support.

This is the way I request the property:

MyProgress parameterProgress;
QDBusInterface interface( "de.pengutronix.rauc",

"/",

"de.pengutronix.rauc.Installer",

QDBusConnection::systemBus() );

QVariant property = interface.property("Progress");

property.value() >> parameterProgress;


No I get a compiler error:

no match for operator>>'(opernad types are 'QDBusArgument' and 'MyProgress')


I think I do the registration an the installing of the oparators wrong.


The registration is done in the constructor of MyProgress:

MyProgress ::MyProgress(){

qRegisterMetaType();

qDBusRegisterMetaType();

}


The magic statement I place in top of my MyProcess.cpp
// this is one of the magic statements
Q_DECLARE_METATYPE(MyProgress)

But where exactly do you place the operators? Also in the MyProcess.cpp?
QDBusArgument <<(QDBusArgument , const MyProgress& 
parameterProgress);
const QDBusArgument >>(const QDBusArgument , MyProgress& 
parameterProgress);
QDBusArgument <<(QDBusArgument , const MyProgress& 
parameterProgress)
{
argument.beginStructure();
argument << parameterProgress.m_Progress;
argument << parameterProgress.m_Message;
argument << parameterProgress.m_Additional;
argument.endStructure();
return argument;
}
const QDBusArgument >>(const QDBusArgument , MyProgress& 
parameterProgress)
{
argument.beginStructure();
argument >> parameterProgress.m_Progress;
argument >> parameterProgress.m_Message;
argument >> parameterProgress.m_Additional;
argument.endStructure();
return argument;
}

It seems like I am only a few millimeters away from my goal.

Thanks


Von: eugen.wi...@jumo.net 
Gesendet: Montag, 2. August 2021 13:41
An: Stahl, Michael 
Cc: RAUC@pengutronix.de 
Betreff: Antwort: [RAUC] D-Bus control Qt

Hi Michael,

"RAUC"  schrieb am 02.08.2021 08:15:26:

> Von: "Stahl, Michael" 
> An: "RAUC@pengutronix.de" 
> Datum: 02.08.2021 08:15
> Betreff: [RAUC] D-Bus control Qt
> Gesendet von: "RAUC" 
>
> Is there someone who implemented the DBus Property "Progress" into a
> Qt-Application? The problem seems the return value isi (Inte

Re: [RAUC] Antwort: D-Bus control Qt

2021-08-02 Thread Stahl, Michael
Hi Eugen,

thanks for the informations. They were very useful. Some lines are familiar to 
me because I tested a lot.
But I still need some support.

This is the way I request the property:

MyProgress parameterProgress;
QDBusInterface interface( "de.pengutronix.rauc",

"/",

"de.pengutronix.rauc.Installer",

QDBusConnection::systemBus() );

QVariant property = interface.property("Progress");

property.value() >> parameterProgress;


No I get a compiler error:

no match for operator>>'(opernad types are 'QDBusArgument' and 'MyProgress')


I think I do the registration an the installing of the oparators wrong.


The registration is done in the constructor of MyProgress:

MyProgress ::MyProgress(){

qRegisterMetaType();

qDBusRegisterMetaType();

}


The magic statement I place in top of my MyProcess.cpp
// this is one of the magic statements
Q_DECLARE_METATYPE(MyProgress)

But where exactly do you place the operators? Also in the MyProcess.cpp?
QDBusArgument <<(QDBusArgument , const MyProgress& 
parameterProgress);
const QDBusArgument >>(const QDBusArgument , MyProgress& 
parameterProgress);
QDBusArgument <<(QDBusArgument , const MyProgress& 
parameterProgress)
{
argument.beginStructure();
argument << parameterProgress.m_Progress;
argument << parameterProgress.m_Message;
argument << parameterProgress.m_Additional;
argument.endStructure();
return argument;
}
const QDBusArgument >>(const QDBusArgument , MyProgress& 
parameterProgress)
{
argument.beginStructure();
argument >> parameterProgress.m_Progress;
argument >> parameterProgress.m_Message;
argument >> parameterProgress.m_Additional;
argument.endStructure();
return argument;
}

It seems like I am only a few millimeters away from my goal.

Thanks


Von: eugen.wi...@jumo.net 
Gesendet: Montag, 2. August 2021 13:41
An: Stahl, Michael 
Cc: RAUC@pengutronix.de 
Betreff: Antwort: [RAUC] D-Bus control Qt

Hi Michael,

"RAUC"  schrieb am 02.08.2021 08:15:26:

> Von: "Stahl, Michael" 
> An: "RAUC@pengutronix.de" 
> Datum: 02.08.2021 08:15
> Betreff: [RAUC] D-Bus control Qt
> Gesendet von: "RAUC" 
>
> Is there someone who implemented the DBus Property "Progress" into a
> Qt-Application? The problem seems the return value isi (Integer,
> String, Integer).
> For all other properties with a single return value like "Operation"
> or "LastError" the Qt DBus API works fine.
> I found an email from 28.Oct 2019 in the mailing list where Bastian
> Krause had the same issue. The answer was only that he had to
> cunsult the Qt DBus documentation on how a tuple is mapped to Qt types.
>
> Thats a good hint but after hours of searching the web I didn't find
> a solution. The return value for a property is QVariant in Qt.
>
> Trial 1 -> Read value by iface.property("Progress"):
> This is the error message I got when I try to read the progress property:
> Cannot construct placeholder type QDBusRawType
>
> Trial 2 -> Read value by iface.call("Get",...):
> Not able to get any information. The arguments of the returned
> QDBusMessages are always empty!
That is the way we implemented it:

On Qt there are some pitfalls and you has to marshaling the data.

1. Create a Data Class

#include 
#include 
#include 

class MyProgress
{
public:
[...]
int m_Progress;
QString m_Message;
int m_Additional;
};

// this is one of the magic statements
Q_DECLARE_METATYPE(MyProgress)
QDBusArgument <<(QDBusArgument , const MyProgress& 
parameterProgress);
const QDBusArgument >>(const QDBusArgument , MyProgress& 
parameterProgress);
};

You has to register the metatype and implement the operators. In the 
Constructor you has to add two register Methods

qRegisterMetaType();
qDBusRegisterMetaType();

After this tree registrations your Class MyProgress is known by Qt Metatype 
System. Now you has to implement operators

QDBusArgument <<(QDBusArgument , const MyProgress& 
parameterProgress)
{
argument.beginStructure();
argument << parameterProgress.m_Progress;
argument << parameterProgress.m_Message;
argument << parameterProgress.m_Additional;
argument.endStructure();
return argument;
}
const QDBusArgument >>(const QDBusArgument , MyProgress& 
parameterProgress)
{
argument.beginStructure();
argument >> parameterProgress.m_Progress;
argument >> parameterProgress.m_Message;
argument >> parameterProgress.m_Additional;
argument.endStructure();
return argument;
}

Now you are finished with preparing how to use it. In the Qt Slot of the D

[RAUC] D-Bus control Qt

2021-08-02 Thread Stahl, Michael
Is there someone who implemented the DBus Property "Progress" into a 
Qt-Application? The problem seems the return value isi (Integer, String, 
Integer).
For all other properties with a single return value like "Operation" or 
"LastError" the Qt DBus API works fine.
I found an email from 28.Oct 2019 in the mailing list where Bastian Krause had 
the same issue. The answer was only that he had to cunsult the Qt DBus 
documentation on how a tuple is mapped to Qt types.

Thats a good hint but after hours of searching the web I didn't find a 
solution. The return value for a property is QVariant in Qt.

Trial 1 -> Read value by iface.property("Progress"):
This is the error message I got when I try to read the progress property:
Cannot construct placeholder type QDBusRawType

Trial 2 -> Read value by iface.call("Get",...):
Not able to get any information. The arguments of the returned QDBusMessages 
are always empty!


___
RAUC mailing list


[RAUC] remove trailing whitespaces at slot-type

2021-03-16 Thread Stahl, Michael
I just searched some hours because rauc wount update my rootfs. The message was:
Installation error: Unsupported image /run/rauc/bundle/MyRootfs.tar.gz

I found out that I had some trailing whitespaces in the system.conf at type=ext4
Because of that the g_pattern_match_simpel function in get_update_handler 
(update_handler.c) didn't match.

Maybe it is possible to remove trailing whitespaces before calling 
g_pattern_match_simple function in future.





___
RAUC mailing list