Results 1 to 12 of 12

Thread: How to autoRun the command "dbus-daemon --config-file=session.conf"?

  1. #1
    Join Date
    Apr 2008
    Posts
    44
    Thanks
    21
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Question How to autoRun the command "dbus-daemon --config-file=session.conf"?

    hello,everyone
    i use the QtDBus in my Qt4.6.2 application. Before run my application, it's necessary to run the DBus session process and the DBus session process must be runing untill my application exit.
    I run the DBus session process by input "dbus-daemon --config-file = session.conf" in the hyperterminal at first.
    Now I want the DBus session process could autorun in my application, i have tried two method but not succeed:
    1. the "dbus-daemon.exe" and the "session.conf" are in the "DBusEssential"

    Qt Code:
    1. system("/DBusEssential/dbus-daemon --config-file=/DBusEssential/session.conf");
    To copy to clipboard, switch view to plain text mode 

    the "system" excute the command, but it exit at once. My application need the DBus session process is always running.

    2.
    Qt Code:
    1. QProcess myProcess;
    2. myProcess.start("/DBusEssential/dbus-daemon --config-file=/DBusEssential/session.conf");
    To copy to clipboard, switch view to plain text mode 

    I Know it's not correct to use like this, but i don't know the correct way.

    May be the "session.conf" could write to the "config-file" of the "dbus-daemon.exe", and then "start " the "dbus-daemon.exe"? How to??

    please help me. thanks very much.
    regards for any advice!!!

  2. #2
    Join Date
    Feb 2009
    Posts
    3
    Thanked 1 Time in 1 Post

    Default Re: How to autoRun the command "dbus-daemon --config-file=session.conf"?

    How about this?

    QProcess::startDetached("/DBusEssential/dbus-daemon --config-file=/DBusEssential/session.conf);

    QProcess::startDetached() is a static member function and sill will be working after your process exit.

  3. The following user says thank you to nice295@gmail.com for this useful post:

    to_guliang (13th July 2010)

  4. #3
    Join Date
    Apr 2008
    Posts
    44
    Thanks
    21
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: How to autoRun the command "dbus-daemon --config-file=session.conf"?

    thanks.
    your suggestion doesn't work. Maybe the program name should be "/DBusEssential/dbus-daemon.exe ", but the "--config-file" and the "session.conf" how to configure to the program???

    i don't know how. waiting for replying....

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to autoRun the command "dbus-daemon --config-file=session.conf"?

    Pass the arguments in a form of a string list as a second argument to startDetached().
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. The following user says thank you to wysota for this useful post:

    to_guliang (13th July 2010)

  7. #5
    Join Date
    Apr 2008
    Posts
    44
    Thanks
    21
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: How to autoRun the command "dbus-daemon --config-file=session.conf"?

    Quote Originally Posted by wysota View Post
    Pass the arguments in a form of a string list as a second argument to startDetached().
    thanks very much.

    i tried what you said as following manner,
    but it doesn't work.
    At the same time, i have tried "QString program = "/DBusEssential/dbus-daemon.exe". It doesn't work.

    could you tell me what's wrong in my code? Thanks a lot.

    Qt Code:
    1. QString program = "/DBusEssential/dbus-daemon";
    2. QStringList arguments;
    3. arguments << "--config-file" << "=" << "/DBusEssential/session.conf";
    4. QProcess::startDetached(program,arguments);
    To copy to clipboard, switch view to plain text mode 

  8. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to autoRun the command "dbus-daemon --config-file=session.conf"?

    It seems to me "--config-file=/DBusEssential/session.conf" is a single argument and not three separate ones.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #7
    Join Date
    Apr 2008
    Posts
    44
    Thanks
    21
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: How to autoRun the command "dbus-daemon --config-file=session.conf"?

    Quote Originally Posted by wysota View Post
    It seems to me "--config-file=/DBusEssential/session.conf" is a single argument and not three separate ones.
    Putting the "--config-file=/DBusEssential/session.conf" in a single argument doesn't work........

  10. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to autoRun the command "dbus-daemon --config-file=session.conf"?

    Any details on how "doesn't work" occur?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. The following user says thank you to wysota for this useful post:

    to_guliang (26th July 2010)

  12. #9
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to autoRun the command "dbus-daemon --config-file=session.conf"?

    You haven't established whether the command you are trying to run works at all. If you type exactly this:
    Qt Code:
    1. /DBusEssential/dbus-daemon --config-file=/DBusEssential/session.conf
    To copy to clipboard, switch view to plain text mode 
    into your terminal, with the same environment as the application will have, does it run? Does it give you meaningful errors if it doesn't?

  13. The following user says thank you to ChrisW67 for this useful post:

    to_guliang (26th July 2010)

  14. #10
    Join Date
    Apr 2008
    Posts
    44
    Thanks
    21
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: How to autoRun the command "dbus-daemon --config-file=session.conf"?

    Thanks to wysota and ChrisW67!!!!!!

    i must say sorry . today i do as ChrisW67 says, it doesn't work in terminal. I remember that i have tried "/DBusEssential/dbus-daemon --config-file=/DBusEssential/session.conf" in my terminal and it works. the facts prove that i have misremember.

    now, i copy the "dbus-daemon.exe" and "session.conf" to the project root directory, the effective code is follows:
    Qt Code:
    1. QString program = "dbus-daemon.exe";
    2. QStringList arguments;
    3. arguments << "--config-file=session.conf";
    4. QProcess::startDetached(program,arguments);
    To copy to clipboard, switch view to plain text mode 

    but now there is another problem, a terminal window named "d:\QtProject\dbus-chat\dbus-daemon.exe" will appear in my desktop. As you know, the client won't accept this window.
    Maybe there is a better way to autorun the dbus-daemon.exe without the terminal window?

  15. #11
    Join Date
    Apr 2008
    Posts
    44
    Thanks
    21
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: How to autoRun the command "dbus-daemon --config-file=session.conf"?

    The following code will do the right thing. the "dbus-daemon.exe" will exit if the application exit:

    Qt Code:
    1. QString program = "dbus-daemon.exe";
    2. QStringList arguments;
    3. arguments << "--config-file=session.conf";
    4.  
    5. QProcess myProcess;
    6. myProcess.start(program, arguments);
    To copy to clipboard, switch view to plain text mode 

    Thanks to all!

  16. #12
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to autoRun the command "dbus-daemon --config-file=session.conf"?

    Be a little careful because the program's working directory may not be be same as the application executable's location: you might want to use QCoreApplication::applicationDirPath() to find dbus-daemon.

    Regarding the console window:
    • Does using the DBus "--fork" option help?
    • Is "dbus-launch" of any use?
    • Does making the command equivalent to "cmd /c start /b dbus-daemon --config-file=session.conf" help?
    • Does capturing the program output stream help?

Similar Threads

  1. Replies: 7
    Last Post: 20th October 2012, 13:44
  2. Replies: 3
    Last Post: 15th February 2010, 17:27
  3. Replies: 3
    Last Post: 8th July 2008, 19:37
  4. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05
  5. QPluginLoader fails when using "debug" config
    By paradiza in forum Qt Programming
    Replies: 22
    Last Post: 14th February 2007, 06:59

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.