[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Ayttm-commits] CVS: ayttm/modules/workwizu .cvsignore,NONE,1.1 Makefile
From: |
Colin Leroy <address@hidden> |
Subject: |
[Ayttm-commits] CVS: ayttm/modules/workwizu .cvsignore,NONE,1.1 Makefile.am,NONE,1.1 workwizu.c,NONE,1.1 workwizu.h,NONE,1.1 |
Date: |
Tue, 07 Jan 2003 14:02:36 -0500 |
Update of /cvsroot/ayttm/ayttm/modules/workwizu
In directory subversions:/tmp/cvs-serv7774/modules/workwizu
Added Files:
.cvsignore Makefile.am workwizu.c workwizu.h
Log Message:
add workwizu module
--- NEW FILE: .cvsignore ---
Makefile
Makefile.in
.deps
.libs
workwizu.lo
workwizu.la
workwizu.o
--- NEW FILE: Makefile.am ---
SUBDIRS =
libdir = $(datadir)/yattm/modules
CFLAGS = @CFLAGS@ @GTK_CFLAGS@ -I$(top_srcdir)/src -I.
LIBS = @LIBS@ @GTK_LIBS@
EXTRA_DIST = workwizu.h
lib_LTLIBRARIES = workwizu.la
workwizu_la_SOURCES = workwizu.c
workwizu_la_LDFLAGS = -module
--- NEW FILE: workwizu.c ---
/*
* Yattm
*
* Copyright (C) Colin Leroy <address@hidden>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#define DEBUG 1
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "intl.h"
#include <gtk/gtk.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <sys/types.h>
#include <errno.h>
#ifdef __MINGW32__
#include <winsock2.h>
#include <sys/poll.h>
#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/poll.h>
#endif
#include <sys/stat.h>
#include <fcntl.h>
#include <math.h>
#include <gmp.h>
#if defined( _WIN32 )
typedef unsigned long u_long;
typedef unsigned long ulong;
#endif
#include "info_window.h"
#include "workwizu.h"
#include "gtk_eb_html.h"
#include "contact.h"
#include "service.h"
#include "chat_window.h"
#include "chat_room.h"
#include "util.h"
#include "status.h"
#include "globals.h"
#include "dialog.h"
#include "message_parse.h"
#include "value_pair.h"
#include "plugin_api.h"
#include "smileys.h"
#include "pixmaps/workwizu_online.xpm"
#include "pixmaps/workwizu_away.xpm"
#define WWZ_ONLINE 0
#define WWZ_OFFLINE 1
/*************************************************************************************
* Begin Module Code
************************************************************************************/
static int ref_count = 0;
static tag_info tags[21];
static char *server = "212.37.193.123";
static int port = 32002;
static char *owner = "savoirweb";
static wwz_user *my_user;
GList *wwz_contacts = NULL;
int connstate;
/* Module Exports */
PLUGIN_INFO plugin_info = {
PLUGIN_SERVICE,
"Workwizu Service",
"Workwizu Chat support",
"$Revision: 1.1 $",
"$Date: 2003/01/07 19:02:33 $",
&ref_count,
plugin_init,
plugin_finish
};
struct service SERVICE_INFO = { "Workwizu", -1, FALSE, TRUE, FALSE, TRUE, NULL
};
/* End Module Exports */
int plugin_init()
{
int count;
eb_debug(DBG_MOD, "Workwizu init\n");
ref_count=0;
for(count=0;count<20;count++)
tags[count].fd=-1;
return(0);
}
int plugin_finish()
{
eb_debug(DBG_MOD, "Returning the ref_count: %i\n", ref_count);
return(ref_count);
}
char *sock_read (int sock)
{
char c;
char buf[4096];
char *line = NULL;
int pos = 0;
while(pos < 4095)
{
if(read(sock, &c, 1)<1)
{
printf("What the..?!\n"); //DEBUG
clean_up(sock);
return NULL;
}
if(c=='\r') { continue; }
if(c=='\n') { buf[pos]='\0'; break; }
buf[pos]=c;
pos++;
}
line = strdup(buf);
eb_debug(DBG_MOD,"READ :%s\n",line);
return line;
}
void sock_write (int sock, char *buf)
{
eb_debug(DBG_MOD,"WRITE:%s\n",buf);
write(sock, buf, strlen(buf));
}
gboolean eb_workwizu_query_connected (eb_account *account)
{
return (ref_count > 0 && account->online);
}
unsigned long getHash (char *s)
{
long hash = 0;
unsigned long res = 0;
int i = 0;
for (i=0; i < strlen(s); i++) {
int c = (int)s[i];
int x = strlen(s);
int l = x-(i+1);
int p = pow(31,l);
hash += c*p; /* 31^(strlen(s)-(1+1)) */
}
if (hash < 0) res = -hash;
else res = hash;
return res;
}
char *compute_challenge()
{
char *result_c = NULL;
unsigned long hash;
mpz_t beta;
mpz_t result;
mpz_t challenge;
mpz_init(beta);
mpz_init(result);
mpz_init(challenge);
mpz_set_str(beta, "1201147206560481999739023090913", 10);
mpz_set_str(challenge, my_user->challenge, 10);
hash = getHash(my_user->password);
hash %= 10000;
mpz_pow_ui(result, challenge, hash);
mpz_tdiv_r (result, result, beta);
result_c = mpz_get_str(NULL, 10, result);
return result_c;
}
void workwizu_answer_challenge (int sock)
{
char *buf;
buf = g_strdup_printf("%s%%%s%%0%%0%%0%%%s\n",
my_user->username,
compute_challenge(),
owner);
sock_write(sock, buf);
g_free(buf);
connstate = CONN_WAITING_USERINFO;
}
void parse_user_info (char *info)
{
gchar **tokens;
/* 0 user % 1 challenge_answer % 2 u_id % 3 is_driver % 4 channel_id %
5 owner */
tokens = g_strsplit(info, "%", 6);
my_user->uid = atoi(tokens[2]);
my_user->is_driver = my_user->has_speak = atoi(tokens[3]);
my_user->channel_id = atoi(tokens[4]);
strncpy(my_user->owner,tokens[5], 255);
g_strfreev(tokens);
connstate = CONN_ESTABLISHED;
}
void send_packet (int sock, int tag, int from, int to, char *str)
{
char *buf = g_strdup_printf("%d:%d:%d:%s\n",
tag, from, to,
str);
sock_write(sock, buf);
g_free(buf);
}
void send_my_packet (int sock, int tag, int to, char *str)
{
send_packet (sock, tag, my_user->uid, to, str);
}
static int send_stats(gpointer sockp)
{
char *buf;
int sock = GPOINTER_TO_INT(sockp);
/* true |true |false |true |false |0 |false
driver |speak |micro |pencil |w_act |lastmv |istyping */
buf = g_strdup_printf("%s|%s|false|false|true|0|%s",
my_user->is_driver?"true":"false",
my_user->has_speak?"true":"false",
my_user->is_typing?"true":"false");
send_my_packet(sock, USERSTATE, EXCEPTME, buf);
return 1;
}
static void parse_stats (int from, char *stats)
{
gchar **tokens = g_strsplit(stats,"|",7);
char *sfrom = g_strdup_printf("%d",from);
eb_account *ea = find_account_by_handle(sfrom,
SERVICE_INFO.protocol_id);
wwz_user *user = (wwz_user *)ea->protocol_account_data;
user->is_driver = !strcmp(tokens[0],"true");
user->is_typing = !strcmp(tokens[6],"true");
user->has_speak = !strcmp(tokens[1],"true");
if (!user->has_speak)
if (user->is_typing && do_typing_notify)
eb_update_status(ea, _("typing..."));
}
void get_message (int from, char *data)
{
eb_account *ea;
eb_local_account *ela;
char *sfrom = g_strdup_printf("%d", from);
ela = find_local_account_by_handle(my_user->username,
SERVICE_INFO.protocol_id);
ea = find_account_by_handle(sfrom, SERVICE_INFO.protocol_id);
if (!ea) {
eb_debug(DBG_MOD, "no account found for %s\n",sfrom);
g_free(sfrom);
return;
}
if (!ela) {
eb_debug(DBG_MOD, "no local account found for
%s\n",my_user->username);
g_free(sfrom);
return;
}
eb_parse_incomming_message(ela, ea, &SERVICE_INFO, data);
g_free(sfrom);
}
void new_user (int from, char *data)
{
eb_account *ea;
char *sfrom = g_strdup_printf("%d", from);
ea = find_account_by_handle(sfrom, SERVICE_INFO.protocol_id);
if (!ea) {
ea = eb_workwizu_new_account(sfrom);
if (!find_grouplist_by_name("Workwizu")) {
add_group("Workwizu");
}
add_unknown_with_name(ea, strdup(data));
g_free(sfrom);
move_contact("Workwizu", ea->account_contact);
update_contact_list();
write_contact_list();
}
eb_workwizu_add_user(ea);
buddy_login(ea);
}
void rem_user (int from)
{
char *sfrom = g_strdup_printf("%d", from);
eb_account *ea = find_account_by_handle(sfrom,
SERVICE_INFO.protocol_id);
if (ea)
buddy_logoff(ea);
g_free(sfrom);
}
void parse_packet(char *packet)
{
gchar **tokens;
int tag, from, to;
char *data;
/* 0 tag : 1 from : 2 to : 3 data */
tokens = g_strsplit(packet, ":", 4);
tag = atoi(tokens[0]);
from = atoi(tokens[1]);
to = atoi(tokens[2]);
data = g_strdup(tokens[3]);
g_strfreev(tokens);
eb_debug(DBG_MOD,"tag:%d, to:%d,from:%d,data:%s\n",
tag,to,from,data);
switch(tag) {
case NEWUSER:
new_user(from, data);
free(data);
break;
case REMOVEUSER:
rem_user(from);
break;
case CHAT:
get_message(from, data);
case ALLOWSPEAK:
my_user->has_speak = 1;
case STOPSPEAK:
my_user->has_speak = 0;
case USERSTATE:
break;
default:
break;
}
}
void workwizu_handle_incoming(int sock, int readable, int writable)
{
char *line;
switch(connstate) {
case CONN_CLOSED:
eb_debug(DBG_MOD,"uh? conn is closed\n");
break;
case CONN_WAITING_CHALLENGE:
line = sock_read(sock);
strcpy(my_user->challenge,line);
free(line);
eb_debug(DBG_MOD,"read challenge
%s\n",my_user->challenge);
workwizu_answer_challenge(sock);
break;
case CONN_WAITING_USERINFO:
line = sock_read(sock);
if (line == NULL) {
do_error_dialog(_("Bad authentication"),
_("Workwizu Error"));
return;
}
parse_user_info(line);
if (my_user->is_driver)
send_my_packet (sock,
DRIVERENTEREDINCHATROOM,
EXCEPTME,
my_user->username);
free(line);
my_user->statssender =
gtk_timeout_add (10000,
(GtkFunction)send_stats,
GINT_TO_POINTER(sock));
break;
case CONN_ESTABLISHED:
line = sock_read(sock);
parse_packet(line);
free(line);
break;
default:
eb_debug(DBG_MOD,"unknown connection state ! :(\n");
break;
}
}
void eb_workwizu_incoming(void *data, int source, eb_input_condition condition)
{
/* eb_debug(DBG_MOD,"eb_workwizu_incoming r%d w%d e%d\n",
condition&EB_INPUT_READ,
condition&EB_INPUT_WRITE,
condition&EB_INPUT_EXCEPTION); */
if (!(condition&EB_INPUT_EXCEPTION)) {
workwizu_handle_incoming(source,
condition & EB_INPUT_READ,
condition & EB_INPUT_WRITE);
}
}
void register_sock(int s, int reading, int writing)
{
int a;
eb_debug(DBG_MOD, "Registering sock %i\n", s);
for(a=0; a<20; a++)
{
if(tags[a].fd==-1) {
tags[a].fd=s;
tags[a].tag_r=tags[a].tag_w=-1;
if(reading)
{
tags[a].tag_r=eb_input_add(s, EB_INPUT_READ, eb_workwizu_incoming,
NULL);
}
if(writing)
{
tags[a].tag_w=eb_input_add(s, EB_INPUT_WRITE, eb_workwizu_incoming,
NULL);
}
eb_debug(DBG_MOD, "Successful %i\n", s);
return;
}
}
}
void unregister_sock(int s)
{
int a;
eb_debug(DBG_MOD, "Unregistering sock %i\n", s);
for(a=0; a<20; a++)
{
if(tags[a].fd==s) {
if(tags[a].tag_r!=-1) { eb_input_remove(tags[a].tag_r); }
if(tags[a].tag_w!=-1) { eb_input_remove(tags[a].tag_w); }
tags[a].fd=-1;
tags[a].tag_r=tags[a].tag_w=0;
eb_debug(DBG_MOD, "Successful %i\n", s);
return;
}
}
}
static int connect_socket(char * hostname, int port)
{
struct sockaddr_in sa;
struct hostent *hp;
int s;
eb_debug(DBG_MOD,"Connecting to %s...\n", hostname);
if ((hp= gethostbyname(hostname)) == NULL) { /* do we know the host's */
#ifndef __MINGW32__
errno= ECONNREFUSED; /* address? */
#endif
return(-1); /* no */
}
memset(&sa,0,sizeof(sa));
memcpy((char *)&sa.sin_addr,hp->h_addr,hp->h_length); /* set address */
sa.sin_family= hp->h_addrtype;
sa.sin_port= htons((u_short)port);
if ((s= socket(hp->h_addrtype,SOCK_STREAM,0)) < 0) /* get socket */
return(-1);
#ifdef O_NONBLOCK
fcntl(s, F_SETFL, O_NONBLOCK);
#endif
if (connect(s,(struct sockaddr *)&sa,sizeof sa) < 0) /* connect */
{
#ifndef __MINGW32__
if(errno==EINPROGRESS || errno==EWOULDBLOCK)
{
struct pollfd pfd;
pfd.fd=s;
pfd.revents=0;
pfd.events=POLLOUT;
fcntl(s, F_SETFL, 0);
if(poll(&pfd, 1, 7500)==1)
{
if(pfd.revents&POLLERR||pfd.revents&POLLHUP||pfd.revents&POLLNVAL)
{
eb_debug(DBG_MOD, "Error!\n");
close(s);
return -1;
} else {
eb_debug(DBG_MOD, "Connect went fine\n");
sleep(2);
return s;
}
}
} else {
fcntl(s, F_SETFL, 0);
#endif
close(s);
return -1;
#ifndef __MINGW32__
}
#endif
}
sleep(1); // necessary?
return(s);
}
void eb_workwizu_login (eb_local_account *account)
{
wwz_account_data *wad = (wwz_account_data *)
account->protocol_local_account_data;
if (account->connected)
return;
my_user = g_new0(wwz_user, 1);
strcpy(my_user->username, account->handle);
strcpy(my_user->password, wad->password);
eb_debug(DBG_MOD, "Logging in\n");
wad->sock = connect_socket(server, port);
if (wad->sock == -1) {
eb_debug(DBG_MOD, "wad->sock=-1 !\n");
return;
}
ref_count++;
register_sock(wad->sock, 1, 0);
if(account->status_menu)
{
/* Make sure set_current_state doesn't call us back */
account->connected=-1;
eb_set_active_menu_status(account->status_menu, WWZ_ONLINE);
}
account->connected=1;
connstate = CONN_WAITING_CHALLENGE;
}
static void clean_up (int sock)
{
if (sock != -1) {
if (my_user->statssender != -1)
gtk_timeout_remove(my_user->statssender);
my_user->statssender = -1;
close(sock);
unregister_sock(sock);
connstate = CONN_CLOSED;
}
}
void eb_workwizu_logout (eb_local_account *account)
{
GList *l;
wwz_account_data *wad = (wwz_account_data *)
account->protocol_local_account_data;
if (!account->connected)
return;
eb_debug(DBG_MOD, "Logging out\n");
for (l = wwz_contacts; l; l = l->next) {
eb_account * ea = (eb_account *)find_account_by_handle((char
*)l->data, SERVICE_INFO.protocol_id);
buddy_logoff(ea);
buddy_update_status(ea);
}
account->connected = 0;
eb_set_active_menu_status(account->status_menu, WWZ_OFFLINE);
clean_up(wad->sock);
if(ref_count >0)
ref_count--;
}
char *translate_to_br(char *in)
{
char **tokens = g_strsplit(in, "\r\n", 0);
char *out = NULL;
int i = 0;
while (tokens[i]) {
char *tok = NULL;
tok = g_strdup(tokens[i]);
if (out == NULL)
out = g_strdup(tok);
else {
char *old = g_strdup(out);
out = g_strconcat(old, "<br>", tok, NULL);
g_free(old);
}
g_free(tok);
i++;
}
g_strfreev(tokens);
printf("out=%s\n",out);
return out;
}
void eb_workwizu_send_im (eb_local_account *account_from,
eb_account *account_to,
gchar *message)
{
wwz_account_data *wad = (wwz_account_data
*)account_from->protocol_local_account_data;
wwz_user *user = (wwz_user *)account_to->protocol_account_data;
char *send = translate_to_br(message);
send_my_packet(wad->sock, CHAT, user->uid, send);
if (!my_user->has_speak)
do_error_dialog(_("You aren't allowed to speak.\nThis message
has probably not arrived."),
_("Workwizu Error"));
}
int eb_workwizu_send_typing (eb_local_account *account_from,
eb_account *account_to)
{
wwz_account_data *wad = (wwz_account_data
*)account_from->protocol_local_account_data;
my_user->is_typing = 1;
send_stats(GINT_TO_POINTER(wad->sock));
my_user->is_typing = 0;
return 4;
}
eb_local_account *eb_workwizu_read_local_config (GList *values)
{
eb_local_account *ela;
wwz_account_data *wad = g_new0(wwz_account_data,1);
if (values == NULL)
return NULL;
ela = g_new0 (eb_local_account, 1);
ela->handle = value_pair_get_value(values, "SCREEN_NAME");
wad->password = value_pair_get_value(values, "PASSWORD");
ela->protocol_local_account_data = wad;
strncpy(ela->alias, ela->handle, 255);
ela->service_id = SERVICE_INFO.protocol_id;
ela->connected = FALSE;
return ela;
}
GList *eb_workwizu_write_local_config (eb_local_account *account)
{
value_pair *pair = NULL;
GList *vals = NULL;
wwz_account_data *wad = (wwz_account_data
*)account->protocol_local_account_data;
pair = g_new0(value_pair, 1);
strcpy(pair->key, "SCREEN_NAME");
strncpy(pair->value, account->handle, 1024);
vals = g_list_append(vals, pair);
pair = g_new0(value_pair, 1);
strcpy(pair->key, "PASSWORD");
strncpy(pair->value, wad->password, 1024);
vals = g_list_append(vals, pair);
return vals;
}
eb_account *eb_workwizu_read_config (GList *config, struct contact *contact)
{
eb_account *ea = g_new0(eb_account, 1);
char *tmp;
wwz_user *user = g_new0(wwz_user,1);
ea->online = FALSE;
tmp = value_pair_get_value(config, "NAME");
strncpy(ea->handle, tmp, 255);
g_free(tmp);
ea->service_id = SERVICE_INFO.protocol_id;
ea->protocol_account_data = NULL;
ea->account_contact = contact;
ea->list_item = NULL;
ea->status = NULL;
ea->pix = NULL;
ea->icon_handler = -1;
ea->status_handler = -1;
user->uid = atoi(ea->handle);
ea->protocol_account_data = user;
eb_debug(DBG_MOD,"eb_workwizu_read_config for %s\n",ea->handle);
return ea;
}
GList *eb_workwizu_get_states (void)
{
GList *status_list = NULL;
status_list = g_list_append(status_list, "Online");
status_list = g_list_append(status_list, "Offline");
return status_list;
}
gint eb_workwizu_get_current_state (eb_local_account *account)
{
if (account->connected)
return WWZ_ONLINE;
else
return WWZ_OFFLINE;
}
void eb_workwizu_set_current_state (eb_local_account *account, gint state)
{
if (!account)
return;
if (state == WWZ_OFFLINE && account->connected)
eb_workwizu_logout(account);
else if (state == WWZ_ONLINE && !account->connected)
eb_workwizu_login(account);
}
char *eb_workwizu_check_login (char *loginname, char *pass)
{
if (strlen(loginname) == 0)
return g_strdup(_("The login is empty."));
return NULL;
}
void eb_workwizu_add_user (eb_account *account)
{
wwz_contacts = g_list_append(wwz_contacts, account->handle);
/* nothing to do server-side */
}
void eb_workwizu_del_user (eb_account *account)
{
wwz_contacts = g_list_remove(wwz_contacts, account->handle);
/* nothing to do server-side */
}
eb_account * eb_workwizu_new_account (gchar *account)
{
eb_account *ea = g_new0(eb_account, 1);
wwz_user *user = g_new0(wwz_user, 1);
strncpy(ea->handle, account, 255);
ea->service_id = SERVICE_INFO.protocol_id;
ea->online = FALSE;
user->uid = atoi(ea->handle);
ea->protocol_account_data = user;
eb_debug(DBG_MOD,"eb_workwizu_new_account for %s\n",ea->handle);
return ea;
}
gchar *eb_workwizu_get_status_string (eb_account *account)
{
wwz_user *user = (wwz_user *)account->protocol_account_data;
if (account->online && user->has_speak)
return "";
else if (!account->online)
return strdup(_("(Offline)"));
else if (account->online && !user->has_speak)
return strdup(_("(No speak)"));
}
static gint pixmaps = 0;
static GdkPixmap * eb_workwizu_pixmap[2];
static GdkBitmap * eb_workwizu_bitmap[2];
static void eb_workwizu_init_pixmaps(void )
{
gint i;
gchar ** xpm;
for (i=WWZ_ONLINE; i<=WWZ_OFFLINE; i++) {
switch(i) {
case WWZ_ONLINE: xpm = workwizu_online_xpm;
break;
default: xpm = workwizu_away_xpm;
break;
}
eb_workwizu_pixmap[i] =
gdk_pixmap_create_from_xpm_d(statuswindow->window,
&eb_workwizu_bitmap[i], NULL, xpm);
}
pixmaps = 1;
}
void eb_workwizu_get_status_pixmap(eb_account * account, GdkPixmap **pm,
GdkBitmap **bm)
{
wwz_user *user = (wwz_user *)account->protocol_account_data;
if (!pixmaps)
eb_workwizu_init_pixmaps();
if (account->online && user->has_speak) {
*pm = eb_workwizu_pixmap[WWZ_ONLINE];
*bm = eb_workwizu_bitmap[WWZ_ONLINE];
} else {
*pm = eb_workwizu_pixmap[WWZ_OFFLINE];
*bm = eb_workwizu_bitmap[WWZ_OFFLINE];
}
}
void eb_workwizu_send_chat_room_message(eb_chat_room *room, gchar *message)
{
/* packet dest = EXCEPTME; */
}
void eb_workwizu_join_chat_room (eb_chat_room *room)
{
room->connected = TRUE;
}
void eb_workwizu_leave_chat_room (eb_chat_room *room)
{
room->connected = FALSE;
}
eb_chat_room *eb_workwizu_make_chat_room(gchar *name, eb_local_account *account)
{
eb_chat_room * ecr = NULL;
wwz_account_data *wad = (wwz_account_data
*)account->protocol_local_account_data;
if (wad->chat_room != NULL)
return wad->chat_room;
ecr = g_new0(eb_chat_room, 1);
strncpy(ecr->room_name, name, 1024);
ecr->fellows = NULL;
ecr->connected = FALSE;
ecr->chat_room_account = account;
wad->chat_room = ecr;
return ecr;
}
void eb_workwizu_send_invite (eb_local_account *account, eb_chat_room *room,
char *user, char *message)
{
/* nothing */
}
static char *eb_workwizu_get_color(void)
{
static char color[]="#8a448b";
return color;
}
struct service_callbacks * query_callbacks()
{
struct service_callbacks * sc;
sc = g_new0( struct service_callbacks, 1 );
sc->query_connected = eb_workwizu_query_connected;
sc->login = eb_workwizu_login;
sc->logout = eb_workwizu_logout;
sc->send_im = eb_workwizu_send_im;
sc->send_typing = eb_workwizu_send_typing;
sc->write_local_config = eb_workwizu_write_local_config;
sc->read_local_account_config = eb_workwizu_read_local_config;
sc->read_account_config = eb_workwizu_read_config;
sc->get_states = eb_workwizu_get_states;
sc->get_current_state = eb_workwizu_get_current_state;
sc->set_current_state = eb_workwizu_set_current_state;
sc->check_login = eb_workwizu_check_login;
sc->add_user = eb_workwizu_add_user;
sc->del_user = eb_workwizu_del_user;
sc->new_account = eb_workwizu_new_account;
sc->get_status_string = eb_workwizu_get_status_string;
sc->get_status_pixmap = eb_workwizu_get_status_pixmap;
sc->send_chat_room_message = eb_workwizu_send_chat_room_message;
sc->join_chat_room = eb_workwizu_join_chat_room;
sc->leave_chat_room = eb_workwizu_leave_chat_room;
sc->make_chat_room = eb_workwizu_make_chat_room;
sc->send_invite = eb_workwizu_send_invite;
sc->get_color=eb_workwizu_get_color;
sc->get_smileys=eb_default_smileys;
return sc;
}
--- NEW FILE: workwizu.h ---
/*
* Yattm
*
* Copyright (C) Colin Leroy <address@hidden>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef __EB_WORKWIZU_H__
#define __EB_WORKWIZU_H__
#include "service.h"
struct service_callbacks * workwizu_query_callbacks();
typedef struct {
int fd;
int tag_r;
int tag_w;
}tag_info;
typedef struct _wwz_account_data wwz_account_data;
struct _wwz_account_data
{
char *password;
int sock;
eb_chat_room *chat_room; /* only one */
};
typedef struct _wwz_user wwz_user;
struct _wwz_user {
char username[255];
char password[255];
char challenge[255];
char owner[255];
int uid;
int is_driver;
int channel_id;
int has_speak;
int is_typing;
int statssender;
};
typedef enum
{
CONN_CLOSED,
CONN_WAITING_CHALLENGE,
CONN_WAITING_USERINFO,
CONN_ESTABLISHED
} ConnState;
int plugin_init();
int plugin_finish();
static void clean_up (int sock);
eb_account * eb_workwizu_new_account (gchar *account);
void eb_workwizu_add_user (eb_account *account);
/* destinations */
#define CHANNEL 0
#define NODEST -1
#define SERVER -2
#define EXCEPTME -3
#define NOTDEFINED -4
#define VNCWRAPPERREFLECTOR -5
/* tags */
#define INVALIDPACKET 1
#define CONNECTIONESTABLISHED 2
#define CONNECTIONCLOSED 3
#define CONNECT 4
#define DISCONNECT 5
#define NUKESTUDENT 6
#define NEWUSER 7
#define REMOVEUSER 8
#define REMOVECHANNEL 9
#define IAMHERE 11
#define CHAT 12
#define ASKPRIVATE 13
#define CLOSEPRIVATE 14
#define PRIVATECHAT 15
#define PHRASEFORCHATFIELD 16
#define APPEND 17
#define ASKCLOSE 18
#define USERLISTBLINK 19
#define USERLISTSELECT 20
#define REMOVEUSERLISTBLINK 21
#define CHANNELLIST 22
#define VISIBLEUSER 23
#define URL 100
#define DOCUMENTCOMPLETE 101
#define SHOW 102
#define WRITE 103
#define COMMENT 104
#define QUESTION 105
#define BEEPER 106
#define ALLOWSPEAK 107
#define STOPSPEAK 108
#define PRIVATEMESSAGEALERT 109
#define PRIVATEMESSAGEALERTREMOVE 110
#define QUIZZ 111
#define PROXYREQUEST 112
#define PROXYMESSAGE 113
#define SHOWCURRENT 114
#define PUBLISHCURRENT 115
#define ALLOWBROWSING 116
#define MARKER 117
#define MARKERURL 118
#define SCROLLURL 119
#define SHOWACTIVATE 120
#define REFRESHDIAPO 121
#define OPENBOARD 200
#define CLOSEBOARD 201
#define BOARDORDER 202
#define BOARDRESIZED 203
#define DRAWINGMODE 204
#define GIVEPENCIL 205
#define REMOVEPENCIL 206
#define OPENPRIVATEBOARD 207
#define BOARDTARGET 208
#define PENSIZE 209
#define PENCOLOR 210
#define OPENTRANSPARENT 211
#define BACKGROUNDNODE 212
#define RAWSHAPEORDER 213
#define SHAPEORDER 214
#define CHATFIELDTARGET 300
#define OPENMATHEDITOR 400
#define WAITFORADRIVER 500
#define DRIVERNOTFOUND 501
#define DRIVERENTEREDINCHATROOM 502
#define VNCWRAPPERTAG 600
#define NEWSENDPAGETOUSER 700
#define UPSIZE 800
#define DOWNSIZE 801
#define CHANGEPENSTYLE 802
#define GOTOBOARD 803
#define STARTSPEAKER 900
#define STOPSPEAKER 901
#define STARTVOICEIPLISTENING 902
#define SPEAKERSTARTED 903
#define STARTVIDEOSPEAKER 904
#define STOPVIDEOSPEAKER 905
#define SPEAKERVIDEOSTARTED 906
#define STARTVIDEOLISTENING 907
#define STARTVIDEOLISTENINGDONE 908
#define FRONTWINDOW 1000
#define VALIDATECHATFIELD 1100
#define STARTRECORD 1200
#define STOPRECORD 1201
#define TABACTIVATED 1300
#define TABSHOWN 1301
#define TABHIDDEN 1302
#define TABACTIVATE 1303
#define TABCLOSED 1304
#define DISPLAYUP 1400
#define DISPLAYDOWN 1401
#define SPECIFIC 1500
#define USERSTATE 1501
#define HISTORYPREV 1600
#define HISTORYNEXT 1601
#define POLL 1700
#define POLLRESULT 1701
#define OPENPOLL 1702
#define SWITCHCONFIG 1800
#define APPSHARESTART 1900
#define APPSHAREINVITE 1901
#define APPSHARERESPOND 1902
#define APPSHAREDATA 1903
#define APPSHARESTOP 1904
#define MEDIALOCATOR 2000
#endif /*__EB_WORKWIZU_H__*/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Ayttm-commits] CVS: ayttm/modules/workwizu .cvsignore,NONE,1.1 Makefile.am,NONE,1.1 workwizu.c,NONE,1.1 workwizu.h,NONE,1.1,
Colin Leroy <address@hidden> <=