Wed, 23 May 2007 03:59:19 +0000
Fix file transfers aborting and mistakenly being marked as cancelled when they are actually complete. Fixes #814
|
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" |
| 9943 | 7 | #include "version.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
8 | |
| 9583 | 9 | #include "plugin.h" |
| 10 | #include "pluginpref.h" | |
| 11 | #include "prefs.h" | |
| 12 | ||
| 13 | #define STATENOTIFY_PLUGIN_ID "core-statenotify" | |
| 14 | ||
| 5267 | 15 | static void |
| 15884 | 16 | write_status(PurpleBuddy *buddy, const char *message) |
| 5267 | 17 | { |
| 15884 | 18 | PurpleConversation *conv; |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
19 | const char *who; |
| 5267 | 20 | char buf[256]; |
|
10167
3f4db9c54e04
[gaim-migrate @ 11254]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9943
diff
changeset
|
21 | char *escaped; |
| 5267 | 22 | |
| 15884 | 23 | conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, |
|
10246
aa5bff72f94c
[gaim-migrate @ 11386]
Mark Doliner <markdoliner@pidgin.im>
parents:
10167
diff
changeset
|
24 | buddy->name, buddy->account); |
| 5267 | 25 | |
| 26 | if (conv == NULL) | |
| 27 | return; | |
| 15884 | 28 | g_return_if_fail(conv->type == PURPLE_CONV_TYPE_IM); |
| 5267 | 29 | |
| 15884 | 30 | who = purple_buddy_get_alias(buddy); |
|
10167
3f4db9c54e04
[gaim-migrate @ 11254]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9943
diff
changeset
|
31 | escaped = g_markup_escape_text(who, -1); |
| 5267 | 32 | |
|
10167
3f4db9c54e04
[gaim-migrate @ 11254]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9943
diff
changeset
|
33 | g_snprintf(buf, sizeof(buf), message, escaped); |
|
3f4db9c54e04
[gaim-migrate @ 11254]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9943
diff
changeset
|
34 | g_free(escaped); |
| 5267 | 35 | |
| 15884 | 36 | purple_conv_im_write(conv->u.im, NULL, buf, PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_ACTIVE_ONLY, time(NULL)); |
| 5267 | 37 | } |
| 38 | ||
| 39 | static void | |
| 15884 | 40 | buddy_status_changed_cb(PurpleBuddy *buddy, PurpleStatus *old_status, |
| 41 | PurpleStatus *status, void *data) | |
| 5267 | 42 | { |
| 11935 | 43 | gboolean available, old_available; |
| 44 | ||
| 15884 | 45 | available = purple_status_is_available(status); |
| 46 | old_available = purple_status_is_available(old_status); | |
| 11935 | 47 | |
| 16481 | 48 | if (purple_prefs_get_bool("/plugins/core/statenotify/notify_away")) { |
| 11935 | 49 | if (available && !old_available) |
| 50 | write_status(buddy, _("%s is no longer away.")); | |
| 51 | else if (!available && old_available) | |
| 52 | write_status(buddy, _("%s has gone away.")); | |
| 53 | } | |
| 5267 | 54 | } |
| 55 | ||
| 56 | static void | |
| 15884 | 57 | buddy_idle_changed_cb(PurpleBuddy *buddy, gboolean old_idle, gboolean idle, |
| 11935 | 58 | void *data) |
| 5267 | 59 | { |
| 16481 | 60 | if (purple_prefs_get_bool("/plugins/core/statenotify/notify_idle")) { |
| 11935 | 61 | if (idle) { |
| 62 | write_status(buddy, _("%s has become idle.")); | |
| 63 | } else { | |
| 64 | write_status(buddy, _("%s is no longer idle.")); | |
| 65 | } | |
| 66 | } | |
| 9583 | 67 | } |
| 68 | ||
|
11901
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
69 | static void |
| 15884 | 70 | buddy_signon_cb(PurpleBuddy *buddy, void *data) |
|
11901
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
71 | { |
| 16481 | 72 | if (purple_prefs_get_bool("/plugins/core/statenotify/notify_signon")) |
|
11901
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
73 | write_status(buddy, _("%s has signed on.")); |
|
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
74 | } |
|
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
75 | |
|
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
76 | static void |
| 15884 | 77 | buddy_signoff_cb(PurpleBuddy *buddy, void *data) |
|
11901
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
78 | { |
| 16481 | 79 | if (purple_prefs_get_bool("/plugins/core/statenotify/notify_signon")) |
|
11901
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
80 | write_status(buddy, _("%s has signed off.")); |
|
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
81 | } |
|
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
82 | |
| 15884 | 83 | static PurplePluginPrefFrame * |
| 84 | get_plugin_pref_frame(PurplePlugin *plugin) | |
| 9583 | 85 | { |
| 15884 | 86 | PurplePluginPrefFrame *frame; |
| 87 | PurplePluginPref *ppref; | |
| 9583 | 88 | |
| 15884 | 89 | frame = purple_plugin_pref_frame_new(); |
| 9583 | 90 | |
| 15884 | 91 | ppref = purple_plugin_pref_new_with_label(_("Notify When")); |
| 92 | purple_plugin_pref_frame_add(frame, ppref); | |
| 9583 | 93 | |
| 16481 | 94 | ppref = purple_plugin_pref_new_with_name_and_label("/plugins/core/statenotify/notify_away", _("Buddy Goes _Away")); |
| 15884 | 95 | purple_plugin_pref_frame_add(frame, ppref); |
|
10246
aa5bff72f94c
[gaim-migrate @ 11386]
Mark Doliner <markdoliner@pidgin.im>
parents:
10167
diff
changeset
|
96 | |
| 16481 | 97 | ppref = purple_plugin_pref_new_with_name_and_label("/plugins/core/statenotify/notify_idle", _("Buddy Goes _Idle")); |
| 15884 | 98 | purple_plugin_pref_frame_add(frame, ppref); |
|
10246
aa5bff72f94c
[gaim-migrate @ 11386]
Mark Doliner <markdoliner@pidgin.im>
parents:
10167
diff
changeset
|
99 | |
| 16481 | 100 | ppref = purple_plugin_pref_new_with_name_and_label("/plugins/core/statenotify/notify_signon", _("Buddy _Signs On/Off")); |
| 15884 | 101 | purple_plugin_pref_frame_add(frame, ppref); |
|
11901
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
102 | |
| 9583 | 103 | return frame; |
| 5267 | 104 | } |
| 105 | ||
| 106 | static gboolean | |
| 15884 | 107 | plugin_load(PurplePlugin *plugin) |
| 5267 | 108 | { |
| 15884 | 109 | void *blist_handle = purple_blist_get_handle(); |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
110 | |
| 15884 | 111 | purple_signal_connect(blist_handle, "buddy-status-changed", plugin, |
| 112 | PURPLE_CALLBACK(buddy_status_changed_cb), NULL); | |
| 113 | purple_signal_connect(blist_handle, "buddy-idle-changed", plugin, | |
| 114 | PURPLE_CALLBACK(buddy_idle_changed_cb), NULL); | |
| 115 | purple_signal_connect(blist_handle, "buddy-signed-on", plugin, | |
| 116 | PURPLE_CALLBACK(buddy_signon_cb), NULL); | |
| 117 | purple_signal_connect(blist_handle, "buddy-signed-off", plugin, | |
| 118 | PURPLE_CALLBACK(buddy_signoff_cb), NULL); | |
| 5267 | 119 | |
| 120 | return TRUE; | |
| 121 | } | |
| 122 | ||
| 15884 | 123 | static PurplePluginUiInfo prefs_info = |
| 9583 | 124 | { |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
11935
diff
changeset
|
125 | get_plugin_pref_frame, |
|
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
11935
diff
changeset
|
126 | 0, /* page_num (Reserved) */ |
|
16745
df2c3d6b609a
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16481
diff
changeset
|
127 | NULL, /* frame (Reserved) */ |
|
df2c3d6b609a
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16481
diff
changeset
|
128 | |
|
df2c3d6b609a
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16481
diff
changeset
|
129 | /* padding */ |
|
df2c3d6b609a
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16481
diff
changeset
|
130 | NULL, |
|
df2c3d6b609a
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16481
diff
changeset
|
131 | NULL, |
|
df2c3d6b609a
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16481
diff
changeset
|
132 | NULL, |
|
df2c3d6b609a
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16481
diff
changeset
|
133 | NULL |
| 9583 | 134 | }; |
| 135 | ||
| 15884 | 136 | static PurplePluginInfo info = |
| 5267 | 137 | { |
| 15884 | 138 | PURPLE_PLUGIN_MAGIC, |
| 139 | PURPLE_MAJOR_VERSION, | |
| 140 | PURPLE_MINOR_VERSION, | |
| 141 | PURPLE_PLUGIN_STANDARD, /**< type */ | |
| 5267 | 142 | NULL, /**< ui_requirement */ |
| 143 | 0, /**< flags */ | |
| 144 | NULL, /**< dependencies */ | |
| 15884 | 145 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
| 5267 | 146 | |
| 9583 | 147 | STATENOTIFY_PLUGIN_ID, /**< id */ |
| 5267 | 148 | N_("Buddy State Notification"), /**< name */ |
| 149 | VERSION, /**< version */ | |
| 150 | /** summary */ | |
| 151 | N_("Notifies in a conversation window when a buddy goes or returns from " | |
| 152 | "away or idle."), | |
| 153 | /** description */ | |
| 154 | N_("Notifies in a conversation window when a buddy goes or returns from " | |
| 155 | "away or idle."), | |
| 156 | "Christian Hammond <chipx86@gnupdate.org>", /**< author */ | |
| 15884 | 157 | PURPLE_WEBSITE, /**< homepage */ |
| 5267 | 158 | |
| 159 | plugin_load, /**< load */ | |
| 160 | NULL, /**< unload */ | |
| 161 | NULL, /**< destroy */ | |
| 162 | ||
| 163 | NULL, /**< ui_info */ | |
| 8993 | 164 | NULL, /**< extra_info */ |
| 9583 | 165 | &prefs_info, /**< prefs_info */ |
|
16745
df2c3d6b609a
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16481
diff
changeset
|
166 | NULL, |
|
df2c3d6b609a
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16481
diff
changeset
|
167 | |
|
df2c3d6b609a
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16481
diff
changeset
|
168 | /* padding */ |
|
df2c3d6b609a
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16481
diff
changeset
|
169 | NULL, |
|
df2c3d6b609a
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16481
diff
changeset
|
170 | NULL, |
|
df2c3d6b609a
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16481
diff
changeset
|
171 | NULL, |
| 8993 | 172 | NULL |
| 5267 | 173 | }; |
| 174 | ||
| 175 | static void | |
| 15884 | 176 | init_plugin(PurplePlugin *plugin) |
| 5267 | 177 | { |
| 16481 | 178 | purple_prefs_add_none("/plugins/core/statenotify"); |
| 179 | purple_prefs_add_bool("/plugins/core/statenotify/notify_away", TRUE); | |
| 180 | purple_prefs_add_bool("/plugins/core/statenotify/notify_idle", TRUE); | |
| 181 | purple_prefs_add_bool("/plugins/core/statenotify/notify_signon", TRUE); | |
| 5267 | 182 | } |
| 183 | ||
| 15884 | 184 | PURPLE_INIT_PLUGIN(statenotify, init_plugin, info) |