#include "client.h"
Go to the source code of this file.
Functions | |
void | end_program (GtkWidget *widget1, gpointer data) |
This function calls when we close the window. | |
void | onExit (GtkWidget *window, gpointer data) |
This function calls when we close the window. | |
void | add_widget_with_label (GtkContainer *box, gchar *caption, GtkWidget *widget) |
This function adds the widget to the Box with corresponding label passed. | |
void | close_properly () |
This function is called when we press Ctrl+C key or on any error condition. | |
void | msg_func (GtkWidget *widget1, gpointer data) |
This function is called when we enter some message in the GTK entry. | |
void | connect_server (GtkWidget *widget1, gpointer data) |
This function is called when "connect" button is pressed.It connects to the server with the information provided by the user(like server IP, client Nick, Port). | |
void * | start_client (void *arg) |
This function starts the client side of Messenger after succesfully connecting to the server. | |
int | main (int argc, char *argv[]) |
This is where program execution starts. |
The client can also see the list of all other connected clients..
Definition in file client.c.
void add_widget_with_label | ( | GtkContainer * | box, | |
gchar * | caption, | |||
GtkWidget * | widget | |||
) |
void close_properly | ( | ) |
This function is called when we press Ctrl+C key or on any error condition.
It does proper closing of file descriptors.
Definition at line 50 of file client.c.
References socket_file_descriptor.
Referenced by msg_func(), and start_client().
void connect_server | ( | GtkWidget * | widget1, | |
gpointer | data | |||
) |
This function is called when "connect" button is pressed.It connects to the server with the information provided by the user(like server IP, client Nick, Port).
If the connection is successful it displays the chat Room, else it displays appriopriate dialog message.
widget1 | "connect" button | |
data | pointer |
Definition at line 82 of file client.c.
References BUFFER, entry_ipaddress, entry_nick, entry_port, client_data::fd, client_data::ip, ip, list_store, client_data::nick, nick, socket_file_descriptor, and t_iter.
Referenced by main().
void end_program | ( | GtkWidget * | widget1, | |
gpointer | data | |||
) |
This function calls when we close the window.
. which quits the window and exits the program. It shutdowns the socket and closes all the widgets.
widget1 | Widget to be closed | |
data | pointer |
Definition at line 16 of file client.c.
References socket_file_descriptor.
Referenced by main().
int main | ( | int | argc, | |
char * | argv[] | |||
) |
This is where program execution starts.
All arguments are passed to gtk for processing, which removes any arguments relevant to it. All other arguments are ignored. This function first gets a window for user to enter Server IP Address, port and Nick of client. If it can connect succesfully then it displays the chat room, else it displays the dialog box with approriate message.
argc | Number of arguments passed. | |
argv | NULL terminated array of command line arguments. |
Definition at line 255 of file client.c.
References add_widget_with_label(), buffer, connect_server(), end_program(), entry, entry_ipaddress, entry_nick, entry_port, iter, list_store, msg_func(), onExit(), and start_client().
void msg_func | ( | GtkWidget * | widget1, | |
gpointer | data | |||
) |
This function is called when we enter some message in the GTK entry.
It sends the message to the server.It prints appropriate error message and closes all connections if sending fails..
widget1 | GTK entry | |
data | pointer |
Definition at line 62 of file client.c.
References close_properly(), entry, msg, and socket_file_descriptor.
Referenced by main().
void onExit | ( | GtkWidget * | window, | |
gpointer | data | |||
) |
void* start_client | ( | void * | arg | ) |
This function starts the client side of Messenger after succesfully connecting to the server.
It can send messages to and recieve messages from all other connected clients and can also see the list of connected clients
arg | paramters |
Definition at line 167 of file client.c.
References buffer, BUFFER, close_properly(), transmit_unit::ip, ip, iter, list_store, transmit_unit::msg, transmit_unit::nick, socket_file_descriptor, t_iter, and transmit_unit::time.
Referenced by main().