Yattm - unified GTK instant-messaging client logo
   [Generated for version 0.2-17 - Mon Jan 6 19:01:23 GMT+1 2003]

Home - Main Page - Data Structures - File List - Data Fields - Globals

console_session.c File Reference

#include "intl.h"
#include "console_session.h"
#include <sys/un.h>
#include <stdlib.h>
#include "chat_window.h"
#include "util.h"
#include "status.h"

Include dependency graph for console_session.c:

Include dependency graph

Go to the source code of this file.

Functions

void console_session_close (int *session)
void console_session_get_command (gpointer data, gint source, GdkInputCondition condition)
void console_session_init (gpointer data, gint source, GdkInputCondition condition)


Function Documentation

void console_session_close int *    session [static]
 

Definition at line 9 of file console_session.c.

Referenced by console_session_get_command().

00010 {
00011     gdk_input_remove(*((int*)session));
00012     g_free(session);
00013 }

void console_session_get_command gpointer    data,
gint    source,
GdkInputCondition    condition
 

Definition at line 15 of file console_session.c.

References contact::chatwindow, console_session_close(), _chat_window::contact, eb_chat_window_display_contact(), _chat_window::entry, find_contact_by_nick(), find_suitable_remote_account(), focus_statuswindow(), _chat_window::perfered, and send_message().

Referenced by console_session_init().

00018 {
00019     char * contact_name;
00020     char * message;
00021     struct contact * remote_contact;
00022     short len;
00023     int pos = 0;
00024     int ret;
00025 
00026     if(read(source, &len, sizeof(short))<=0)
00027     {
00028         console_session_close((int*)data);
00029         return;
00030     }
00031     contact_name = alloca(len);
00032     if(read(source, contact_name, len)<=0)
00033     {
00034         console_session_close((int*)data);
00035         return;
00036     }
00037     if(strcmp(contact_name, "focus-yattm")) {
00038         if(read(source, &len, sizeof(short))<=0)
00039         {
00040             console_session_close((int*)data);
00041             return;
00042         }
00043         message = alloca(len);
00044         if(read(source, message, len)<=0)
00045         {
00046             console_session_close((int*)data);
00047             return;
00048         }
00049 
00050         remote_contact = find_contact_by_nick(contact_name);
00051         if(!remote_contact)
00052         {
00053             ret = -1;
00054             write(source, &ret, sizeof(int));
00055             return;
00056         }
00057         eb_chat_window_display_contact(remote_contact);
00058         remote_contact->chatwindow->perfered= 
00059                 find_suitable_remote_account(remote_contact->chatwindow->perfered, 
00060                                             remote_contact->chatwindow->contact);
00061         if(!remote_contact->chatwindow->perfered)
00062         {
00063             ret = -2;
00064             write(source, &ret, sizeof(int));
00065             return;
00066         }
00067 
00068         gtk_editable_insert_text(GTK_EDITABLE(remote_contact->chatwindow->entry),
00069                                  message, strlen(message), &pos);
00070         send_message(NULL, remote_contact->chatwindow);
00071     } else {
00072         focus_statuswindow();
00073     }
00074     
00075     ret = 0;
00076     write(source, &ret, sizeof(int));
00077 
00078 }

void console_session_init gpointer    data,
gint    source,
GdkInputCondition    condition
 

Definition at line 80 of file console_session.c.

References console_session_get_command().

00081 {
00082     struct sockaddr_un remote;
00083     int len;
00084     int sock;
00085     int * listener = g_new0(int, 1);
00086     
00087     sock = accept(source, (struct sockaddr *)&remote, &len);
00088     *listener = gdk_input_add(sock, GDK_INPUT_READ,
00089                     console_session_get_command, 
00090                     (gpointer)listener);
00091 }


Contact: Andy Maloney     [Documentation generated by doxygen]