Mercurial > pidgin
changeset 16143:598b1b15b199
Trac Ticket #149 from JensenDied
This patch does a rename of our DBus stuff.
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Sun, 15 Apr 2007 18:09:14 +0000 |
parents | 74b2d576f458 |
children | 1f42dbf360e3 |
files | Makefile.am configure.ac finch/libgnt/pygnt/dbus-gnt gaim.service.in libpurple/dbus-purple.h libpurple/dbus-server.c libpurple/plugins/dbus-buddyicons-example.py libpurple/purple-notifications-example libpurple/purple-remote libpurple/purple-send libpurple/purple-send-async libpurple/purple-url-handler pidgin.spec.in |
diffstat | 13 files changed, 131 insertions(+), 108 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile.am Sun Apr 15 18:06:49 2007 +0000 +++ b/Makefile.am Sun Apr 15 18:09:14 2007 +0000 @@ -13,7 +13,7 @@ config.h.mingw \ gaim.pc.in \ gaim-uninstalled.pc.in \ - gaim.service.in \ + purple.service.in \ intltool-extract.in \ intltool-merge.in \ intltool-update.in \ @@ -26,7 +26,7 @@ if ENABLE_DBUS dbus_servicedir=$(DBUS_SERVICES_DIR) -dbus_service_DATA=gaim.service +dbus_service_DATA=purple.service endif dist-hook: pidgin.spec
--- a/configure.ac Sun Apr 15 18:06:49 2007 +0000 +++ b/configure.ac Sun Apr 15 18:09:14 2007 +0000 @@ -1893,7 +1893,7 @@ AC_OUTPUT([Makefile Doxyfile - gaim.service + purple.service doc/Makefile doc/pidgin.1 doc/finch.1
--- a/finch/libgnt/pygnt/dbus-gnt Sun Apr 15 18:06:49 2007 +0000 +++ b/finch/libgnt/pygnt/dbus-gnt Sun Apr 15 18:09:14 2007 +0000 @@ -37,23 +37,23 @@ gnt.gnt_init() bus = dbus.SessionBus() -obj = bus.get_object("net.sf.purple.PurpleService", "/net/sf/purple/PurpleObject") -purple = dbus.Interface(obj, "net.sf.purple.PurpleInterface") +obj = bus.get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject") +purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface") bus.add_signal_receiver(buddysignedon, - dbus_interface = "net.sf.purple.PurpleInterface", + dbus_interface = "im.pidgin.purple.PurpleInterface", signal_name = "BuddySignedOn") bus.add_signal_receiver(wrote_msg, - dbus_interface = "net.sf.purple.PurpleInterface", + dbus_interface = "im.pidgin.purple.PurpleInterface", signal_name = "WroteImMsg") bus.add_signal_receiver(wrote_msg, - dbus_interface = "net.sf.purple.PurpleInterface", + dbus_interface = "im.pidgin.purple.PurpleInterface", signal_name = "WroteChatMsg") bus.add_signal_receiver(conv_closed, - dbus_interface = "net.sf.purple.PurpleInterface", + dbus_interface = "im.pidgin.purple.PurpleInterface", signal_name = "DeletingConversation") def get_dict_key(conv):
--- a/gaim.service.in Sun Apr 15 18:06:49 2007 +0000 +++ b/gaim.service.in Sun Apr 15 18:09:14 2007 +0000 @@ -1,3 +1,3 @@ [D-BUS Service] -Name=org.gaim.GaimService -Exec=@bindir@/gaim +Name=im.pidgin.purple.PurpleService +Exec=/bin/false
--- a/libpurple/dbus-purple.h Sun Apr 15 18:06:49 2007 +0000 +++ b/libpurple/dbus-purple.h Sun Apr 15 18:09:14 2007 +0000 @@ -24,8 +24,8 @@ #ifndef _DBUS_PURPLE_H_ #define _DBUS_PURPLE_H_ -#define DBUS_SERVICE_PURPLE "net.sf.purple.PurpleService" -#define DBUS_PATH_PURPLE "/net/sf/purple/PurpleObject" -#define DBUS_INTERFACE_PURPLE "net.sf.purple.PurpleInterface" +#define DBUS_SERVICE_PURPLE "im.pidgin.purple.PurpleService" +#define DBUS_PATH_PURPLE "/im/pidgin/purple/PurpleObject" +#define DBUS_INTERFACE_PURPLE "im.pidgin.purple.PurpleInterface" #endif /* _DBUS_PURPLE_H_ */
--- a/libpurple/dbus-server.c Sun Apr 15 18:06:49 2007 +0000 +++ b/libpurple/dbus-server.c Sun Apr 15 18:09:14 2007 +0000 @@ -143,7 +143,7 @@ gint id = purple_dbus_pointer_to_id(ptr); if (ptr != NULL && id == 0) - dbus_set_error(error, "net.sf.purple.ObjectNotFound", + dbus_set_error(error, "im.pidgin.purple.ObjectNotFound", "The return object is not mapped (this is a Purple error)"); return id; @@ -156,7 +156,7 @@ gpointer ptr = purple_dbus_id_to_pointer(id, type); if (ptr == NULL && id != 0) - dbus_set_error(error, "net.sf.purple.InvalidHandle", + dbus_set_error(error, "im.pidgin.purple.InvalidHandle", "%s object with ID = %i not found", typename, id); return ptr;
--- a/libpurple/plugins/dbus-buddyicons-example.py Sun Apr 15 18:06:49 2007 +0000 +++ b/libpurple/plugins/dbus-buddyicons-example.py Sun Apr 15 18:09:14 2007 +0000 @@ -2,7 +2,7 @@ # # Print the aliases of buddies who have a buddy-icon set. # -# Gaim is the legal property of its developers, whose names are too numerous +# Purple is the legal property of its developers, whose names are too numerous # to list here. Please refer to the COPYRIGHT file distributed with this # source distribution. # @@ -24,13 +24,13 @@ import dbus bus = dbus.SessionBus() -obj = bus.get_object("net.sf.gaim.GaimService", "/net/sf/gaim/GaimObject") -gaim = dbus.Interface(obj, "net.sf.gaim.GaimInterface") +obj = bus.get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject") +purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface") -node = gaim.GaimBlistGetRoot() +node = purple.PurpleBlistGetRoot() while node != 0: - if gaim.GaimBlistNodeIsBuddy(node): - icon = gaim.GaimBuddyGetIcon(node) + if purple.PurpleBlistNodeIsBuddy(node): + icon = purple.PurpleBuddyGetIcon(node) if icon != 0: - print gaim.GaimBuddyGetAlias(node) - node = gaim.GaimBlistNodeNext(node, 0) + print purple.PurpleBuddyGetAlias(node) + node = purple.PurpleBlistNodeNext(node, 0)
--- a/libpurple/purple-notifications-example Sun Apr 15 18:06:49 2007 +0000 +++ b/libpurple/purple-notifications-example Sun Apr 15 18:09:14 2007 +0000 @@ -1,12 +1,12 @@ #!/usr/bin/env python -# This is a simple gaim notification server. +# This is a simple purple notification server. # It shows notifications when your buddy signs on or you get an IM message. # # This script requires Python 2.4 and PyGTK bindings # # Note that all function names are resolved dynamically, no -# gaim-specific library is needed. +# purple-specific library is needed. import dbus import dbus.glib @@ -19,12 +19,12 @@ return conversation else: # 1 = GAIM_CONV_IM - return gaim.GaimConversationNew(1, account, name) + return purple.PurpleConversationNew(1, account, name) def receivedimmsg(account, name, message, conversation, flags): - buddy = gaim.GaimFindBuddy(account, name) + buddy = purple.PurpleFindBuddy(account, name) if buddy != 0: - alias = gaim.GaimBuddyGetAlias(buddy) + alias = purple.PurpleBuddyGetAlias(buddy) else: alias = name @@ -38,19 +38,19 @@ conversation = ensureimconversation(conversation, account, name) if code == 102: # show me - window = gaim.GaimConversationGetWindow(conversation) - gaim.GaimConvWindowRaise(window) + window = purple.PurpleConversationGetWindow(conversation) + purple.PurpleConvWindowRaise(window) if code == 103: # close - gaim.GaimConversationDestroy(conversation) + purple.PurpleConversationDestroy(conversation) if code == 104: # abuse - im = gaim.GaimConversationGetImData(conversation) - gaim.GaimConvImSend(im, "Go away you f...") + im = purple.PurpleConversationGetImData(conversation) + purple.PurpleConvImSend(im, "Go away you f...") def buddysignedon(buddyid): - alias = gaim.GaimBuddyGetAlias(buddyid) + alias = purple.PurpleBuddyGetAlias(buddyid) text = "%s is online" % alias code = os.spawnlp(os.P_WAIT, "xmessage", "xmessage", "-buttons", @@ -60,24 +60,24 @@ pass if code == 102: # talk - name = gaim.GaimBuddyGetName(buddyid) - account = gaim.GaimBuddyGetAccount(buddyid) - gaim.GaimConversationNew(1, account, name) + name = purple.PurpleBuddyGetName(buddyid) + account = purple.PurpleBuddyGetAccount(buddyid) + purple.PurpleConversationNew(1, account, name) bus = dbus.SessionBus() -obj = bus.get_object("net.sf.gaim.GaimService", "/net/sf/gaim/GaimObject") -gaim = dbus.Interface(obj, "net.sf.gaim.GaimInterface") +obj = bus.get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject") +purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface") bus.add_signal_receiver(receivedimmsg, - dbus_interface = "net.sf.gaim.GaimInterface", + dbus_interface = "im.pidgin.purple.PurpleInterface", signal_name = "ReceivedImMsg") bus.add_signal_receiver(buddysignedon, - dbus_interface = "net.sf.gaim.GaimInterface", + dbus_interface = "im.pidgin.purple.PurpleInterface", signal_name = "BuddySignedOn") -print "This is a simple gaim notification server." +print "This is a simple purple notification server." print "It shows notifications when your buddy signs on or you get an IM message." loop = gobject.MainLoop()
--- a/libpurple/purple-remote Sun Apr 15 18:06:49 2007 +0000 +++ b/libpurple/purple-remote Sun Apr 15 18:09:14 2007 +0000 @@ -9,8 +9,8 @@ xml.dom.minidom.Element.all = xml.dom.minidom.Element.getElementsByTagName -obj = dbus.SessionBus().get_object("net.sf.gaim.GaimService", "/net/sf/gaim/GaimObject") -gaim = dbus.Interface(obj, "net.sf.gaim.GaimInterface") +obj = dbus.SessionBus().get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject") +purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface") class CheckedObject: def __init__(self, obj): @@ -31,7 +31,7 @@ return result def show_help(): - print """This program uses DBus to communicate with gaim. + print """This program uses DBus to communicate with purple. Usage: @@ -44,7 +44,7 @@ FunctionName(value1,value2,...) The second and third form are provided for completeness but their use -is not recommended; use gaim-send or gaim-send-async instead. The +is not recommended; use purple-send or purple-send-async instead. The second form uses introspection to find out the parameter names and their types, therefore it is rather slow. @@ -58,11 +58,11 @@ setstatus?status=away&message=don't disturb quit - GaimAccountsFindConnected?name=&protocol=prpl-jabber - GaimAccountFindConnected(,prpl-jabber) + PurpleAccountsFindConnected?name=&protocol=prpl-jabber + PurpleAccountFindConnected(,prpl-jabber) """ % sys.argv[0] -cgaim = CheckedObject(gaim) +cpurple = CheckedObject(purple) urlregexp = r"^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?" @@ -81,13 +81,13 @@ def findaccount(accountname, protocolname): try: # prefer connected accounts - account = cgaim.GaimAccountsFindConnected(accountname, protocolname) + account = cpurple.PurpleAccountsFindConnected(accountname, protocolname) return account except: # try to get any account and connect it - account = cgaim.GaimAccountsFindAny(accountname, protocolname) - gaim.GaimAccountSetStatusVargs(account, "online", 1) - gaim.GaimAccountConnect(account) + account = cpurple.PurpleAccountsFindAny(accountname, protocolname) + purple.PurpleAccountSetStatusVargs(account, "online", 1) + purple.PurpleAccountConnect(account) return account @@ -110,60 +110,60 @@ if command == "goim": account = findaccount(accountname, protocol) - conversation = cgaim.GaimConversationNew(1, account, params["screenname"]) + conversation = cpurple.PurpleConversationNew(1, account, params["screenname"]) if "message" in params: - im = cgaim.GaimConversationGetImData(conversation) - gaim.GaimConvImSend(im, params["message"]) + im = cpurple.PurpleConversationGetImData(conversation) + purple.PurpleConvImSend(im, params["message"]) return None elif command == "gochat": account = findaccount(accountname, protocol) - connection = cgaim.GaimAccountGetConnection(account) - return gaim.ServJoinChat(connection, params) + connection = cpurple.PurpleAccountGetConnection(account) + return purple.ServJoinChat(connection, params) elif command == "addbuddy": account = findaccount(accountname, protocol) - return cgaim.GaimBlistRequestAddBuddy(account, params["screenname"], + return cpurple.PurpleBlistRequestAddBuddy(account, params["screenname"], params.get("group", ""), "") elif command == "setstatus": - current = gaim.GaimSavedstatusGetCurrent() + current = purple.PurpleSavedstatusGetCurrent() if "status" in params: status_id = params["status"] - status_type = gaim.GaimPrimitiveGetTypeFromId(status_id) + status_type = purple.PurplePrimitiveGetTypeFromId(status_id) else: - status_type = gaim.GaimSavedstatusGetType(current) - status_id = gaim.GaimPrimitiveGetIdFromType(status_type) + status_type = purple.PurpleSavedstatusGetType(current) + status_id = purple.PurplePrimitiveGetIdFromType(status_type) if "message" in params: message = params["message"]; else: - message = gaim.GaimSavedstatusGetMessage(current) + message = purple.PurpleSavedstatusGetMessage(current) if "account" in params: - accounts = [cgaim.GaimAccountsFindAny(accountname, protocol)] + accounts = [cpurple.PurpleAccountsFindAny(accountname, protocol)] for account in accounts: - status = gaim.GaimAccountGetStatus(account, status_id) - type = gaim.GaimStatusGetType(status) - gaim.GaimSavedstatusSetSubstatus(current, account, type, message) - gaim.GaimSavedstatusActivateForAccount(current, account) + status = purple.PurpleAccountGetStatus(account, status_id) + type = purple.PurpleStatusGetType(status) + purple.PurpleSavedstatusSetSubstatus(current, account, type, message) + purple.PurpleSavedstatusActivateForAccount(current, account) else: - accounts = gaim.GaimAccountsGetAllActive() - saved = gaim.GaimSavedstatusNew("", status_type) - gaim.GaimSavedstatusSetMessage(saved, message) - gaim.GaimSavedstatusActivate(saved) + accounts = purple.PurpleAccountsGetAllActive() + saved = purple.PurpleSavedstatusNew("", status_type) + purple.PurpleSavedstatusSetMessage(saved, message) + purple.PurpleSavedstatusActivate(saved) return None elif command == "getinfo": account = findaccount(accountname, protocol) - connection = cgaim.GaimAccountGetConnection(account) - return gaim.ServGetInfo(connection, params["screenname"]) + connection = cpurple.PurpleAccountGetConnection(account) + return purple.ServGetInfo(connection, params["screenname"]) elif command == "quit": - return gaim.GaimCoreQuit() + return purple.PurpleCoreQuit() elif command == "uri": return None @@ -180,7 +180,7 @@ fargs = [] for arg in args: fargs.append(convert(arg.strip())) - return gaim.__getattr__(name)(*fargs) + return purple.__getattr__(name)(*fargs) else: # introspect the object to get parameter names and types # this is slow because the entire introspection info must be downloaded @@ -200,7 +200,7 @@ methodparams.append(int(value)) else: raise "Don't know how to handle type \"%s\"" % type - return gaim.__getattr__(command)(*methodparams) + return purple.__getattr__(command)(*methodparams) show_help() raise "Unknown command: %s" % command
--- a/libpurple/purple-send Sun Apr 15 18:06:49 2007 +0000 +++ b/libpurple/purple-send Sun Apr 15 18:09:14 2007 +0000 @@ -5,8 +5,8 @@ if test -z "$METHOD_NAME" then cat <<EOF -This program calls gaim API functions using DBus and prints the return value. -If you are not interested in the return value, use gaim-send-async. +This program calls purple API functions using DBus and prints the return value. +If you are not interested in the return value, use purple-send-async. Usage: @@ -17,9 +17,9 @@ Examples: - $0 GaimAccountsFindConnected string: string:prpl-jabber - $0 GaimAccountsGetAll - $0 GaimCoreQuit + $0 PurpleAccountsFindConnected string: string:prpl-jabber + $0 PurpleAccountsGetAll + $0 PurpleCoreQuit Use dbus-viewer to get the list of supported functions and their parameters. EOF @@ -27,6 +27,6 @@ fi shift -dbus-send --dest=net.sf.gaim.GaimService --print-reply --type=method_call /net/sf/gaim/GaimObject net.sf.gaim.GaimInterface.$METHOD_NAME "$@" +dbus-send --dest=im.pidgin.purple.PurpleService --print-reply --type=method_call /im/pidgin/purple/PurpleObject im.pidgin.purple.PurpleInterface.$METHOD_NAME "$@" echo
--- a/libpurple/purple-send-async Sun Apr 15 18:06:49 2007 +0000 +++ b/libpurple/purple-send-async Sun Apr 15 18:09:14 2007 +0000 @@ -5,7 +5,7 @@ if test -z "$METHOD_NAME" then cat <<EOF -This program calls gaim API functions using DBus. As opposed to gaim-send, +This program calls purple API functions using DBus. As opposed to purple-send, it does not print the return value. Usage: @@ -17,7 +17,7 @@ Examples: - $0 GaimCoreQuit + $0 PurpleCoreQuit Use dbus-viewer to get the list of supported functions and their parameters. EOF @@ -25,6 +25,6 @@ fi shift -dbus-send --dest=net.sf.gaim.GaimService --type=method_call /net/sf/gaim/GaimObject net.sf.gaim.GaimInterface.$METHOD_NAME "$@" +dbus-send --dest=im.pidgin.purple.PurpleService --type=method_call /im/pidgin/purple/PurpleObject im.pidgin.purple.PurpleInterface.$METHOD_NAME "$@" echo
--- a/libpurple/purple-url-handler Sun Apr 15 18:06:49 2007 +0000 +++ b/libpurple/purple-url-handler Sun Apr 15 18:09:14 2007 +0000 @@ -6,8 +6,8 @@ import time import urllib -obj = dbus.SessionBus().get_object("net.sf.gaim.GaimService", "/net/sf/gaim/GaimObject") -gaim = dbus.Interface(obj, "net.sf.gaim.GaimInterface") +obj = dbus.SessionBus().get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject") +purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface") class CheckedObject: def __init__(self, obj): @@ -27,7 +27,7 @@ raise "Error: " + self.attr + " " + str(args) + " returned " + str(result) return result -cgaim = CheckedObject(gaim) +cpurple = CheckedObject(purple) def extendlist(list, length, fill): if len(list) < length: @@ -44,42 +44,42 @@ def findaccount(protocolname, accountname=""): try: # prefer connected accounts - account = cgaim.GaimAccountsFindConnected(accountname, protocolname) + account = cpurple.PurpleAccountsFindConnected(accountname, protocolname) return account except: # try to get any account and connect it - account = cgaim.GaimAccountsFindAny(accountname, protocolname) - gaim.GaimAccountSetStatusVargs(account, "online", 1) - gaim.GaimAccountConnect(account) + account = cpurple.PurpleAccountsFindAny(accountname, protocolname) + purple.PurpleAccountSetStatusVargs(account, "online", 1) + purple.PurpleAccountConnect(account) return account def goim(account, screenname, message=None): - # XXX: 1 == GAIM_CONV_TYPE_IM - conversation = cgaim.GaimConversationNew(1, account, screenname) + # XXX: 1 == PURPLE_CONV_TYPE_IM + conversation = cpurple.PurpleConversationNew(1, account, screenname) if message: - gaim.GaimConvSendConfirm(conversation, message) + purple.PurpleConvSendConfirm(conversation, message) def gochat(account, params, message=None): - connection = cgaim.GaimAccountGetConnection(account) - gaim.ServJoinChat(connection, params) + connection = cpurple.PurpleAccountGetConnection(account) + purple.ServJoinChat(connection, params) if message != None: for i in range(20): - # XXX: 2 == GAIM_CONV_TYPE_CHAT - conversation = gaim.GaimFindConversationWithAccount(2, params.get("channel", params.get("room")), account) + # XXX: 2 == PURPLE_CONV_TYPE_CHAT + conversation = purple.PurpleFindConversationWithAccount(2, params.get("channel", params.get("room")), account) if conversation: - gaim.GaimConvSendConfirm(conversation, message) + purple.PurpleConvSendConfirm(conversation, message) break else: time.sleep(0.5) def addbuddy(account, screenname, group="", alias=""): - cgaim.GaimBlistRequestAddBuddy(account, screenname, group, alias) + cpurple.PurpleBlistRequestAddBuddy(account, screenname, group, alias) def aim(uri): - protocol = "prpl-oscar" - match = re.match(r"^(aim|icq):([^?]*)(\?(.*))", uri) + protocol = "prpl-aim" + match = re.match(r"^(aim):([^?]*)(\?(.*))", uri) if not match: print "Invalid aim URI: %s" % uri return @@ -115,7 +115,30 @@ goim(account, screenname) def icq(uri): - aim(uri) + protocol = "prpl-icq" + match = re.match(r"^(icq):([^?]*)(\?(.*))", uri) + if not match: + print "Invalid aim URI: %s" % uri + return + + command = urllib.unquote_plus(match.group(2)) + paramstring = match.group(4) + params = {} + if paramstring: + for param in paramstring.split("&"): + key, value = extendlist(param.split("=", 1), 2, "") + params[key] = urllib.unquote_plus(value) + accountname = params.get("account", "") + screenname = params.get("screenname", "") + + account = findaccount(protocol, accountname) + + if command.lower() == "goim": + goim(account, screenname, params.get("message")) + elif command.lower() == "gochat": + gochat(account, params) + elif command.lower() == "addbuddy": + addbuddy(account, screenname, params.get("group", "")) def irc(uri): protocol = "prpl-irc"
--- a/pidgin.spec.in Sun Apr 15 18:06:49 2007 +0000 +++ b/pidgin.spec.in Sun Apr 15 18:09:14 2007 +0000 @@ -374,7 +374,7 @@ %{_bindir}/purple-send-async %{_bindir}/purple-url-handler %{_libdir}/libpurple-client.so.* -%{_datadir}/dbus-1/services/gaim.service +%{_datadir}/dbus-1/services/purple.service %doc README.dbus %doc libpurple/purple-notifications-example %endif