[smuxi/experiments/certfp: 19/55] Engine, Frontend-GNOME: removed UrlMessagePartModel.Protocol
- From: Mirco M. M. Bauer <mmmbauer src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [smuxi/experiments/certfp: 19/55] Engine, Frontend-GNOME: removed UrlMessagePartModel.Protocol
- Date: Sun, 12 Jan 2014 07:27:51 +0000 (UTC)
commit ed0dd9bfb227b54a08be14112bfb2b44c6c9b981
Author: Oliver Schneider <mail oli-obk de>
Date: Fri Mar 8 10:50:43 2013 +0100
Engine, Frontend-GNOME: removed UrlMessagePartModel.Protocol
src/Engine/Messages/UrlMessagePartModel.cs | 55 ++------------------------
src/Frontend-GNOME/Views/MessageTextView.cs | 5 +-
2 files changed, 7 insertions(+), 53 deletions(-)
---
diff --git a/src/Engine/Messages/UrlMessagePartModel.cs b/src/Engine/Messages/UrlMessagePartModel.cs
index 5a7d798..8c4c83b 100644
--- a/src/Engine/Messages/UrlMessagePartModel.cs
+++ b/src/Engine/Messages/UrlMessagePartModel.cs
@@ -51,7 +51,6 @@ namespace Smuxi.Engine
#if LOG4NET
private static readonly log4net.ILog _Logger =
log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endif
- private UrlProtocol _Protocol;
private string _Url;
public string Url {
@@ -65,16 +64,7 @@ namespace Smuxi.Engine
_Url = value;
}
}
-
- public UrlProtocol Protocol {
- get {
- return _Protocol;
- }
- set {
- _Protocol = value;
- }
- }
-
+
public UrlMessagePartModel(string url) :
this(url, null)
{
@@ -84,34 +74,17 @@ namespace Smuxi.Engine
: base(model)
{
if (model is UrlMessagePartModel) {
- _Protocol = (model as UrlMessagePartModel)._Protocol;
_Url = (model as UrlMessagePartModel)._Url;
}
}
public UrlMessagePartModel(string url, string text):
- this(url, text, UrlProtocol.None)
-
- {
- _Protocol = ParseProtocol(url);
- if (_Protocol == UrlProtocol.None) {
- // assume http if no protocol was specified
- _Protocol = UrlProtocol.Http;
- // text should stay pristine
- if (Text == null) {
- Text = _Url;
- }
- _Url = String.Format("http://{0}", _Url);
- }
- }
-
- public UrlMessagePartModel(string url, string text, UrlProtocol protocol) :
base(text)
+
{
_Url = url;
- _Protocol = protocol;
}
-
+
protected UrlMessagePartModel(SerializationInfo info, StreamingContext ctx) :
base(info, ctx)
{
@@ -121,7 +94,7 @@ namespace Smuxi.Engine
{
base.SetObjectData(sr);
- _Protocol = (UrlProtocol) sr.ReadInt32();
+ sr.ReadInt32();
_Url = sr.ReadString();
}
@@ -129,28 +102,10 @@ namespace Smuxi.Engine
{
base.GetObjectData(sw);
- sw.Write((Int32) _Protocol);
+ sw.Write((Int32) UrlProtocol.Unknown);
sw.Write(_Url);
}
- protected static UrlProtocol ParseProtocol(string url)
- {
- Match match = Regex.Match(url, @"^([a-zA-Z0-9\-]+):");
- if (!match.Success) {
- return UrlProtocol.None;
- }
-
- string protocol = match.Groups[1].Value;
- try {
- return (UrlProtocol) Enum.Parse(typeof(UrlProtocol), protocol, true);
- } catch (ArgumentException ex) {
-#if LOG4NET
- _Logger.Error("ParseProtocol(url): error parsing protocol: " + protocol, ex);
-#endif
- }
- return UrlProtocol.Unknown;
- }
-
public override string ToString()
{
if (Text == null) {
diff --git a/src/Frontend-GNOME/Views/MessageTextView.cs b/src/Frontend-GNOME/Views/MessageTextView.cs
index 7c48961..40d2c83 100644
--- a/src/Frontend-GNOME/Views/MessageTextView.cs
+++ b/src/Frontend-GNOME/Views/MessageTextView.cs
@@ -334,13 +334,12 @@ namespace Smuxi.Frontend.Gnome
var urlPart = (UrlMessagePartModel) msgPart;
var linkText = urlPart.Text ?? urlPart.Url;
- var url = urlPart.Url;
Uri uri;
try {
- uri = new Uri(url);
+ uri = new Uri(urlPart.Url);
} catch (UriFormatException ex) {
#if LOG4NET
- _Logger.Error("AddMessage(): Invalid URL: " + url, ex);
+ _Logger.Error("AddMessage(): Invalid URL: " + urlPart.Url, ex);
#endif
buffer.Insert(ref iter, linkText);
continue;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]