mirror of https://github.com/deavminet/gustav.git
Only loop through Channel objects
This commit is contained in:
parent
be543d33fd
commit
029cd5a3ee
|
@ -11,6 +11,7 @@ import gtk.ListBox;
|
||||||
import gtk.Label;
|
import gtk.Label;
|
||||||
|
|
||||||
import areas.Channel;
|
import areas.Channel;
|
||||||
|
import areas.MessageArea;
|
||||||
import std.string;
|
import std.string;
|
||||||
|
|
||||||
import core.sync.mutex;
|
import core.sync.mutex;
|
||||||
|
@ -45,7 +46,7 @@ public final class Connection : Thread
|
||||||
private Notebook notebookSwitcher;
|
private Notebook notebookSwitcher;
|
||||||
private Channel[] chans; /*TODO: Technically locking by GTK would make this not needed */
|
private Channel[] chans; /*TODO: Technically locking by GTK would make this not needed */
|
||||||
private Mutex chansLock;
|
private Mutex chansLock;
|
||||||
private Channel focusedChan;
|
private MessageArea focusedChan;
|
||||||
|
|
||||||
|
|
||||||
// public void setPrescence(string pres)
|
// public void setPrescence(string pres)
|
||||||
|
@ -318,20 +319,34 @@ public final class Connection : Thread
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: Update this to do an `instanceof` check for the correct MessageArea sub-type */
|
||||||
public Channel findChannel(string channelName)
|
public Channel findChannel(string channelName)
|
||||||
{
|
{
|
||||||
Channel result;
|
Channel result;
|
||||||
|
|
||||||
chansLock.lock();
|
chansLock.lock();
|
||||||
|
|
||||||
foreach(Channel channel; chans)
|
/**
|
||||||
|
* Loop through each MessageArea and only inspect those
|
||||||
|
* whose type is `Channel`
|
||||||
|
*/
|
||||||
|
foreach(MessageArea area; chans)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/* Make sure the object is of type `Channel` */
|
||||||
|
if(typeid(area) == typeid(Channel))
|
||||||
|
{
|
||||||
|
/* Down-cast */
|
||||||
|
Channel channel = cast(Channel)area;
|
||||||
|
|
||||||
|
/* Find the matching channel */
|
||||||
if(cmp(channel.getName(), channelName) == 0)
|
if(cmp(channel.getName(), channelName) == 0)
|
||||||
{
|
{
|
||||||
result = channel;
|
result = channel;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
writeln("\""~channelName~"\"");
|
writeln("\""~channelName~"\"");
|
||||||
|
|
|
@ -29,7 +29,7 @@ public final class User : MessageArea
|
||||||
private Connection connection;
|
private Connection connection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* USername
|
* Username
|
||||||
*/
|
*/
|
||||||
private string username;
|
private string username;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue