[smuxi: 8/15] [Common] Add an onError callback to IconCache
- From: Mirco M. M. Bauer <mmmbauer src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [smuxi: 8/15] [Common] Add an onError callback to IconCache
- Date: Tue, 3 Feb 2015 01:07:38 +0000 (UTC)
commit 952b32b0394a7cc3323c10556391a9393428b661
Author: Carlos MartÃn Nieto <cmn dwim me>
Date: Sat Jan 31 19:08:57 2015 +0100
[Common] Add an onError callback to IconCache
This callback will be used when something goes wrong, such that the
requester can know when to switch to an error pixbuf.
src/Common/IconCache.cs | 7 ++++++-
src/Frontend-GNOME/Views/Chats/ProtocolChatView.cs | 2 +-
2 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/src/Common/IconCache.cs b/src/Common/IconCache.cs
index 48e71d0..dddc077 100644
--- a/src/Common/IconCache.cs
+++ b/src/Common/IconCache.cs
@@ -86,10 +86,12 @@ namespace Smuxi.Common
/// <param name="iconName">Name of the icon, including extension</param>
/// <param name="websiteUrl">The url from which to download the icon</param>
/// <param name="onSuccess">Function to call after downloading the icon</param>
+ /// <param name="onError">Function to call if an error happens (optinal)</param>
/// <remarks>
/// This method is thread safe
/// </remarks>
- public void DownloadIcon(string protocol, string iconName, string websiteUrl, Action<string>
onSuccess)
+ public void DownloadIcon(string protocol, string iconName, string websiteUrl,
+ Action<string> onSuccess, Action<Exception> onError)
{
ThreadPool.QueueUserWorkItem(delegate {
try {
@@ -108,6 +110,9 @@ namespace Smuxi.Common
#if LOG4NET
f_Logger.Error("DownloadIcon(): Exception", ex);
#endif
+ if (onError != null) {
+ onError(ex);
+ }
}
});
}
diff --git a/src/Frontend-GNOME/Views/Chats/ProtocolChatView.cs
b/src/Frontend-GNOME/Views/Chats/ProtocolChatView.cs
index fd38017..9f9f558 100644
--- a/src/Frontend-GNOME/Views/Chats/ProtocolChatView.cs
+++ b/src/Frontend-GNOME/Views/Chats/ProtocolChatView.cs
@@ -244,7 +244,7 @@ namespace Smuxi.Frontend.Gnome
}
}
iconCache.Proxy = proxy;
- iconCache.DownloadIcon(protocol, iconName, websiteUrl, UpdateServerIcon);
+ iconCache.DownloadIcon(protocol, iconName, websiteUrl, UpdateServerIcon, null);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]