[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] How to Disconnect a python QDBus connection?
From:       Shahin Azad <ishahinism () gmail ! com>
Date:       2012-09-17 18:50:14
Message-ID: CAHgS6UshmyJw8pBepKwqsYAvNro4KUYGoaj9q9LSh1Z4xLG71Q () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


I made some kind of answering machine for pidgin client that uses Linuxes
DBus to make connection with pidgin. the code is this:

    class DBus_Answer():
        def __init__(self, text = "No text"):
            self.answer = text
            bus_loop = DBusQtMainLoop(set_as_default=True)
            self.bus = dbus.SessionBus()
            self.bus.add_signal_receiver(self.pidgin_control_func,

dbus_interface="im.pidgin.purple.PurpleInterface",
                                         signal_name="ReceivedImMsg")

        def pidgin_control_func(self, account, sender, message,
conversation, flags):
            obj = self.bus.get_object("im.pidgin.purple.PurpleService",
"/im/pidgin/purple/PurpleObject")
            purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface")
            purple.PurpleConvImSend(purple.PurpleConvIm(conversation),
self.answer)

now I want to use it as a module in another program. I called it like this:

    answering_machine.DBus_Answer(message)

the problem is, when I stop the second program (the program that has this
one as a module) and then start it again, I'll get a `segmentation fault`
because it want to make another connection to the DBus and it seams it's
not regular!

Other wise I want to give the chance of disabling this module to user. I
tried to use an `if` statement. It will work for the first time. but if
user run the module for once, he can't disable it any more.


-- 
*Shahin Azad!*
My personal *blog*: http://shahinism.com
I like to keep it respectful with *OpenRespect* (http://www.openrespect.org)

[Attachment #5 (text/html)]

<div dir="ltr">I made some kind of answering machine for pidgin client that uses \
Linuxes DBus to make connection with pidgin. the code is this:<br><br>       class \
DBus_Answer():<br>               def __init__(self, text = &quot;No text&quot;):   \
<br>  self.answer = text<br>                       bus_loop = \
DBusQtMainLoop(set_as_default=True)<br>                       self.bus = \
dbus.SessionBus()<br>                       \
self.bus.add_signal_receiver(self.pidgin_control_func,<br>                            \
dbus_interface=&quot;im.pidgin.purple.PurpleInterface&quot;,<br>  \
signal_name=&quot;ReceivedImMsg&quot;)<br>               <br>               def \
pidgin_control_func(self, account, sender, message, conversation, flags):<br>         \
obj = self.bus.get_object(&quot;im.pidgin.purple.PurpleService&quot;, \
&quot;/im/pidgin/purple/PurpleObject&quot;)<br>  purple = dbus.Interface(obj, \
&quot;im.pidgin.purple.PurpleInterface&quot;)<br>                       \
purple.PurpleConvImSend(purple.PurpleConvIm(conversation), self.answer)<br><br>now I \
want to use it as a module in another program. I called it like this:<br> <br>       \
answering_machine.DBus_Answer(message)<br><br>the problem is, when I stop the second \
program (the program that has this one as a module) and then start it again, I&#39;ll \
get a `segmentation fault` because it want to make another connection to the DBus and \
it seams it&#39;s not regular!<br> <br>Other wise I want to give the chance of \
disabling this module to user. I tried to use an `if` statement. It will work for the \
first time. but if user run the module for once, he can&#39;t disable it any \
more.<br><br clear="all"> <br>-- <br><div dir="ltr"><b>Shahin <span \
style="color:rgb(255,0,0)">A</span>zad!</b><br>My personal <b>blog</b>:<a> \
http://shahinism.com</a><br>I like to keep it respectful with <b>OpenRespect</b> (<a \
href="http://www.openrespect.org/" \
target="_blank">http://www.openrespect.org</a>)<br> </div><br>
</div>



_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic