Mercurial > pidgin
annotate plugins/dbus-example.c @ 12645:fc28451f5d96
[gaim-migrate @ 14983]
SF Patch #1314512 from Sadrul (who has a patch for everything)
"This patch introduces a flag for protocol plugins that
support offline messages (like Y!M and ICQ). This was
encouraged by the following conversation:
<sadrul> should offline buddies be listed/enabled in
the send-to menu?
<rekkanoryo> i would think only for protocols that
support offline messaging, if it's indicated that the
buddy is offline
-- <snip> --
<Bleeter> sadrul: personally, I'd like to see a
'supports offline' flag of some description
<Bleeter> one could then redirect (via plugins) through
email or alternative methods
<Bleeter> just a thought
<Paco-Paco> yeah, that sounds like a reasonble thing to have
This patch uses this flag to disable the buddies in the
send-to menu who are offline and the protocol doesn't
support offline messages."
I made this make the label insensitive instead of the whole menuitem. This
should address SimGuy's concerns about inconsistency (i.e. you could create a
conversation with someone via the buddy list that you couldn't create via the
Send To menu). I also hacked up some voodoo to show the label as sensitive when
moused-over, as that looks better (given the label-insensitive thing is itself a
hack). I think this works quite well.
BUG NOTE:
This makes more obvious an existing bug. The Send To menu isn't updated when
buddies sign on or off or change status (at least under some circumstances).
We need to fix that anyway, so I'm not going to let it hold up this commit.
Switching tabs will clear it up. I'm thinking we just might want to build the
contents of that menu when it is selected. That would save us a mess of
inefficient signal callbacks that update the Send To menus in open windows all
the time.
AIM NOTE:
This assumes that AIM can't offline message. That's not strictly true. You can
message invisible users on AIM. However, by design, we can't tell when a user
is invisible without resorting to dirty hackery. In practice, this isn't a
problem, as you can still select the AIM user from the menu. And really, how
often will you be choosing the Invisible contact, rather than the user going
Invisible in the middle of a conversation or IMing you while they're Invisible?
JABBER NOTE:
This assumes that Jabber can always offline message. This isn't strictly true.
Sadrul said:
I have updated Jabber according to this link which seems to
talk about how to determine the existence offline-message
support in a server:
http://www.jabber.org/jeps/jep-0013.html#discover
However, jabber.org doesn't seem to send the required
info. So I am not sure about it.
He later said:
I talked to Nathan and he said offline message support is
mostly assumed for most jabber servers. GTalk doesn't yet
support it, but they are working on it. So I have made
jabber to always return TRUE.
If there is truly no way to detect offline messaging capability, then this is
an acceptable solution. We could special case Google Talk because of its
popularity, and remove that later. It's probably not worth it though.
MSN NOTE:
This assumes that MSN can never offline message. That's effectively true, but
to be technically correct, MSN can offline message if there's already a
switchboard conversation open with a user. We could write an offline_message
function in the MSN prpl to detect that, but it'd be of limited usefulness,
especially given that under most circumstances (where this might matter), the
switchboard connection will be closed almost immediately.
CVS NOTE:
I'm writing to share a tragic little story.
I have a PC that I use for Gaim development. One day, I was writing a commit
message on it, when all of a suddent it went berserk. The screen started
flashing, and the whole commit message just disappeared. All of it. And it was
a good commit message! I had to cram and rewrite it really quickly. Needless to
say, my rushed commit message wasn't nearly as good, and I blame the PC for that.
Seriously, though, what kind of version control system loses your commit
message on a broken connection to the server? Stupid!
committer: Tailor Script <tailor@pidgin.im>
| author | Richard Laager <rlaager@wiktel.com> |
|---|---|
| date | Fri, 23 Dec 2005 19:26:04 +0000 |
| parents | 4295083cf489 |
| children | a7b24ba66570 |
| rev | line source |
|---|---|
| 11173 | 1 /* |
| 2 This is an example of a gaim dbus plugin. After enabling this | |
| 3 plugin, the following commands should work from the command line: | |
| 4 | |
| 5 prompt$ gaim-send DbusExampleGetHelloObject | |
| 6 | |
| 7 returns, say: int32 74 | |
| 8 | |
| 9 prompt$ gaim-send DbusExampleGetText int32:74 | |
| 10 | |
| 11 returns: string "Hello." | |
| 12 | |
| 13 prompt$ gaim-send DbusExampleSetText int32:74 string:Bye! | |
| 14 | |
| 15 prompt$ gaim-send DbusExampleGetText int32:74 | |
| 16 | |
| 17 returns: string "Bye!" | |
| 18 | |
| 19 */ | |
| 20 | |
| 21 #include "internal.h" | |
| 22 | |
| 23 #include "plugin.h" | |
| 24 #include "blist.h" | |
| 25 #include "version.h" | |
| 26 | |
| 27 #include <stdio.h> | |
| 28 #include <stdlib.h> | |
| 29 #include <string.h> | |
| 30 | |
| 31 #define DBUS_API_SUBJECT_TO_CHANGE | |
| 32 #include "dbus-maybe.h" | |
| 33 #include "dbus-bindings.h" | |
| 34 | |
| 35 typedef struct { | |
| 36 char *text; | |
| 37 } GaimText; | |
| 38 | |
| 39 /* This makes the structure GaimText visible to the gaim-dbus type | |
| 40 system. It defines GaimText as a type with no parent. From now | |
| 41 on, we will be able to register pointers to structures of this | |
| 42 type. You to dbus-define types you want to be directly accessible | |
| 43 by external applications. */ | |
| 44 GAIM_DBUS_DEFINE_TYPE(GaimText) | |
| 45 | |
| 46 /* Here we make four functions accessible to other applications by | |
| 47 DBus. These functions can access types defined in gaim proper | |
| 48 (GaimBuddy) as well as the types defined in the plugin (GaimText). */ | |
| 49 DBUS_EXPORT GaimText* dbus_example_get_hello_object(void); | |
| 50 DBUS_EXPORT void dbus_example_set_text(GaimText *obj, const char *text); | |
| 51 DBUS_EXPORT const char *dbus_example_get_text(GaimText *obj); | |
| 52 DBUS_EXPORT const char *dbus_example_get_buddy_name(GaimBuddy *buddy); | |
| 53 | |
| 54 /* This file has been generated by the #dbus-analize-functions.py | |
| 55 script. It contains dbus wrappers for the four functions declared | |
| 56 above. */ | |
| 57 #include "dbus-example-bindings.c" | |
| 58 | |
| 59 /* This is the GaimText object we want to make publicly visible. */ | |
| 60 static GaimText hello; | |
| 61 | |
| 62 /* Here come the definitions of the four exported functions. */ | |
| 63 GaimText* dbus_example_get_hello_object(void) | |
| 64 { | |
| 65 return &hello; | |
| 66 } | |
| 67 | |
| 68 void dbus_example_set_text(GaimText *obj, const char *text) | |
| 69 { | |
| 70 if (obj != NULL) { | |
| 71 g_free(obj->text); | |
| 72 obj->text = g_strdup(text); | |
| 73 } | |
| 74 } | |
| 75 | |
| 76 const char *dbus_example_get_text(GaimText *obj) | |
| 77 { | |
| 78 if (obj != NULL) | |
| 79 return obj->text; | |
| 80 else | |
| 81 return NULL; | |
| 82 } | |
| 83 | |
| 84 const char *dbus_example_get_buddy_name(GaimBuddy *buddy) | |
| 85 { | |
| 86 return gaim_buddy_get_name(buddy); | |
| 87 } | |
| 88 | |
| 89 /* And now standard plugin stuff */ | |
| 90 | |
| 91 static gboolean | |
| 92 plugin_load(GaimPlugin *plugin) | |
| 93 { | |
| 94 /* First, we have to register our four exported functions with the | |
| 95 main gaim dbus loop. Without this statement, the gaim dbus | |
| 96 code wouldn't know about our functions. */ | |
| 97 GAIM_DBUS_REGISTER_BINDINGS(plugin); | |
| 98 | |
| 99 /* Then, we register the hello object of type GaimText. Note that | |
| 100 pointer registrations / unregistrations are completely dynamic; | |
| 101 they don't have to be made when the plugin is loaded / | |
| 102 unloaded. Without this statement the dbus gaim code wouldn't | |
| 103 know about the hello object. */ | |
| 104 GAIM_DBUS_REGISTER_POINTER(&hello, GaimText); | |
| 105 | |
| 106 hello.text = g_strdup("Hello."); | |
| 107 | |
| 108 return TRUE; | |
| 109 } | |
| 110 | |
| 111 | |
| 112 static gboolean | |
| 113 plugin_unload(GaimPlugin *plugin) | |
| 114 { | |
| 115 g_free(hello.text); | |
| 116 | |
| 117 /* It is necessary to unregister all pointers registered by the module. */ | |
| 118 GAIM_DBUS_UNREGISTER_POINTER(&hello); | |
| 119 | |
| 120 return TRUE; | |
| 121 } | |
| 122 | |
| 123 static GaimPluginInfo info = | |
| 124 { | |
| 125 GAIM_PLUGIN_MAGIC, | |
| 126 GAIM_MAJOR_VERSION, | |
| 127 GAIM_MINOR_VERSION, | |
| 128 GAIM_PLUGIN_STANDARD, /**< type */ | |
| 129 NULL, /**< ui_requirement */ | |
| 130 0, /**< flags */ | |
| 131 NULL, /**< dependencies */ | |
| 132 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
| 133 | |
| 134 "dbus-example", /**< id */ | |
| 135 N_("DBus"), /**< name */ | |
| 136 VERSION, /**< version */ | |
| 137 /** summary */ | |
| 138 N_("DBus Plugin Example"), | |
| 139 /** description */ | |
| 140 N_("DBus Plugin Example"), | |
| 141 "Piotr Zielinski (http://cl.cam.ac.uk/~pz215)", /**< author */ | |
| 142 GAIM_WEBSITE, /**< homepage */ | |
| 143 | |
| 144 plugin_load, /**< load */ | |
| 145 plugin_unload, /**< unload */ | |
| 146 NULL, /**< destroy */ | |
| 147 | |
| 148 NULL, /**< ui_info */ | |
| 149 NULL, /**< extra_info */ | |
| 150 NULL, /**< prefs_info */ | |
| 151 NULL | |
| 152 }; | |
| 153 | |
| 154 static void init_plugin(GaimPlugin *plugin) | |
| 155 { | |
| 156 } | |
| 157 | |
| 158 GAIM_INIT_PLUGIN(dbus_example, init_plugin, info) |
