简体   繁体   English

我正在试图找出如何使用带有pidgin的dbus

[英]I'm trying to figure out how to use dbus with pidgin

My problem is I'm not sure how to interface them. 我的问题是我不确定如何界面。 Do I need to have pidgin installed in a particular way in order for dbus to interface with it? 我是否需要以特定方式安装pidgin才能使dbus与之接口? and if not does the pidgin gui have to be running in order for dbus to utilize it? 如果没有,为了让dbus使用它,必须运行pidgin gui?

As per this source you could do the following : 根据来源,您可以执行以下操作:

#!/usr/bin/env python

def cb_func(account, rec, message):
    #change message here somehow? 
    print message

import dbus, gobject
from dbus.mainloop.glib import DBusGMainLoop
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()

bus.add_signal_receiver(cb_func,
dbus_interface="im.pidgin.purple.PurpleInterface",
signal_name="SendingImMsg")

loop = gobject.MainLoop()
loop.run()

Probably you can get started with this lead. 可能你可以开始这个领先。

import dbus
from dbus.mainloop.glib import DBusGMainLoop

main_loop = DBusGMainLoop()
session_bus = dbus.SessionBus(mainloop = main_loop)
obj = session_bus.get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject")
purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface")

Then you can use the purple object to call some methods like this: 然后你可以使用紫色对象来调用这样的方法:

status = purple.PurpleSavedstatusNew("", current)
purple.PurpleSavedstatusSetMessage(status, message)
purple.PurpleSavedstatusActivate(status)

A really useful tool to use when getting started with using DBUS to interface with Pidgin is D-Feet . 在开始使用DBUS与Pidgin接口时使用的一个非常有用的工具是D-Feet You can see all the available methods you can call and even execute them directly from the GUI. 您可以看到可以调用的所有可用方法,甚至可以直接从GUI执行它们。

The code below has an example of showing the buddy list when it is hidden and another example of starting an IM conversation with a specific contact. 下面的代码有一个示例,显示隐藏的好友列表和另一个与特定联系人开始IM对话的示例。

import dbus
BUS_ARGS = ('im.pidgin.purple.PurpleService', '/im/pidgin/purple/PurpleObject')
obj = dbus.SessionBus().get_object(*BUS_ARGS)
purple = dbus.Interface(obj, 'im.pidgin.purple.PurpleInterface')

# show buddy list if it is hidden
purple.PurpleBlistSetVisible(1)

# start IM conversation with specific contact
account = purple.PurpleAccountsFindConnected('', '')
conversation = purple.PurpleConversationNew(1, account, 'alice@example.com')

I can recommend a number of useful resources relating to using dbus with pidgin: 我可以推荐一些与使用带有pidgin的dbus相关的有用资源:

  • Riding the D-Bus with Pidgin - Has three separate python dbus examples. 使用Pidgin乘坐D-Bus - 有三个单独的python dbus示例。
  • purple-remote - It's a python script that was installed on my ubuntu machine when I installed pidgin. purple-remote - 当我安装pidgin时,它是安装在我的ubuntu机器上的python脚本。 Its a single file and pretty easy to read through. 它是一个单独的文件,非常容易阅读。
  • dbus-monitor - Great program to monitor dbus calls. dbus-monitor - 监控dbus呼叫的好程序。 It can help you discover what calls are being used by programs you use when you can't find them documented. 它可以帮助您发现当您找不到文档时使用的程序正在使用的调用。
  • qdbusviewer - Great graphical tool that can list pidgins dbus methods. qdbusviewer - 可以列出pidgins dbus方法的出色图形工具。 You can also call them from the tool itself. 您也可以从工具本身调用它们。

qdbusviewer

You do not need to do any special configuration of Pidgin to use D-Bus, however it must be running if you want to use it. 您不需要对Pidgin进行任何特殊配置即可使用D-Bus,但是如果您想使用它,它必须正在运行。 You can check the script I'm using to control Pidgin status from the NetworkManager-dispatcher ( part 1 , part 2 ) as a sample how to interface Pidgin via D-Bus from python. 您可以从NetworkManager-dispatcher( 第1 部分第2部分 )检查我用来控制Pidgin状态的脚本,作为如何通过Dthon总线从python接口Pidgin的示例。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我试图弄清楚如何以 2 的幂为循环递增 - I'm trying to figure out how increment for loop in powers of 2 我试图弄清楚如何在 python 上安装这个库(时间) - I'm trying to figure out how to install this lib on python (time) 我是 python 的新手,我想弄清楚如何在同一行上一次打印一个字母 - I'm new to python and I am trying to figure out how to print letters one at a time on the same line 我试图弄清楚如何添加到字典列表中,而不是创建一个字典列表列表 - I'm trying to figure out how to add to a list of dictionaries, rather than create a list of lists of dictionaries 我正在尝试在要求用户输入两个输入的地方编写一行代码,但无法弄清楚如何完成此操作 - I'm trying to write a line of code at ask the user for two inputs but can't figure out how to complete this 我试图弄清楚如何计算在Python的字符串句子中字母大写的次数 - I'm trying to figure out how to count how many times a letter is capitalized in a string sentence in Python 我正在尝试找出Python中的简单列表加密 - I'm trying to figure out simple list encryption in Python 我正在试图找出如何从我的csv文件中删除逗号和美元符号 - I'm trying to figure out how to strip commas and dollars signs from my csv file 我试图弄清楚如何让python将歌词简单地发布到歌曲中 - I'm trying to figure out how to get python to simply post the lyrics to a song 我试图弄清楚如何制作一个正方形,当点击它时,它会改变 colors - I'm trying to figure out how to make a square that when clicked, it will change colors
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM