Compare commits

...

34 Commits

Author SHA1 Message Date
Tristan B. Kildaire 426a65cf96 Sucked those offsets out of my thumb, I couldn't be ared right now 2021-01-28 16:39:08 +02:00
Tristan B. Kildaire 66bb86e4cd WIP: Direct messages woith `from` field
Just offset incorrectly it seems
2021-01-28 16:26:57 +02:00
Tristan B. Kildaire 3d6e01fb2a Oh lol, they're unchecked 2021-01-28 16:11:26 +02:00
Tristan B. Kildaire a14d67e0fd Upgrade tristanable 2021-01-28 16:08:24 +02:00
Tristan B. Kildaire e0bd021db1 Fok idk 2021-01-28 15:57:34 +02:00
Tristan B. Kildaire f2120f5fd4 Call `findUser` on direct message notification received 2021-01-28 15:32:03 +02:00
Tristan B. Kildaire ddee77a5b7 Corrected array-base offset 2021-01-28 15:29:04 +02:00
Tristan B. Kildaire 75ac2e16d4 WIP: Direct messages 2021-01-28 15:21:08 +02:00
Tristan B. Kildaire 5bac2157f8 User area now populated with copied-over code from Channel (similiar)
Set message type (isUser=1/true) for sending of messages via enter and send button
2021-01-28 14:26:00 +02:00
Tristan B. Kildaire 302603a6f6 Removed debug 2021-01-28 14:18:41 +02:00
Tristan B. Kildaire 40342772c2 Fixed bug 2021-01-28 14:17:21 +02:00
Tristan B. Kildaire 13d5176a89 No class cast exception, the cast went ahead, had UB that caused a segfault somewhere 2021-01-28 13:56:39 +02:00
Tristan B. Kildaire e6ef053f13 Added a new debugs 2021-01-28 13:55:10 +02:00
Tristan B. Kildaire 602d23e067 MessageArea is responsible for box 2021-01-28 13:40:49 +02:00
Tristan B. Kildaire 37c1afeaaa Added handler 2021-01-28 13:38:10 +02:00
Tristan B. Kildaire 21f60747a6 Use the delegate as intended 2021-01-28 13:35:22 +02:00
Tristan B. Kildaire 4c687b06eb It's a delegate, we have access to `this`, use it 2021-01-28 13:34:16 +02:00
Tristan B. Kildaire e75aee2221 Added direct message button to UserNode 2021-01-28 13:28:56 +02:00
Tristan B. Kildaire 4ff60a02c9 Remove dunused fields 2021-01-28 13:03:31 +02:00
Tristan B. Kildaire a3d70929e5 Renamed `chans` -> `areas`
Renamed `focusedChan` -> `focusedArea`
2021-01-28 13:00:02 +02:00
Tristan B. Kildaire 029cd5a3ee Only loop through Channel objects 2021-01-28 12:57:58 +02:00
Tristan B. Kildaire be543d33fd Missing imports 2021-01-28 11:44:00 +02:00
Tristan B. Kildaire a9b3617b0d Added stub for User area 2021-01-28 11:43:24 +02:00
Tristan B. Kildaire 31611d6f94 Restructure and inherit 2021-01-28 11:41:19 +02:00
Tristan B. Kildaire d4912089b1 WIP: Message areas 2021-01-28 11:33:11 +02:00
Tristan B. Kildaire 638b1bfa9b Comment change 2021-01-28 11:30:56 +02:00
Tristan B. Kildaire 58951da6b0 Now show property values too 2021-01-28 11:30:43 +02:00
Tristan B. Kildaire 1420e8e86f Use gogga for some debug messages 2021-01-28 11:08:18 +02:00
Tristan B. Kildaire 27c42711e0 Updated dub.json 2021-01-27 22:43:37 +02:00
Tristan B. Kildaire f5791f2eae Changed message shown to be "prescence" instead of "status"
ALso show an error on setting sttaus when not connected to any server
2021-01-27 22:39:33 +02:00
Tristan B. Kildaire 97295cf042 Fixed error message shown when you attempt to set your status and are not connected to any server 2021-01-27 22:37:49 +02:00
Tristan B. Kildaire ce9a675da0 Don't crash when you select "Channel list" when you have no open sessions 2021-01-27 22:37:20 +02:00
Tristan B. Kildaire 62895ccaee Implemented custom channel join (useful for when you want to create a new channel)
It will show up in the channels list window
2021-01-27 22:09:57 +02:00
Tristan B. Kildaire ecd23539ab Prototyping: Channel join for uncreated channels 2021-01-27 21:51:26 +02:00
9 changed files with 606 additions and 77 deletions

View File

@ -4,8 +4,9 @@
],
"copyright": "Copyright © 2020, Tristan B. Kildaire",
"dependencies": {
"gtk-d": "~>3.9.0",
"libdnet": "~>0.1.17"
"gogga": "0.0.2",
"gtk-d": "3.9.0",
"libdnet": "0.2.3"
},
"description": "GTK graphical DNET client",
"license": "GPL v3",

View File

@ -2,8 +2,9 @@
"fileVersion": 1,
"versions": {
"bformat": "1.0.8",
"gogga": "0.0.2",
"gtk-d": "3.9.0",
"libdnet": "0.1.17",
"libdnet": "0.2.3",
"tristanable": "0.1.1"
}
}

View File

@ -5,12 +5,14 @@ import gui;
import gdk.Threads : te = threadsEnter, tl = threadsLeave;
import gtk.Box;
import std.stdio;
import libdnet.dclient;
import libdnet.client;
import std.socket;
import gtk.ListBox;
import gtk.Label;
import Channel;
import areas.Channel;
import areas.MessageArea;
import areas.User;
import std.string;
import core.sync.mutex;
@ -19,13 +21,15 @@ import gtk.Notebook;
import std.conv;
import gogga;
public final class Connection : Thread
{
private GUI gui;
private Box box;
private ListBox channels;
private ListBox users;
private ListBox textArea;
private DClient client;
private Address address;
@ -41,9 +45,9 @@ public final class Connection : Thread
* All joined Channel-s in this Connection
*/
private Notebook notebookSwitcher;
private Channel[] chans; /*TODO: Technically locking by GTK would make this not needed */
private MessageArea[] areas; /*TODO: Technically locking by GTK would make this not needed */
private Mutex chansLock;
private Channel focusedChan;
private MessageArea focusedArea;
// public void setPrescence(string pres)
@ -122,7 +126,8 @@ public final class Connection : Thread
{
/* Receive a notification */
byte[] notificationData = client.awaitNotification();
writeln(notificationData);
gprintln("A new notification has arrived");
gprintln("Notification data: "~to!(string)(notificationData));
te();
// import std.conv;
@ -151,45 +156,100 @@ public final class Connection : Thread
}
}
/**
* Processes an incoming notification
* accordingly
*/
private void process(byte[] data)
{
/* TODO: Implement me */
/* TODO: Check notification type */
/* Get the notification type */
ubyte notificationType = data[0];
gprintln("NotificationType: "~to!(string)(notificationType));
/* For normal message (to channel or user) */
if(notificationType == 0)
{
/* TODO: Decode using tristanable */
writeln("new message");
writeln(data);
/* TODO: Handle private messages */
/* Decode is a test for assuming channel message received */
data = data[1..data.length];
gprintln("Channel/User Notification: "~to!(string)(data));
/* Decode the [usernameLength, username] */
ubyte usernameLength = data[1];
writeln(usernameLength);
string username = cast(string)data[2..2+usernameLength];
writeln(username);
/* Decode the [channelLength, channel] */
ubyte channelLength = data[2+usernameLength];
writeln(channelLength);
string channel = cast(string)data[2+usernameLength+1..2+usernameLength+1+channelLength];
writeln(channel);
/* If this is a new message channel notification */
if(data[0] == 0)
{
gprintln("New channel message received", DebugType.WARNING);
findChannel(channel).receiveMessage(username, cast(string)data[2+usernameLength+1+channelLength..data.length]);
/* Decode the [usernameLength, username] */
ubyte usernameLength = data[1];
gprintln("ChannelMessage: (Username length): "~to!(string)(usernameLength));
string username = cast(string)data[2..2+usernameLength];
gprintln("ChannelMessage: (Username): "~username);
writeln("hdsfhdk");
/* Decode the [channelLength, channel] */
ubyte channelLength = data[2+usernameLength];
gprintln("ChannelMessage: (Channel length): "~to!(string)(channelLength));
string channel = cast(string)data[2+usernameLength+1..2+usernameLength+1+channelLength];
gprintln("ChannelMessage: (Channel): "~channel);
findChannel(channel).receiveMessage(username, cast(string)data[2+usernameLength+1+channelLength..data.length]);
}
/* If this is a new direct message notification */
else if(data[0] == 1)
{
gprintln("New direct message received", DebugType.WARNING);
/* Decode the [usernameLength, username] (username here is recipient's) */
ubyte recipientLength = data[1];
gprintln("DirectMessage: (Recipient length): "~to!(string)(recipientLength));
string recipient = cast(string)data[2..2+recipientLength];
gprintln("DirectMessage: (Recipient): "~recipient);
/* Decode the [usernameLength, username] (username here is sender's) */
ubyte sendersLength = data[2+recipientLength];
gprintln("DirectMessage: (Sender length): "~to!(string)(sendersLength));
string sender = cast(string)data[2+recipientLength+1..2+recipientLength+1+sendersLength];
gprintln("DirectMessage: (Sender): "~sender);
/* The message is the remainder */
string message = cast(string)data[2+recipientLength+1+sendersLength..data.length];
gprintln("DirectMessage: (Message): "~message);
/**
* TODO: DIfferes from channels, channels we never get delivered those we have no tab for as we haven't joined them
* and because server side knows we haven't joined iot we don't receive the notifivcaiton, eher however, there is no
* user tab possibly yet, so we will need to add it our selves */
User userArea = findUser(sender);
if(userArea)
{
userArea.receiveMessage(sender, message);
}
else
{
/* Add a new UserArea which will generate a new tab for us */
addDirectMessage_unsafe(sender);
/* The above statement adds an entry for us, now let's find the added UserArea */
userArea = findUser(sender);
/* Now let's add the direct message */
userArea.receiveMessage(sender, message);
}
}
else
{
/* TODO: Handle this */
gprintln("FOk");
}
}
/* Channel notification (ntype=1) */
else if(notificationType == 1)
@ -240,6 +300,124 @@ public final class Connection : Thread
}
private void addUserDM(User newUser)
{
/* TODO: However this we need to mutex for the areas as we could recieve a new message by watcher which adds for us */
chansLock.lock();
areas ~= newUser;
chansLock.unlock();
}
/**
* Opens a new tab for a new direct message
*
* (To be called by a handler, which auto-mutexes)
*
* 1. Will add a new area
* 2. Will add a new tab to the notebook switcher
* 3. Will switch the current tab to said tab
*/
public void addDirectMessage_unsafe(string username)
{
/* TODO: Get box over here etc. */
gprintln("Henlo begi");
/* Check if we have joined this user already */
User foundUser = findUser(username);
gprintln("Henlo");
/* If we have joined this user before */
if(foundUser)
{
/* TODO: Switch to */
writeln("nope time: "~username);
}
/* If we haven't joined this user before */
else
{
/* Create the new User area */
User newUser = new User(this, username);
/* Add the user */
addUserDM(newUser);
/* Set as the `foundChannel` */
foundUser = newUser;
/* Get the Widgets container for this channel and add a tab for it */
notebookSwitcher.add(newUser.getBox());
notebookSwitcher.setTabReorderable(newUser.getBox(), true);
notebookSwitcher.setTabLabelText(newUser.getBox(), newUser.getUsername());
writeln("hdsjghjsd");
writeln("first time: "~username);
// /* Get the user's list */
// newChannel.populateUsersList();
}
/* Render recursively all children of the container and then the container itself */
box.showAll();
}
/**
* Attempts to find the User object you are looking for
*/
public User findUser(string username)
{
User result;
chansLock.lock();
/**
* Loop through each MessageArea and only inspect those
* whose type is `Channel`
*/
foreach(MessageArea area; areas)
{
/* Make sure the object is of type `Channel` */
if(typeid(area) == typeid(User))
{
/* Down-cast */
User user = cast(User)area;
/* Find the matching channel */
if(cmp(user.getUsername(), username) == 0)
{
result = user;
break;
}
}
}
import std.stdio;
writeln("\""~username~"\"");
chansLock.unlock();
return result;
}
public void joinChannel(string channelName)
{
/* Check if we have joined this channel already */
@ -316,18 +494,34 @@ public final class Connection : Thread
}
}
/**
* Attempts to find the Channel object you are looking for
*/
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; areas)
{
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;
}
}
}
@ -354,7 +548,7 @@ public final class Connection : Thread
{
/* Add the channel to the `chans` tracking list */
chansLock.lock();
chans ~= newChannel;
areas ~= newChannel;
chansLock.unlock();
/* Add the channel to the channels list (sidebar) */

View File

@ -32,20 +32,35 @@ public final class ProfileWindow
/* Create a Box for contents */
Box profileBox = new Box(GtkOrientation.VERTICAL, 1);
/* Create a Image for the profile picture */
Image profileImage = new Image("/home/deavmi/Downloads/logo.png");
profileBox.add(profileImage);
// profileImage.
/* Create the username label */
Label usernameTitle = new Label("");
usernameTitle.setMarkup("<span size=\"20000\">"~username~"</span>");
profileBox.add(usernameTitle);
Image profileImage = new Image("/home/deavmi/Downloads/5207740.jpg");
//profileWindow.add(profileImage);
/* Display all props (keys) */
string[] props = connection.getClient().getProperties(username);
profileBox.add(new Label(to!(string)(props)));
/* Display all props (values) */
string[] propValues;
foreach(string property; props)
{
propValues ~= connection.getClient().getProperty(username, property);
}
profileBox.add(new Label(to!(string)(propValues)));
profileWindow.add(profileBox);
profileWindow.showAll();
// profileWindow.unmaximize();
// profileWindow.setAttachedTo()
}
}

