diff --git a/source/Connection.d b/source/Connection.d index 85a9b45..d4fafe1 100644 --- a/source/Connection.d +++ b/source/Connection.d @@ -11,6 +11,7 @@ import gtk.ListBox; import gtk.Label; import areas.Channel; +import areas.MessageArea; import std.string; import core.sync.mutex; @@ -45,7 +46,7 @@ public final class Connection : Thread private Notebook notebookSwitcher; private Channel[] chans; /*TODO: Technically locking by GTK would make this not needed */ private Mutex chansLock; - private Channel focusedChan; + private MessageArea focusedChan; // public void setPrescence(string pres) @@ -318,18 +319,32 @@ public final class Connection : Thread } } + /* TODO: Update this to do an `instanceof` check for the correct MessageArea sub-type */ public Channel findChannel(string channelName) { Channel result; chansLock.lock(); - foreach(Channel channel; chans) + /** + * Loop through each MessageArea and only inspect those + * whose type is `Channel` + */ + foreach(MessageArea area; chans) { - if(cmp(channel.getName(), channelName) == 0) + + /* Make sure the object is of type `Channel` */ + if(typeid(area) == typeid(Channel)) { - result = channel; - break; + /* Down-cast */ + Channel channel = cast(Channel)area; + + /* Find the matching channel */ + if(cmp(channel.getName(), channelName) == 0) + { + result = channel; + break; + } } } diff --git a/source/areas/User.d b/source/areas/User.d index e4be63b..217aad9 100644 --- a/source/areas/User.d +++ b/source/areas/User.d @@ -29,7 +29,7 @@ public final class User : MessageArea private Connection connection; /** - * USername + * Username */ private string username;