Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. DBus reply data accessed via QString
QtWS25 Last Chance

DBus reply data accessed via QString

Scheduled Pinned Locked Moved Solved General and Desktop
dbusmethodqstringqvariantqlist
22 Posts 3 Posters 11.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    amonR2
    wrote on 13 Jun 2016, 00:52 last edited by A Former User 7 Jan 2016, 07:30
    #1

    Hi, I would like to put the result from a DBus method inside a QString or access it via one or more QString. Let me explain: when I write this code

    QDBusInterface *iface_Clementine = new QDBusInterface("org.mpris.clementine", "/Player", "org.freedesktop.MediaPlayer", QDBusConnection::sessionBus(), this);
    if(iface_Clementine->isValid()) {
    replyClementine = iface_Clementine->call("GetMetadata");
    qDebug() << reponseClementine;
    } 
    

    I receive the following result:

    QDBusMessage(type=MethodReturn, service=":1.154", signature="a{sv}", contents=([Argument: a{sv} {"album" = [Variant(QString): "Masta Blasta EP"], "artist" = [Variant(QString): "Lee Foss"], "arturl" = [Variant(QString): "file:///tmp/clementine-art-yY3324.jpg"], "audio-bitrate" = [Variant(int): 320], "audio-samplerate" = [Variant(int): 44100], "genre" = [Variant(QString): "Deep House"], "location" = [Variant(QString): "file:///home/JohnD/Music/Lee Foss/Lee Foss - Masta Blasta EP [MEXA001]/1_Masta_Blasta_Original_Mix.mp3"], "mtime" = [Variant(int): 364000], "rating" = [Variant(int): 6], "time" = [Variant(int): 364], "title" = [Variant(QString): "Masta Blasta (Original Mix)"], "year" = [Variant(int): 2012]}]) ) 
    

    How can I access the elements of the reply such as "artist" and "album" via one or more QStrings?
    Cheers.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      micland
      wrote on 13 Jun 2016, 08:49 last edited by micland
      #2

      QDBusMessage is a struct that holds the reply and some further meta data like error codes etc.
      Check QDBusMessage::arguments() to get a list of all arguments as list of QVariants and QVariant provides a toString() method. (see http://doc.qt.io/qt-5/qdbusmessage.html#arguments)

          QDBusMessage reply = dbusInterface->call(...);
          QList<QVariant> args = reply.arguments();
          if (args.count() != 3) {
              qCritical("Got no valid DBus response");
          } else {
              QString a0 = args.at(0).toString();
              QString a1 = args.at(1).toString();
              QStirng a2 = args.at(2).toString();
              // ....
          }
      

      QVariant provides also methods to convert to other types if you expect an int or something else in the reply.

      And: If you expect just one value, you can assign the QDBusMessage directly to a QDbusReply:

          QDBusReply<QString> reply = dbusInterface->call(...);
          if (reply.isValid()) {
              QString reply = reply.value());
              // ...
          } else {
              qCritical("Got no valid DBus response");
          }
      

      btw, Qt brings a the qdbusviewer which is very useful to inspect the provided DBus interfaces and methods of running processes...

      1 Reply Last reply
      5
      • A Offline
        A Offline
        amonR2
        wrote on 13 Jun 2016, 23:34 last edited by
        #3

        Hi Micland, thank you a lot for your answer. However when I adapt your code to mine in that way:

        iface_Clementine = new QDBusInterface("org.mpris.clementine", "/Player", "org.freedesktop.MediaPlayer", QDBusConnection::sessionBus(), this);
        replyClementine = iface_Clementine->call("GetMetadata");
        QList<QVariant> args = replyClementine.arguments();
        if (args.count() == 0) {
                qCritical("Got no valid DBus response");
            } 
        else {
                QString a1 = args.at(1).toString();
                qDebug() << a1;
        }
        

        I get the following result: "", In other word an empty string. Sometimes my app crashes. Why?

        K M 2 Replies Last reply 14 Jun 2016, 03:56
        0
        • A amonR2
          13 Jun 2016, 23:34

          Hi Micland, thank you a lot for your answer. However when I adapt your code to mine in that way:

          iface_Clementine = new QDBusInterface("org.mpris.clementine", "/Player", "org.freedesktop.MediaPlayer", QDBusConnection::sessionBus(), this);
          replyClementine = iface_Clementine->call("GetMetadata");
          QList<QVariant> args = replyClementine.arguments();
          if (args.count() == 0) {
                  qCritical("Got no valid DBus response");
              } 
          else {
                  QString a1 = args.at(1).toString();
                  qDebug() << a1;
          }
          

          I get the following result: "", In other word an empty string. Sometimes my app crashes. Why?

          K Offline
          K Offline
          kshegunov
          Moderators
          wrote on 14 Jun 2016, 03:56 last edited by
          #4

          @amonR2
          You should check the obtained interface and the reply for validity before doing anything with them. As for the crash, run it through the debugger, if having trouble paste the stack trace here.

          Kind regards.

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply
          0
          • A amonR2
            13 Jun 2016, 23:34

            Hi Micland, thank you a lot for your answer. However when I adapt your code to mine in that way:

            iface_Clementine = new QDBusInterface("org.mpris.clementine", "/Player", "org.freedesktop.MediaPlayer", QDBusConnection::sessionBus(), this);
            replyClementine = iface_Clementine->call("GetMetadata");
            QList<QVariant> args = replyClementine.arguments();
            if (args.count() == 0) {
                    qCritical("Got no valid DBus response");
                } 
            else {
                    QString a1 = args.at(1).toString();
                    qDebug() << a1;
            }
            

            I get the following result: "", In other word an empty string. Sometimes my app crashes. Why?

            M Offline
            M Offline
            micland
            wrote on 14 Jun 2016, 06:28 last edited by
            #5

            @amonR2 said:

            I get the following result: "", In other word an empty string. Sometimes my app crashes. Why?

            Did you run the qdbusviewer (separate tool shipped with Qt) and inspect your interface manually? Does this viewer also get an empty string or anything else? If you get a valid answer using Qt I guess the backends is sending an empty string...

            1 Reply Last reply
            0
            • A Offline
              A Offline
              amonR2
              wrote on 15 Jun 2016, 02:57 last edited by
              #6

              @ Kshegunov, thanks for your help. To check if the obtained interface is valid, is this code correct:

              iface_Clementine = new QDBusInterface("org.mpris.clementine", "/Player", "org.freedesktop.MediaPlayer", QDBusConnection::sessionBus(), this);
              
              if (!iface_Clementine->isValid()) {
              qCritical("The player is not nactive");
              }
              else{
              replyClementine = iface_Clementine->call("GetMetadata");
              QList<QVariant> args = replyClementine.arguments();
              
              if (args.count() == 0) {
              qCritical("Got no valid DBus response");
              					    } 
              else {
                     QString a1 = args.at(1).toString();
                     qDebug() << a1;
                   }
              }
              

              But how do you do to check if the reply is valid?

              @ micland, yes I ran qdbusviewer and obtained a message like the one I put in my first post://Received reply from :1.156 Arguments: [Argument: a{sv} {"album" = [Variant(QString): "In Search of..."], "artist" = [Variant(QString): "N.E.R.D."],...] . The only difference was the name of the service that I changed in my code but I still get an empty string as result. Why the backend sends an empty string instead of the actual result? And in my code, if you notice, I check if the number of items in the list is null. Does Qt counts an empty string as an item?

              K M 2 Replies Last reply 15 Jun 2016, 03:25
              0
              • A amonR2
                15 Jun 2016, 02:57

                @ Kshegunov, thanks for your help. To check if the obtained interface is valid, is this code correct:

                iface_Clementine = new QDBusInterface("org.mpris.clementine", "/Player", "org.freedesktop.MediaPlayer", QDBusConnection::sessionBus(), this);
                
                if (!iface_Clementine->isValid()) {
                qCritical("The player is not nactive");
                }
                else{
                replyClementine = iface_Clementine->call("GetMetadata");
                QList<QVariant> args = replyClementine.arguments();
                
                if (args.count() == 0) {
                qCritical("Got no valid DBus response");
                					    } 
                else {
                       QString a1 = args.at(1).toString();
                       qDebug() << a1;
                     }
                }
                

                But how do you do to check if the reply is valid?

                @ micland, yes I ran qdbusviewer and obtained a message like the one I put in my first post://Received reply from :1.156 Arguments: [Argument: a{sv} {"album" = [Variant(QString): "In Search of..."], "artist" = [Variant(QString): "N.E.R.D."],...] . The only difference was the name of the service that I changed in my code but I still get an empty string as result. Why the backend sends an empty string instead of the actual result? And in my code, if you notice, I check if the number of items in the list is null. Does Qt counts an empty string as an item?

                K Offline
                K Offline
                kshegunov
                Moderators
                wrote on 15 Jun 2016, 03:25 last edited by kshegunov
                #7

                @amonR2

                To check if the obtained interface is valid, is this code correct

                Yes.

                But how do you do to check if the reply is valid?

                I personally check it through a QDBusReply object (e.g. here). If using the dbus message class use QDBusAbstractInterface::lastError instead.

                Read and abide by the Qt Code of Conduct

                1 Reply Last reply
                1
                • A amonR2
                  15 Jun 2016, 02:57

                  @ Kshegunov, thanks for your help. To check if the obtained interface is valid, is this code correct:

                  iface_Clementine = new QDBusInterface("org.mpris.clementine", "/Player", "org.freedesktop.MediaPlayer", QDBusConnection::sessionBus(), this);
                  
                  if (!iface_Clementine->isValid()) {
                  qCritical("The player is not nactive");
                  }
                  else{
                  replyClementine = iface_Clementine->call("GetMetadata");
                  QList<QVariant> args = replyClementine.arguments();
                  
                  if (args.count() == 0) {
                  qCritical("Got no valid DBus response");
                  					    } 
                  else {
                         QString a1 = args.at(1).toString();
                         qDebug() << a1;
                       }
                  }
                  

                  But how do you do to check if the reply is valid?

                  @ micland, yes I ran qdbusviewer and obtained a message like the one I put in my first post://Received reply from :1.156 Arguments: [Argument: a{sv} {"album" = [Variant(QString): "In Search of..."], "artist" = [Variant(QString): "N.E.R.D."],...] . The only difference was the name of the service that I changed in my code but I still get an empty string as result. Why the backend sends an empty string instead of the actual result? And in my code, if you notice, I check if the number of items in the list is null. Does Qt counts an empty string as an item?

                  M Offline
                  M Offline
                  micland
                  wrote on 15 Jun 2016, 06:38 last edited by
                  #8

                  @amonR2 said:

                  yes I ran qdbusviewer and obtained a message like the one I put in my first post://Received reply from :1.156 Arguments: [Argument: a{sv} {"album" = [Variant(QString): "In Search of..."], "artist" = [Variant(QString): "N.E.R.D."],...] . The only difference was the name of the service that I changed in my code but I still get an empty string as result.

                  Uhm, that's a bit strange. Can you try to inspect the reply with the debugger or send the arguments to debug out (qDebug() << args;) just to see if all arguments are empty or what Qt has interpreted from the message?

                  1 Reply Last reply
                  1
                  • A Offline
                    A Offline
                    amonR2
                    wrote on 16 Jun 2016, 03:12 last edited by
                    #9

                    @kshegunov , thank you very much.

                    @micland , I don't know how to inspect the reply with the debugger so I prefer to give you the result of qDebug() << args; which is: (QVariant(, )). Should I set Qt or my header in a certain way? So far I use the following includes:

                    #include <QtGui> 
                    #include <QtDBus/QtDBus>
                    

                    Is it ok? And what about the Q_DECLARE_METATYPE() that I don't use? Should I use it here? If yes, how?

                    M 1 Reply Last reply 16 Jun 2016, 06:44
                    0
                    • A amonR2
                      16 Jun 2016, 03:12

                      @kshegunov , thank you very much.

                      @micland , I don't know how to inspect the reply with the debugger so I prefer to give you the result of qDebug() << args; which is: (QVariant(, )). Should I set Qt or my header in a certain way? So far I use the following includes:

                      #include <QtGui> 
                      #include <QtDBus/QtDBus>
                      

                      Is it ok? And what about the Q_DECLARE_METATYPE() that I don't use? Should I use it here? If yes, how?

                      M Offline
                      M Offline
                      micland
                      wrote on 16 Jun 2016, 06:44 last edited by
                      #10

                      @amonR2 said:

                      I don't know how to inspect the reply with the debugger so I prefer to give you the result of qDebug() << args; which is: (QVariant(, )). Should I set Qt or my header in a certain way?

                      The order of the includes should not be relevant.
                      According to your debug output your program does not get the same answer as qdbusviewer gets. But I don't think that it's a bug in Qt because qdbusviewer uses the same logic and should be affected by that bug, too.
                      Could you check for reply->errorMessage(); and double check if there is any typo in the specified DBus interface / object / method in your code?

                      1 Reply Last reply
                      0
                      • A Offline
                        A Offline
                        amonR2
                        wrote on 17 Jun 2016, 03:42 last edited by
                        #11

                        @micland said:

                        Could you check for reply->errorMessage();

                        There sorry but I am not sure what you are talking about, did you mean to do this instead: qDebug() << replyClementine.errroMessage();? If yes, the output is still an empty string (""). For the typo in the DBus interface, objet and method in my code I don't think there is one as qDebug() << replyClementine gives me a correct response. But why this response is not "translated" into a list of variants and strings? What may "corrupt" the process here?

                        M 1 Reply Last reply 17 Jun 2016, 08:10
                        0
                        • A amonR2
                          17 Jun 2016, 03:42

                          @micland said:

                          Could you check for reply->errorMessage();

                          There sorry but I am not sure what you are talking about, did you mean to do this instead: qDebug() << replyClementine.errroMessage();? If yes, the output is still an empty string (""). For the typo in the DBus interface, objet and method in my code I don't think there is one as qDebug() << replyClementine gives me a correct response. But why this response is not "translated" into a list of variants and strings? What may "corrupt" the process here?

                          M Offline
                          M Offline
                          micland
                          wrote on 17 Jun 2016, 08:10 last edited by
                          #12

                          @amonR2
                          Yes, I wanted to see that there is no error message provided (or: I was hoping to see a message that gave us a hint ;-) ). I'm a bit confused that there is no error AND no usable reply.
                          Another idea: If you don't known how to debug the arguments, can you print out args.count()? Perhaps there is just one entry in the list and this entry might be a new list (or hash map) - and you're accessing the (not existing) second argument.... (the output (QVariant(, )) might indicate that there is just one argument...).

                          1 Reply Last reply
                          0
                          • A Offline
                            A Offline
                            amonR2
                            wrote on 18 Jun 2016, 03:45 last edited by
                            #13

                            The output of qDebug << args.count(); gives me 1. There is something I have changed in my code's environment: previously it was in release mode and I have just thought to put it in Debug one's which gives more info. With this code:

                            QString a1 = args.at(1).toString();
                            qDebug() << a1;
                            

                            my app crashes and the IDE gives me this message: ASSERT failure in QList<T>::at: "index out of range", file /usr/include/qt4/QtCore/qlist.h, line 469. But when I use this one:

                            QString a1 = args.at(0).toString();
                            qDebug() << a1;
                            

                            my app doesn't crash and qDebug() gives me an empty string.

                            M 1 Reply Last reply 20 Jun 2016, 06:38
                            0
                            • A amonR2
                              18 Jun 2016, 03:45

                              The output of qDebug << args.count(); gives me 1. There is something I have changed in my code's environment: previously it was in release mode and I have just thought to put it in Debug one's which gives more info. With this code:

                              QString a1 = args.at(1).toString();
                              qDebug() << a1;
                              

                              my app crashes and the IDE gives me this message: ASSERT failure in QList<T>::at: "index out of range", file /usr/include/qt4/QtCore/qlist.h, line 469. But when I use this one:

                              QString a1 = args.at(0).toString();
                              qDebug() << a1;
                              

                              my app doesn't crash and qDebug() gives me an empty string.

                              M Offline
                              M Offline
                              micland
                              wrote on 20 Jun 2016, 06:38 last edited by
                              #14

                              @amonR2
                              Ok, the argument list contains just one argument - that's why you get the "index out of range" error because you try to access the second argument. Please add the line qDebug() << args.at(0).typeName(); to see the type of the first argument. Maybe it's a list where you find all your expected data in...

                              A 1 Reply Last reply 21 Jun 2016, 01:58
                              0
                              • M micland
                                20 Jun 2016, 06:38

                                @amonR2
                                Ok, the argument list contains just one argument - that's why you get the "index out of range" error because you try to access the second argument. Please add the line qDebug() << args.at(0).typeName(); to see the type of the first argument. Maybe it's a list where you find all your expected data in...

                                A Offline
                                A Offline
                                amonR2
                                wrote on 21 Jun 2016, 01:58 last edited by
                                #15

                                The reply from qDebug() << args.at(0).typeName(); gives me: QDBusArgument.

                                M 1 Reply Last reply 21 Jun 2016, 12:50
                                0
                                • A amonR2
                                  21 Jun 2016, 01:58

                                  The reply from qDebug() << args.at(0).typeName(); gives me: QDBusArgument.

                                  M Offline
                                  M Offline
                                  micland
                                  wrote on 21 Jun 2016, 12:50 last edited by
                                  #16

                                  @amonR2
                                  Huh, a nested QDBusArgument? Well check the inner argument if it serves the expected information:
                                  args.at(0).value<QDBusArgument>().args().
                                  (You should really try to inspect the reply using the debugger and iterate through the object tree to see what's encapsulated in the arguments. That's a lot easier than poking with qDebug() - perhaps this link will help you getting started? http://doc.qt.io/qtcreator/creator-debug-mode.html)

                                  1 Reply Last reply
                                  0
                                  • A Offline
                                    A Offline
                                    amonR2
                                    wrote on 22 Jun 2016, 03:22 last edited by
                                    #17

                                    @micland said:

                                    Huh, a nested QDBusArgument?

                                    sorry I don't understand what you mean there but that's all qDebug displays.
                                    Then when I try to qDebug thisargs.at(0).value<QDBusArgument>().args();, the compiler says: 'class QDBusArgument' has no member named 'args'. So I tried with this: args.at(0).value<QDBusArgument>() and received the following from the compiler: no match for 'operator<<' in 'qDebug()() << QVariant::value() const [with T = QDBusArgument]()' [...] no known conversion for argument 1 from 'QDebug' to 'QDBusArgument&'.
                                    Finally, by puting a breakpoint (thank you for the link) at QList<QVariant> args = replyClementine.arguments(); in my code and launching the debug-mode, the compiler stops and shows me this through the "Locals and Expressions" window:

                                    	args                 	<inaccessible>	QList<QVariant>
                                    	this	 @0x83f87d8	FenetreNNS
                                    		QWidget		QWidget
                                    		Deviselabel	0x0	QLabel *
                                    		MainLabel	 @0x844d210	QLabel
                                    		Nextm	 @0x8451f28	QPushButton
                                    		NoTrackLabel	 @0x8454628	QLabel
                                    		Play	 @0x844f628	QPushButton
                                    		Previous	 @0x8451088	QPushButton
                                    		TemoinSousTitre	false	bool
                                    		Volume	 @0x8453a48	QSlider
                                    		VolumeLabel	 @0x844d160	QLabel
                                    		boutonDeviseBaht	 @0x8439978	QPushButton
                                    		boutonDeviseDenar	 @0x843cce0	QPushButton
                                    		boutonDeviseDollar	 @0x843f968	QPushButton
                                    		boutonDeviseEuro	 @0x8440418	QPushButton
                                    		boutonDeviseLira	 @0x843e608	QPushButton
                                    		boutonDevisePeso	 @0x8442098	QPushButton
                                    		boutonDevisePound	 @0x8444e58	QPushButton
                                    		boutonDeviseRuble	 @0x843b078	QPushButton
                                    		boutonDeviseRupee	 @0x844a4b0	QPushButton
                                    		boutonDeviseWon	 @0x844b2e0	QPushButton
                                    		boutonDeviseYen	 @0x8448a28	QPushButton
                                    		boutonDeviseYuan	 @0x8449e70	QPushButton
                                    		iface_Clementine	 @0x845e788	QDBusInterface
                                    		machine	 @0x8455420	QStateMachine
                                    		principalefen	 @0xbffff7b4	FenPrincipale
                                    		replyClementine		QDBusMessage
                                    			d_ptr	 @0x845d098	QDBusMessagePrivate
                                    		signMapper	 @0x8454ac0	QSignalMapper
                                    		signMapper2	 @0x84553e8	QSignalMapper
                                    		sliderSousTitre	 @0x844d998	QSlider
                                    		state1	 @0x8451f60	QState
                                    		state2	 @0x8451f70	QState
                                    		str1	"Currency"	QString
                                    		tempo	 @0x84505b0	QTimer
                                    
                                    

                                    Should I show the content of some other windows?

                                    M 1 Reply Last reply 22 Jun 2016, 07:05
                                    0
                                    • A amonR2
                                      22 Jun 2016, 03:22

                                      @micland said:

                                      Huh, a nested QDBusArgument?

                                      sorry I don't understand what you mean there but that's all qDebug displays.
                                      Then when I try to qDebug thisargs.at(0).value<QDBusArgument>().args();, the compiler says: 'class QDBusArgument' has no member named 'args'. So I tried with this: args.at(0).value<QDBusArgument>() and received the following from the compiler: no match for 'operator<<' in 'qDebug()() << QVariant::value() const [with T = QDBusArgument]()' [...] no known conversion for argument 1 from 'QDebug' to 'QDBusArgument&'.
                                      Finally, by puting a breakpoint (thank you for the link) at QList<QVariant> args = replyClementine.arguments(); in my code and launching the debug-mode, the compiler stops and shows me this through the "Locals and Expressions" window:

                                      	args                 	<inaccessible>	QList<QVariant>
                                      	this	 @0x83f87d8	FenetreNNS
                                      		QWidget		QWidget
                                      		Deviselabel	0x0	QLabel *
                                      		MainLabel	 @0x844d210	QLabel
                                      		Nextm	 @0x8451f28	QPushButton
                                      		NoTrackLabel	 @0x8454628	QLabel
                                      		Play	 @0x844f628	QPushButton
                                      		Previous	 @0x8451088	QPushButton
                                      		TemoinSousTitre	false	bool
                                      		Volume	 @0x8453a48	QSlider
                                      		VolumeLabel	 @0x844d160	QLabel
                                      		boutonDeviseBaht	 @0x8439978	QPushButton
                                      		boutonDeviseDenar	 @0x843cce0	QPushButton
                                      		boutonDeviseDollar	 @0x843f968	QPushButton
                                      		boutonDeviseEuro	 @0x8440418	QPushButton
                                      		boutonDeviseLira	 @0x843e608	QPushButton
                                      		boutonDevisePeso	 @0x8442098	QPushButton
                                      		boutonDevisePound	 @0x8444e58	QPushButton
                                      		boutonDeviseRuble	 @0x843b078	QPushButton
                                      		boutonDeviseRupee	 @0x844a4b0	QPushButton
                                      		boutonDeviseWon	 @0x844b2e0	QPushButton
                                      		boutonDeviseYen	 @0x8448a28	QPushButton
                                      		boutonDeviseYuan	 @0x8449e70	QPushButton
                                      		iface_Clementine	 @0x845e788	QDBusInterface
                                      		machine	 @0x8455420	QStateMachine
                                      		principalefen	 @0xbffff7b4	FenPrincipale
                                      		replyClementine		QDBusMessage
                                      			d_ptr	 @0x845d098	QDBusMessagePrivate
                                      		signMapper	 @0x8454ac0	QSignalMapper
                                      		signMapper2	 @0x84553e8	QSignalMapper
                                      		sliderSousTitre	 @0x844d998	QSlider
                                      		state1	 @0x8451f60	QState
                                      		state2	 @0x8451f70	QState
                                      		str1	"Currency"	QString
                                      		tempo	 @0x84505b0	QTimer
                                      
                                      

                                      Should I show the content of some other windows?

                                      M Offline
                                      M Offline
                                      micland
                                      wrote on 22 Jun 2016, 07:05 last edited by
                                      #18

                                      @amonR2 said:

                                      Huh, a nested QDBusArgument?
                                      sorry I don't understand what you mean there but that's all qDebug displays.

                                      Aye, sorry - I was wrong, read your answer too fast and got confused...
                                      It's hard to find this error without reproducing it. If I find some time at the weekend I'll try to debug it. Can you tell me which software you installed? will say: what's that player your communicating with?

                                      A 1 Reply Last reply 23 Jun 2016, 02:24
                                      0
                                      • M micland
                                        22 Jun 2016, 07:05

                                        @amonR2 said:

                                        Huh, a nested QDBusArgument?
                                        sorry I don't understand what you mean there but that's all qDebug displays.

                                        Aye, sorry - I was wrong, read your answer too fast and got confused...
                                        It's hard to find this error without reproducing it. If I find some time at the weekend I'll try to debug it. Can you tell me which software you installed? will say: what's that player your communicating with?

                                        A Offline
                                        A Offline
                                        amonR2
                                        wrote on 23 Jun 2016, 02:24 last edited by
                                        #19

                                        @micland
                                        The name of the player is "Clementine" and I am using Qt 4.8 . No worries, thank you a lot for your help anyway. I will keep looking for a solution. If I can't find anything I will use one of the other APIs. Cheers again.

                                        M 2 Replies Last reply 27 Jun 2016, 07:48
                                        0
                                        • A amonR2
                                          23 Jun 2016, 02:24

                                          @micland
                                          The name of the player is "Clementine" and I am using Qt 4.8 . No worries, thank you a lot for your help anyway. I will keep looking for a solution. If I can't find anything I will use one of the other APIs. Cheers again.

                                          M Offline
                                          M Offline
                                          micland
                                          wrote on 27 Jun 2016, 07:48 last edited by
                                          #20

                                          @amonR2
                                          I'm a little bit closer, but did non really succeed...
                                          First: Qt 4.8 is some days older, I used 5.6 for my experiements. Inspecting the DBus interface using qdbusviewer (from Qt5.6) ended with the error message "Unable to find method GetMetadata on path /Player in interface org.freedesktop.MediaPlayer" (the method is listed but I can't call it) - but the cli client qdbus provided me the expected data. I can't say if that's a bug in Qt or a "conformity problem", but it shows that calling the clementine DBus interface from Qt works not straight forward.

                                          I tried to access the interface using a simple Qt program (like the example code you posted) and got the same reply as you did. Inspecting the received QDBusArgument showed that its currentyType() is a MapType (4) which means that the arguments are organized as a key/value list (the same says the MPRIS spec: see "Metadata" is an array of dict entries in the form (string, variant) eg: {sv}., https://xmms2.org/wiki/MPRIS#.22Metadata.22)

                                          I think you have to extract the values manually and play arround with beginMap(), beginMapEntry(), endMapEntry(), endMap() of QDBusArgument. (I spent just a little time but did not succeed ...)
                                          But I'm interested if that's the right way so if you find a solution please share it here! (If I find some time I will try it again, too...)

                                          1 Reply Last reply
                                          1

                                          9/22

                                          16 Jun 2016, 03:12

                                          • Login

                                          • Login or register to search.
                                          9 out of 22
                                          • First post
                                            9/22
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved