Sat, 31 Jul 2004 21:29:40 +0000
[gaim-migrate @ 10464]
Changes to those get_alias functions in blist.c from
Christopher (siege) O'Brien:
Renames gaim_get_buddy_alias to gaim_buddy_get_alias
Renames gaim_get_buddy_alias_only to
_gaim_buddy_get_alias_only
Adds function gaim_buddy_get_contact_alias, which looks
up a buddy's appropriate display name by order of:
buddy alias; contact alias; server alias; buddy name.
Note that the buddy alias is still the top-priority.
Changed conversation.c to use _get_contact_alias rather
than _get_alias
The end result of this is that aliasing the contact
will result in conversations with any of that contact's
buddies using the contact alias. This allows people
like myself to no longer have to alias each buddy to
the same alias in order to achieve the same effect.
committer: Mark Doliner <markdoliner@pidgin.im>
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
1 | #include "internal.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2 | |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
3 | #include "blist.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
4 | #include "conversation.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5 | #include "debug.h" |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
6 | #include "signals.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
7 | |
| 9583 | 8 | #include "plugin.h" |
| 9 | #include "pluginpref.h" | |
| 10 | #include "prefs.h" | |
| 11 | ||
| 12 | #define STATENOTIFY_PLUGIN_ID "core-statenotify" | |
| 13 | ||
| 5267 | 14 | static void |
| 6695 | 15 | write_status(GaimBuddy *buddy, const char *message) |
| 5267 | 16 | { |
|
5676
d3c2fdaf4821
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5587
diff
changeset
|
17 | GaimConversation *conv; |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
18 | const char *who; |
| 5267 | 19 | char buf[256]; |
| 20 | ||
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
21 | conv = gaim_find_conversation_with_account(buddy->name, buddy->account); |
| 5267 | 22 | |
| 23 | if (conv == NULL) | |
| 24 | return; | |
| 25 | ||
|
9620
fe99fcea5c1c
[gaim-migrate @ 10464]
Christopher O'Brien <siege@pidgin.im>
parents:
9583
diff
changeset
|
26 | who = gaim_buddy_get_alias(buddy); |
| 5267 | 27 | |
|
6489
4281626455d8
[gaim-migrate @ 7003]
Robert McQueen <robot101@debian.org>
parents:
6485
diff
changeset
|
28 | g_snprintf(buf, sizeof(buf), message, who); |
| 5267 | 29 | |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6695
diff
changeset
|
30 | gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); |
| 5267 | 31 | } |
| 32 | ||
| 33 | static void | |
| 6695 | 34 | buddy_away_cb(GaimBuddy *buddy, void *data) |
| 5267 | 35 | { |
| 9583 | 36 | if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_away")) |
| 37 | write_status(buddy, _("%s has gone away.")); | |
| 5267 | 38 | } |
| 39 | ||
| 40 | static void | |
| 6695 | 41 | buddy_unaway_cb(GaimBuddy *buddy, void *data) |
| 5267 | 42 | { |
| 9583 | 43 | if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_away")) |
| 44 | write_status(buddy, _("%s is no longer away.")); | |
| 5267 | 45 | } |
| 46 | ||
| 47 | static void | |
| 6695 | 48 | buddy_idle_cb(GaimBuddy *buddy, void *data) |
| 5267 | 49 | { |
| 9583 | 50 | if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_idle")) |
| 51 | write_status(buddy, _("%s has become idle.")); | |
| 5267 | 52 | } |
| 53 | ||
| 54 | static void | |
| 6695 | 55 | buddy_unidle_cb(GaimBuddy *buddy, void *data) |
| 5267 | 56 | { |
| 9583 | 57 | if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_idle")) |
| 58 | write_status(buddy, _("%s is no longer idle.")); | |
| 59 | } | |
| 60 | ||
| 61 | static GaimPluginPrefFrame * | |
| 62 | get_plugin_pref_frame(GaimPlugin *plugin) | |
| 63 | { | |
| 64 | GaimPluginPrefFrame *frame; | |
| 65 | GaimPluginPref *ppref; | |
| 66 | ||
| 67 | frame = gaim_plugin_pref_frame_new(); | |
| 68 | ||
| 69 | ppref = gaim_plugin_pref_new_with_label("Notify When"); | |
| 70 | gaim_plugin_pref_frame_add(frame, ppref); | |
| 71 | ||
| 72 | ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/core/statenotify/notify_away", "Buddy Goes _Away"); | |
| 73 | gaim_plugin_pref_frame_add(frame, ppref); | |
| 74 | ||
| 75 | ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/core/statenotify/notify_idle", "Buddy Goes _Idle"); | |
| 76 | gaim_plugin_pref_frame_add(frame, ppref); | |
| 77 | ||
| 78 | return frame; | |
| 5267 | 79 | } |
| 80 | ||
| 81 | static gboolean | |
| 82 | plugin_load(GaimPlugin *plugin) | |
| 83 | { | |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
84 | void *blist_handle = gaim_blist_get_handle(); |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
85 | |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
86 | gaim_signal_connect(blist_handle, "buddy-away", |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
87 | plugin, GAIM_CALLBACK(buddy_away_cb), NULL); |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
88 | gaim_signal_connect(blist_handle, "buddy-back", |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
89 | plugin, GAIM_CALLBACK(buddy_unaway_cb), NULL); |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
90 | gaim_signal_connect(blist_handle, "buddy-idle", |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
91 | plugin, GAIM_CALLBACK(buddy_idle_cb), NULL); |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
92 | gaim_signal_connect(blist_handle, "buddy-unidle", |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
93 | plugin, GAIM_CALLBACK(buddy_unidle_cb), NULL); |
| 5267 | 94 | |
| 95 | return TRUE; | |
| 96 | } | |
| 97 | ||
| 9583 | 98 | static GaimPluginUiInfo prefs_info = |
| 99 | { | |
| 100 | get_plugin_pref_frame | |
| 101 | }; | |
| 102 | ||
| 5267 | 103 | static GaimPluginInfo info = |
| 104 | { | |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
105 | GAIM_PLUGIN_API_VERSION, /**< api_version */ |
| 5267 | 106 | GAIM_PLUGIN_STANDARD, /**< type */ |
| 107 | NULL, /**< ui_requirement */ | |
| 108 | 0, /**< flags */ | |
| 109 | NULL, /**< dependencies */ | |
| 110 | GAIM_PRIORITY_DEFAULT, /**< priority */ | |
| 111 | ||
| 9583 | 112 | STATENOTIFY_PLUGIN_ID, /**< id */ |
| 5267 | 113 | N_("Buddy State Notification"), /**< name */ |
| 114 | VERSION, /**< version */ | |
| 115 | /** summary */ | |
| 116 | N_("Notifies in a conversation window when a buddy goes or returns from " | |
| 117 | "away or idle."), | |
| 118 | /** description */ | |
| 119 | N_("Notifies in a conversation window when a buddy goes or returns from " | |
| 120 | "away or idle."), | |
| 121 | "Christian Hammond <chipx86@gnupdate.org>", /**< author */ | |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
122 | GAIM_WEBSITE, /**< homepage */ |
| 5267 | 123 | |
| 124 | plugin_load, /**< load */ | |
| 125 | NULL, /**< unload */ | |
| 126 | NULL, /**< destroy */ | |
| 127 | ||
| 128 | NULL, /**< ui_info */ | |
| 8993 | 129 | NULL, /**< extra_info */ |
| 9583 | 130 | &prefs_info, /**< prefs_info */ |
| 8993 | 131 | NULL |
| 5267 | 132 | }; |
| 133 | ||
| 134 | static void | |
|
5920
963bfdefee02
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5873
diff
changeset
|
135 | init_plugin(GaimPlugin *plugin) |
| 5267 | 136 | { |
| 9583 | 137 | gaim_prefs_add_none("/plugins/core/statenotify"); |
| 138 | gaim_prefs_add_bool("/plugins/core/statenotify/notify_away", TRUE); | |
| 139 | gaim_prefs_add_bool("/plugins/core/statenotify/notify_idle", TRUE); | |
| 5267 | 140 | } |
| 141 | ||
| 6063 | 142 | GAIM_INIT_PLUGIN(statenotify, init_plugin, info) |