[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Ayttm-commits] CVS: ayttm/modules/workwizu workwizu.c,1.2,1.3 workwizu
From: |
Colin Leroy <address@hidden> |
Subject: |
[Ayttm-commits] CVS: ayttm/modules/workwizu workwizu.c,1.2,1.3 workwizu.h,1.1,1.2 |
Date: |
Wed, 08 Jan 2003 14:13:20 -0500 |
Update of /cvsroot/ayttm/ayttm/modules/workwizu
In directory subversions:/tmp/cvs-serv23354a/modules/workwizu
Modified Files:
workwizu.c workwizu.h
Log Message:
chatroom support, fixes
Index: workwizu.c
===================================================================
RCS file: /cvsroot/ayttm/ayttm/modules/workwizu/workwizu.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- workwizu.c 8 Jan 2003 00:42:14 -0000 1.2
+++ workwizu.c 8 Jan 2003 19:13:17 -0000 1.3
@@ -158,7 +158,6 @@
if(read(sock, &c, 1)<1)
{
printf("What the..?!\n"); //DEBUG
- clean_up(sock);
return NULL;
}
if(c=='\r') { continue; }
@@ -173,8 +172,15 @@
void sock_write (int sock, char *buf)
{
+ eb_local_account *account;
eb_debug(DBG_MOD,"WRITE:%s\n",buf);
- write(sock, buf, strlen(buf));
+ if (write(sock, buf, strlen(buf)) == -1) {
+ perror("write");
+ account = find_local_account_by_handle(my_user->username,
SERVICE_INFO.protocol_id);
+ do_error_dialog(_("Connection closed (can't write)"),
+ _("Workwizu Error"));
+ eb_workwizu_logout(account);
+ }
}
gboolean eb_workwizu_query_connected (eb_account *account)
{
@@ -295,13 +301,14 @@
}
-void get_message (int from, char *data)
+void get_message (int from, int to, 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) {
@@ -314,7 +321,15 @@
g_free(sfrom);
return;
}
- eb_parse_incomming_message(ela, ea, &SERVICE_INFO, data);
+ if (to > 0)
+ eb_parse_incomming_message(ela, ea, &SERVICE_INFO, data);
+ else {
+ wwz_account_data *wad = (wwz_account_data
*)ela->protocol_local_account_data;
+ if (wad->chat_room == NULL)
+ eb_start_chat_room(SERVICE_INFO.protocol_id,
_("Workwizu chatroom"));
+ printf("wad->chat_room = %p\n",wad->chat_room);
+ eb_chat_room_show_message(wad->chat_room,
ea->account_contact->nick, data);
+ }
g_free(sfrom);
}
@@ -343,8 +358,10 @@
{
char *sfrom = g_strdup_printf("%d", from);
eb_account *ea = find_account_by_handle(sfrom,
SERVICE_INFO.protocol_id);
- if (ea)
+ if (ea) {
buddy_logoff(ea);
+ eb_workwizu_del_user(ea);
+ }
g_free(sfrom);
}
@@ -353,7 +370,8 @@
gchar **tokens;
int tag, from, to;
char *data;
- /* 0 tag : 1 from : 2 to : 3 data */
+
+ /* 0 tag : 1 from : 2 to : 3 data */
tokens = g_strsplit(packet, ":", 4);
tag = atoi(tokens[0]);
from = atoi(tokens[1]);
@@ -371,7 +389,7 @@
rem_user(from);
break;
case CHAT:
- get_message(from, data);
+ get_message(from, to, data);
break;
case ALLOWSPEAK:
eb_debug(DBG_MOD,"yeah, right to speak\n");
@@ -392,12 +410,19 @@
void workwizu_handle_incoming(int sock, int readable, int writable)
{
char *line;
+ eb_local_account *account =
find_local_account_by_handle(my_user->username, SERVICE_INFO.protocol_id);
switch(connstate) {
case CONN_CLOSED:
eb_debug(DBG_MOD,"uh? conn is closed\n");
break;
case CONN_WAITING_CHALLENGE:
line = sock_read(sock);
+ if (line == NULL) {
+ do_error_dialog(_("Server doesn't answer"),
+ _("Workwizu Error"));
+ eb_workwizu_logout(account);
+ return;
+ }
strcpy(my_user->challenge,line);
free(line);
eb_debug(DBG_MOD,"read challenge
%s\n",my_user->challenge);
@@ -408,6 +433,7 @@
if (line == NULL) {
do_error_dialog(_("Bad authentication"),
_("Workwizu Error"));
+ eb_workwizu_logout(account);
return;
}
parse_user_info(line);
@@ -424,6 +450,12 @@
break;
case CONN_ESTABLISHED:
line = sock_read(sock);
+ if (line == NULL) {
+ do_error_dialog(_("Connection lost"),
+ _("Workwizu Error"));
+ eb_workwizu_logout(account);
+ return;
+ }
parse_packet(line);
free(line);
break;
@@ -603,6 +635,7 @@
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);
+ eb_workwizu_del_user(ea);
buddy_update_status(ea);
}
account->connected = 0;
@@ -645,10 +678,13 @@
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"));
+ else
+ send_my_packet(wad->sock, CHAT, user->uid, send);
+ g_free(send);
}
int eb_workwizu_send_typing (eb_local_account *account_from,
@@ -763,13 +799,21 @@
void eb_workwizu_add_user (eb_account *account)
{
- wwz_contacts = g_list_append(wwz_contacts, account->handle);
+ eb_local_account *account_from =
find_local_account_by_handle(my_user->username, SERVICE_INFO.protocol_id);
+ wwz_account_data *wad = (wwz_account_data
*)account_from->protocol_local_account_data;
+ wwz_contacts = g_list_append(wwz_contacts, account->handle);
+ if (wad->chat_room)
+ eb_chat_room_buddy_arrive(wad->chat_room,
account->account_contact->nick, account->handle);
/* nothing to do server-side */
}
void eb_workwizu_del_user (eb_account *account)
{
+ eb_local_account *account_from =
find_local_account_by_handle(my_user->username, SERVICE_INFO.protocol_id);
+ wwz_account_data *wad = (wwz_account_data
*)account_from->protocol_local_account_data;
wwz_contacts = g_list_remove(wwz_contacts, account->handle);
+ if (wad->chat_room)
+ eb_chat_room_buddy_leave(wad->chat_room, account->handle);
/* nothing to do server-side */
}
@@ -837,17 +881,41 @@
void eb_workwizu_send_chat_room_message(eb_chat_room *room, gchar *message)
{
- /* packet dest = EXCEPTME; */
+ eb_local_account *account_from = (eb_local_account
*)room->chat_room_account;
+ wwz_account_data *wad = (wwz_account_data
*)account_from->protocol_local_account_data;
+ char *send = translate_to_br(message);
+
+ if (!my_user->has_speak)
+ do_error_dialog(_("You aren't allowed to speak.\nThis message
has probably not arrived."),
+ _("Workwizu Error"));
+ else {
+ send_my_packet(wad->sock, CHAT, EXCEPTME, send);
+ eb_chat_room_show_message(room, my_user->username, send);
+ }
+
+ g_free(send);
}
void eb_workwizu_join_chat_room (eb_chat_room *room)
{
+ GList *all = NULL;
room->connected = TRUE;
+ for (all = wwz_contacts; all != NULL && all->data != NULL; all =
all->next) {
+ eb_account * ea = (eb_account *)find_account_by_handle((char
*)all->data, SERVICE_INFO.protocol_id);
+ eb_chat_room_buddy_arrive(room, ea->account_contact->nick,
ea->handle);
+ }
}
void eb_workwizu_leave_chat_room (eb_chat_room *room)
{
+ GList *all = NULL;
+ eb_local_account *account = (eb_local_account *)room->chat_room_account;
+ wwz_account_data *wad = (wwz_account_data
*)account->protocol_local_account_data;
+ for (all = wwz_contacts; all != NULL && all->data != NULL; all =
all->next) {
+ eb_chat_room_buddy_leave(room, (char*)all->data);
+ }
room->connected = FALSE;
+ wad->chat_room = NULL;
}
eb_chat_room *eb_workwizu_make_chat_room(gchar *name, eb_local_account
*account)
@@ -864,6 +932,8 @@
ecr->connected = FALSE;
ecr->chat_room_account = account;
wad->chat_room = ecr;
+
+ eb_join_chat_room(ecr);
return ecr;
}
@@ -877,7 +947,15 @@
static char color[]="#8a448b";
return color;
}
-
+
+void eb_workwizu_set_away (eb_local_account * account, gchar * message ) {
+
+}
+
+void eb_workwizu_set_idle (eb_local_account * account, gint idle ) {
+
+}
+
struct service_callbacks * query_callbacks()
{
struct service_callbacks * sc;
@@ -907,6 +985,8 @@
sc->send_invite = eb_workwizu_send_invite;
sc->get_color=eb_workwizu_get_color;
sc->get_smileys=eb_default_smileys;
+ sc->set_away=eb_workwizu_set_away;
+ sc->set_idle=eb_workwizu_set_idle;
return sc;
}
Index: workwizu.h
===================================================================
RCS file: /cvsroot/ayttm/ayttm/modules/workwizu/workwizu.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- workwizu.h 7 Jan 2003 19:02:33 -0000 1.1
+++ workwizu.h 8 Jan 2003 19:13:17 -0000 1.2
@@ -69,7 +69,7 @@
static void clean_up (int sock);
eb_account * eb_workwizu_new_account (gchar *account);
void eb_workwizu_add_user (eb_account *account);
-
+void eb_workwizu_del_user (eb_account *account);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Ayttm-commits] CVS: ayttm/modules/workwizu workwizu.c,1.2,1.3 workwizu.h,1.1,1.2,
Colin Leroy <address@hidden> <=
- Prev by Date:
[Ayttm-commits] CVS: ayttm ChangeLog,1.53,1.54 configure.in,1.53,1.54
- Next by Date:
[Ayttm-commits] CVS: ayttm ChangeLog,1.54,1.55 configure.in,1.54,1.55
- Previous by thread:
[Ayttm-commits] CVS: ayttm ChangeLog,1.53,1.54 configure.in,1.53,1.54
- Next by thread:
[Ayttm-commits] CVS: ayttm ChangeLog,1.54,1.55 configure.in,1.54,1.55
- Index(es):