View File

@ -1,7 +1,7 @@
module UserNode;
import Connection;
import libdnet.dclient;
import libdnet.client;
import gtk.Box;
import gtk.Button;
import gtk.Image;
@ -26,36 +26,19 @@ public final class UserNode
initBox();
}
private final class UserButton : Button
private void userButtonClick(Button)
{
private string username;
this(string username)
{
this.username = username;
}
public string getUsername()
{
return username;
}
}
private void userButtonClick(Button e)
{
/* The Button will only ever be a UserButton */
UserButton button = cast(UserButton)e;
/* Create a new ProfileWindow */
ProfileWindow profileWindow = new ProfileWindow(connection, button.getUsername());
ProfileWindow profileWindow = new ProfileWindow(connection, username);
}
private void initBox()
{
/* Create a new Box */
box = new Box(GtkOrientation.HORIZONTAL, 10);
/* Layout [Button (Prescence Icon)] - Label <username> */
UserButton userButton = new UserButton(username);
/* Layout [Button (Prescence Icon)] - Label <username> - [Button (Reply Icon)]*/
Button userButton = new Button();
Image userButtonImg = new Image("user-available", GtkIconSize.BUTTON);
userButton.setImage(userButtonImg);
@ -76,8 +59,30 @@ public final class UserNode
/* Add both components */
box.add(userButton);
box.add(userLabel);
/* Add the direct message button */
Button messageButton = new Button();
Image messageButtonImg = new Image("mail-forward", GtkIconSize.BUTTON);
messageButton.setImage(messageButtonImg);
/* Set the handler for on click */
messageButton.addOnClicked(&newDirectMessage);
box.add(messageButton);
}
/**
* This is the handler for when the "direct message" button is clicked
*
* It will call `addDirectMessage_unsafe` with the username specified
*/
private void newDirectMessage(Button)
{
connection.addDirectMessage_unsafe(username);
}
/**
* Event handler to be run when you hover over a user's
* username in the Users sidebar list which will show

View File

@ -7,11 +7,13 @@
* along with the input box state
*/
module areas.Channel;
import gtk.Box;
import gtk.ListBox;
import gtk.Label;
import gtk.TextView;
import libdnet.dclient;
import libdnet.client;
import gtk.Label;
import std.string;
import gtk.Button;
@ -26,7 +28,10 @@ import pango.PgAttributeList;
import pango.PgAttribute;
import Connection;
public final class Channel
import gogga;
import areas.MessageArea;
public final class Channel : MessageArea
{
private DClient client;
private Connection connection;
@ -36,11 +41,6 @@ public final class Channel
*/
private string channelName;
/**
* The container for this Channel
*/
private Box box;
/**
* UI components
*
@ -135,6 +135,7 @@ public final class Channel
import gtk.FileChooserDialog; /* TODO: Set parent */
FileChooserDialog fileChooser = new FileChooserDialog("Send file to "~channelName, null, FileChooserAction.OPEN);
fileChooser.run();
gprintln("Selected file: "~fileChooser.getFilename());
}
import gtk.EditableIF;
@ -180,11 +181,6 @@ public final class Channel
box.showAll();
}
public Box getBox()
{
return box;
}
public string getName()
{
return channelName;

View File

@ -0,0 +1,25 @@
/**
* MessageArea
*
* Represents the binding of a text entry, send button, user list (sometimes)
* and message log - basically the place where you message a channel or someone
*
* The sub-classes are "Direct Message" and "Channel"
*/
module areas.MessageArea;
import gtk.Box;
public class MessageArea
{
/* TODO: Implement me */
/* The area's Box (where everything is contained) */
protected Box box;
public Box getBox()
{
return box;
}
}

215
source/areas/User.d Normal file
View File

@ -0,0 +1,215 @@
module areas.User;
import areas.MessageArea;
import gtk.Box;
import gtk.ListBox;
import gtk.Label;
import gtk.TextView;
import libdnet.client;
import gtk.Label;
import std.string;
import gtk.Button;
import gtk.Tooltip;
import gtk.Widget;
import gtk.ScrolledWindow;
import gtk.Button;
import gtk.Entry;
import UserNode;
import pango.PgAttributeList;
import pango.PgAttribute;
import Connection;
import gogga;
public final class User : MessageArea
{
private DClient client;
private Connection connection;
/**
* Username
*/
private string username;
/**
* UI components
*
*/
// private ListBox users;
private ListBox textArea;
private Entry textInput;
/* TODO: No mutexes should be needed (same precaution) as the GTK lock provides safety */
// private string[] usersString;
this(Connection connection, string username)
{
this.client = connection.getClient();
this.connection = connection;
this.username = username;
initializeBox();
}
public string getUsername()
{
return username;
}
private void initializeBox()
{
box = new Box(GtkOrientation.HORIZONTAL, 1);
// box.add(new Label("poes"));
/* The text box */
Box textBox = new Box(GtkOrientation.VERTICAL, 1);
/* Channel title */
Label channelTitleLabel = new Label(username);
channelTitleLabel.setMarkup("<span size=\"large\"><b>"~username~"</b></span>");
textBox.add(channelTitleLabel);
/* The messages box */
textArea = new ListBox();
ScrolledWindow scrollTextChats = new ScrolledWindow(textArea);
textBox.add(scrollTextChats);
/* The Box for the whole |attach button| text field| send button| */
Box textInputBox = new Box(GtkOrientation.HORIZONTAL, 1);
import gtk.Image;
/* The attachment button */
Button attachFileButton = new Button("Upload");
Image attachFileButtonIcon = new Image("user-available", GtkIconSize.BUTTON); /* TODO: Fix icon now showing */
attachFileButton.setImage(attachFileButtonIcon);
attachFileButton.addOnClicked(&uploadFileDialog);
textInputBox.add(attachFileButton);
/* The text input */
textInput = new Entry();
textInput.addOnActivate(&sendMessageEnter);
textInput.addOnChanged(&textChangd);
textInputBox.packStart(textInput,1,1,0);
/* The send button */
Button sendButton = new Button("Send");
sendButton.addOnClicked(&sendMessageBtn);
textInputBox.add(sendButton);
textBox.add(textInputBox);
box.add(textBox);
// box.packEnd(userBox,0,0,0);
textBox.setChildPacking(scrollTextChats, true, true, 0, GtkPackType.START);
box.setChildPacking(textBox, true, true, 0, GtkPackType.START);
}
import gtk.EditableIF;
private void textChangd(EditableIF)
{
/* If the text box just became empty stop ssending typing notifications */
/* Send typing stats */
// client.sendIsTyping(channelName, true);
/* TODO: Client implement wiht different tag? */
}
private void sendMessageEnter(Entry)
{
/* Retrieve the message */
string message = textInput.getBuffer().getText();
/* TODO: Add the message to our log (as it won't be delivered to us) */
sendMessage(message);
/* Send the message */
client.sendMessage(1, username, message);
/* Clear the text box */
textInput.getBuffer().setText("",0);
box.showAll();
}
private void sendMessageBtn(Button)
{
/* Retrieve the message */
string message = textInput.getBuffer().getText();
/* TODO: Add the message to our log (as it won't be delivered to us) */
sendMessage(message);
/* Send the message */
client.sendMessage(1, username, message);
/* Clear the text box */
textInput.getBuffer().setText("",0);
box.showAll();
}
public void sendMessage(string message)
{
/* TOOD: Pass in connection perhaps */
string username = "Yourself";
/* Create the MessageBox */
Box messageBox = new Box(GtkOrientation.VERTICAL, 1);
/* Create and add the username */
Label usernameLabel = new Label("");
usernameLabel.setMarkup("<b>"~username~"</b>");
usernameLabel.setHalign(GtkAlign.END);
messageBox.add(usernameLabel);
/* Create and add the message */
Label messageLabel = new Label(message);
messageLabel.setHalign(GtkAlign.END);
messageLabel.setSelectable(true);
messageBox.add(messageLabel);
/* Add the message to the log */
textArea.add(messageBox);
}
public void receiveMessage(string username, string message)
{
/* Create the MessageBox */
Box messageBox = new Box(GtkOrientation.VERTICAL, 1);
/* Create and add the username */
Label usernameLabel = new Label("");
usernameLabel.setMarkup("<b>"~username~"</b>");
usernameLabel.setHalign(GtkAlign.START);
messageBox.add(usernameLabel);
/* Create and add the message */
Label messageLabel = new Label(message);
messageLabel.setHalign(GtkAlign.START);
messageLabel.setSelectable(true);
messageBox.add(messageLabel);
// import gtk.Image;
// Image d = new Image("/home/deavmi/Downloads/5207740.jpg");
// messageBox.add(d);
/* Add the message to the log */
textArea.add(messageBox);
}
private void uploadFileDialog(Button e)
{
import gtk.FileChooserDialog; /* TODO: Set parent */
FileChooserDialog fileChooser = new FileChooserDialog("Send file to "~username, null, FileChooserAction.OPEN);
fileChooser.run();
gprintln("Selected file: "~fileChooser.getFilename());
}
}

View File

@ -21,7 +21,7 @@ import gtk.SearchEntry;
import gtk.Image;
import Connection;
import Channel;
import areas.Channel;
import std.socket;
import std.conv;
@ -253,6 +253,16 @@ public class GUI : Thread
channelListButton.addOnClicked(&listChannels);
toolbar.add(channelListButton);
/* TODO: Join channel button */
ToolButton joinChannelButton = new ToolButton("");
joinChannelButton.setIconName("document-new");
joinChannelButton.setTooltipText("Join channel");
toolbar.add(joinChannelButton);
/* TODO: Leave channel button */
@ -278,6 +288,18 @@ public class GUI : Thread
import std.string;
private void setStatusMessage(Entry f)
{
/* If there are no connections */
if(!connections.length)
{
import gtk.MessageDialog;
MessageDialog errorDialog = new MessageDialog(mainWindow, GtkDialogFlags.MODAL, GtkMessageType.ERROR, GtkButtonsType.CLOSE, false, "Cannot set status\n\nYou are not connected to a server");
errorDialog.setIconName("user-available");
// errorDialog.set
errorDialog.run();
return;
}
/* Get the current connection */
Connection currentConnection = connections[notebook.getCurrentPage()];
@ -398,6 +420,34 @@ public class GUI : Thread
}
private class JoinButtonCustom : Button
{
private Entry channelInputBox;
this(Entry channelInputBox)
{
/* Set the button's text to "Join" */
super("Join");
/* Set the handler for the button */
addOnClicked(&handler);
this.channelInputBox = channelInputBox;
}
private void handler(Button)
{
/* Get the current connection */
Connection currentConnection = connections[notebook.getCurrentPage()];
/* Get the name of the channel selected */
string channelSelected = channelInputBox.getText();
/* Join the channel on this connection */
currentConnection.joinChannel(channelSelected);
}
}
/**
* List channels
*
@ -414,6 +464,29 @@ public class GUI : Thread
ListBox channelsList = new ListBox();
win.add(new ScrolledWindow(channelsList));
/* TODO: Temporary, REMOVE AFTWR TESTING (ADDED ON 27th of JAN 2021) */
Box box = new Box(GtkOrientation.HORIZONTAL, 1);
Entry customChannelEntry = new Entry();
box.packStart(customChannelEntry, 1, 1, 1);
box.add(new JoinButtonCustom(customChannelEntry));
channelsList.add(box);
/* If there are no available connections */
if(!connections.length)
{
import gtk.MessageDialog;
MessageDialog errorDialog = new MessageDialog(mainWindow, GtkDialogFlags.MODAL, GtkMessageType.ERROR, GtkButtonsType.CLOSE, false, "Cannot list channels\n\nYou are not connected to a server");
errorDialog.setIconName("user-available");
// errorDialog.set
errorDialog.run();
return;
}
/* Get the current connection */
Connection currentConnection = connections[notebook.getCurrentPage()];
@ -455,6 +528,10 @@ public class GUI : Thread
win.showAll();
}
/**
* Run when you select the 'Join' button next tio an already existing
* channel in the channels list
*/
private void selectChannel(Button s)
{
/* Get the current connection */
@ -489,7 +566,7 @@ public class GUI : Thread
else
{
import gtk.MessageDialog;
MessageDialog errorDialog = new MessageDialog(mainWindow, GtkDialogFlags.MODAL, GtkMessageType.ERROR, GtkButtonsType.CLOSE, false, "Cannot list channels\n\nYou are not connected to a server");
MessageDialog errorDialog = new MessageDialog(mainWindow, GtkDialogFlags.MODAL, GtkMessageType.ERROR, GtkButtonsType.CLOSE, false, "Cannot set prescence\n\nYou are not connected to a server");
errorDialog.setIconName("user-available");
// errorDialog.set
errorDialog.run();