*** userserver.c.orig Sun Jan 21 23:55:45 2001 --- userserver.c Fri Apr 13 00:09:55 2001 *************** *** 1,4 **** ! /* $Id: userserver.patch,v 1.1 2001/04/27 16:24:54 blutgens Exp $ */ #include "common.h" --- 1,8 ---- ! /* ! $Id: userserver.patch,v 1.1 2001/04/27 16:24:54 blutgens Exp $ ! patched by drJeckyll for IcuKrell 0.0.1a,b-0.1.2 12/04/2001 ! */ ! #include "common.h" *************** *** 28,33 **** --- 32,40 ---- USERSERVER_CMD_NOOP = 0, USERSERVER_CMD_DO = 1, USERSERVER_CMD_READMSG = 2, + USERSERVER_CMD_MSGCOUNT = 3, + USERSERVER_CMD_GETSTATUS = 4, + USERSERVER_ICUKRELL_ASK = 9, } UserServerCmd; void userserver_handler(gint sock) *************** *** 38,43 **** --- 45,56 ---- gchar c; gchar *cmd, *args; GSList *contact; + gchar msg_count = 0; + gchar online_users = 0; + gchar msg_count_buf[100]; + gchar icu_status[100]; + gchar online_list_[100]; + gchar online_list[65000]; /* Read in the packet */ *************** *** 83,90 **** switch (cmdtype) { ! case USERSERVER_CMD_NOOP: ! break; case USERSERVER_CMD_READMSG: contact = Contacts; while( contact != NULL && g_slist_length( kontakt->stored_messages ) == 0 ) --- 96,167 ---- switch (cmdtype) { ! case USERSERVER_CMD_NOOP: ! break; ! ! case USERSERVER_CMD_MSGCOUNT: ! contact = Contacts; ! ! while (contact != NULL) ! { ! msg_count += g_slist_length(((CONTACT_PTR)contact->data)->stored_messages); ! contact = contact->next; ! } ! ! g_free( cmdbuf ); ! sprintf(msg_count_buf, "%d\n", msg_count); ! cmdbuf = g_strdup( msg_count_buf ); ! cmdlen = g_htonl( strlen(cmdbuf ) + 1 ); ! write( sock, &cmdlen, sizeof( unsigned long ) ); ! write( sock, cmdbuf, strlen( cmdbuf ) + 1 ); ! break; ! ! case USERSERVER_ICUKRELL_ASK: ! contact = Contacts; ! ! while (contact != NULL) ! { ! msg_count += g_slist_length(((CONTACT_PTR)contact->data)->stored_messages); ! if (kontakt->status != STATUS_OFFLINE) online_users++; ! contact = contact->next; ! } ! ! sprintf(icu_status, "Unknown"); ! if (Current_Status == STATUS_OFFLINE) sprintf(icu_status, "Offline"); ! else ! switch( Current_Status & 0xffff ) ! { ! case STATUS_ONLINE: ! sprintf(icu_status, "Online"); ! break; ! case STATUS_INVISIBLE: ! sprintf(icu_status, "Invisible"); ! break; ! case STATUS_NA: ! sprintf(icu_status, "N/A"); ! break; ! case STATUS_FREE_CHAT: ! sprintf(icu_status, "Free4Chat"); ! break; ! case STATUS_OCCUPIED: ! sprintf(icu_status, "Occupied"); ! break; ! case STATUS_AWAY: ! sprintf(icu_status, "Away"); ! break; ! case STATUS_DND: ! sprintf(icu_status, "DND"); ! break; ! } ! ! g_free( cmdbuf ); ! sprintf(msg_count_buf, "%s %d %d %s\n", icu_status, msg_count, online_users, toggles->theme_name); ! cmdbuf = g_strdup( msg_count_buf ); ! cmdlen = g_htonl( strlen(cmdbuf ) + 1 ); ! write( sock, &cmdlen, sizeof( unsigned long ) ); ! write( sock, cmdbuf, strlen( cmdbuf ) + 1 ); ! break; ! case USERSERVER_CMD_READMSG: contact = Contacts; while( contact != NULL && g_slist_length( kontakt->stored_messages ) == 0 ) *************** *** 94,100 **** { g_free( cmdbuf ); cmdbuf = g_strdup( _("No messages available.\n\n") ); ! cmdlen = g_htonl( strlen( cmdbuf + 1 ) ); write( sock, &cmdlen, sizeof( unsigned long ) ); write( sock, cmdbuf, strlen( cmdbuf ) + 1 ); break; --- 171,177 ---- { g_free( cmdbuf ); cmdbuf = g_strdup( _("No messages available.\n\n") ); ! cmdlen = g_htonl( strlen( cmdbuf ) + 1 ); write( sock, &cmdlen, sizeof( unsigned long ) ); write( sock, cmdbuf, strlen( cmdbuf ) + 1 ); break; *************** *** 103,116 **** show_contact_message_client( contact, sock ); break; case USERSERVER_CMD_DO: cmd=strtok(cmdbuf," \t"); if (!cmd) break; /* COMMAND: QUIT */ ! if (!strcasecmp(cmd,"quit")) icq_quit(NULL,NULL); /* COMMAND: AWAY */ else if (!strcasecmp(cmd,"away")) { --- 180,300 ---- show_contact_message_client( contact, sock ); break; + case USERSERVER_CMD_GETSTATUS: + sprintf(icu_status, "Unknown"); + if (Current_Status == STATUS_OFFLINE) sprintf(icu_status, "Offline"); + else + switch( Current_Status & 0xffff ) + { + case STATUS_ONLINE: + sprintf(icu_status, "Online"); + break; + case STATUS_INVISIBLE: + sprintf(icu_status, "Invisible"); + break; + case STATUS_NA: + sprintf(icu_status, "N/A"); + break; + case STATUS_FREE_CHAT: + sprintf(icu_status, "Free4Chat"); + break; + case STATUS_OCCUPIED: + sprintf(icu_status, "Occupied"); + break; + case STATUS_AWAY: + sprintf(icu_status, "Away"); + break; + case STATUS_DND: + sprintf(icu_status, "DND"); + break; + } + + g_free( cmdbuf ); + sprintf(msg_count_buf, "%s\n", icu_status); + cmdbuf = g_strdup(msg_count_buf); + cmdlen = g_htonl(strlen(cmdbuf) + 1); + write( sock, &cmdlen, sizeof( unsigned long ) ); + write( sock, cmdbuf, strlen( cmdbuf ) + 1 ); + break; + case USERSERVER_CMD_DO: cmd=strtok(cmdbuf," \t"); if (!cmd) break; /* COMMAND: QUIT */ ! else if (!strcasecmp(cmd,"quit")) icq_quit(NULL,NULL); + /* COMMAND: HIDE */ + else if (!strcasecmp(cmd,"hide")) + { + if (GTK_WIDGET_VISIBLE(app)) + { + gtk_widget_hide(app); + if (gnome_win_hints_get_workspace(app) != gnome_win_hints_get_current_workspace()) + gdk_window_withdraw( GTK_WIDGET(app)->window ); + } + } + + /* COMMAND: SHOW */ + else if (!strcasecmp(cmd,"show")) + { + if (!GTK_WIDGET_VISIBLE(app)) + { + if (gnome_win_hints_get_workspace(app) != gnome_win_hints_get_current_workspace()) + gnome_win_hints_set_workspace(app, gnome_win_hints_get_current_workspace()); + gtk_widget_show(app); + } + } + + /* COMMAND: SHOWHIDE */ + else if (!strcasecmp(cmd,"showhide")) + { + if (GTK_WIDGET_VISIBLE(app)) + { + gtk_widget_hide(app); + if (gnome_win_hints_get_workspace(app) != gnome_win_hints_get_current_workspace()) + gdk_window_withdraw( GTK_WIDGET(app)->window ); + } else + { + if (gnome_win_hints_get_workspace(app) != gnome_win_hints_get_current_workspace()) + gnome_win_hints_set_workspace(app, gnome_win_hints_get_current_workspace()); + gtk_widget_show(app); + } + } + + /* COMMAND: ADDCONTACT */ + else if (!strcasecmp(cmd,"addcontact")) + search_window(NULL, 0); + + /* COMMAND: CONNHISTORY */ + else if (!strcasecmp(cmd,"connhistory")) + toggle_log_window(NULL, 0); + + /* COMMAND: SHOWPREFS */ + else if (!strcasecmp(cmd,"showprefs")) + configure_window(NULL, 0); + + /* COMMAND: ISERINFO */ + else if (!strcasecmp(cmd,"changeinfo")) + change_info_window(NULL, 0); + + /* COMMAND: IGNORELIST */ + else if (!strcasecmp(cmd,"ignorelist")) + ignore_list_dialog(); + + /* COMMAND: VISIBLELIST */ + else if (!strcasecmp(cmd,"visiblelist")) + visible_list_dialog(); + + /* COMMAND: INVISIBLELIST */ + else if (!strcasecmp(cmd,"invisiblelist")) + invisible_list_dialog(); + + /* COMMAND: NOTIFYLIST */ + else if (!strcasecmp(cmd,"notifylist")) + notify_list_dialog(); + /* COMMAND: AWAY */ else if (!strcasecmp(cmd,"away")) { *************** *** 123,129 **** g_free( Away_Message ); Away_Message = g_strdup( msg ); } ! /* COMMAND: USERADD */ else if (!strcasecmp(cmd,"adduser") || !strcasecmp(cmd,"useradd")) { --- 307,313 ---- g_free( Away_Message ); Away_Message = g_strdup( msg ); } ! /* COMMAND: USERADD */ else if (!strcasecmp(cmd,"adduser") || !strcasecmp(cmd,"useradd")) { *************** *** 134,139 **** --- 318,420 ---- Add_User(atol(uin), uin, TRUE); } + + /* COMMAND: ONLINELIST */ + else if (!strcasecmp(cmd, "onlinelist")) + { + contact = Contacts; + + online_list[0] = 0; + while (contact != NULL) + { + if (kontakt->status != STATUS_OFFLINE) + { + sprintf(online_list_, "%s\t%d\t", kontakt->nick, kontakt->uin); + strcat(online_list, online_list_); + switch (kontakt->status & 0xffff) + { + case STATUS_ONLINE: + strcat(online_list, "Online"); + break; + case STATUS_INVISIBLE: + strcat(online_list, "Invisible"); + break; + case STATUS_NA: + strcat(online_list, "N/A"); + break; + case STATUS_NA_99A: + strcat(online_list, "N/A"); + break; + case STATUS_FREE_CHAT: + strcat(online_list, "Free4Chat"); + break; + case STATUS_OCCUPIED: + strcat(online_list, "Occupied"); + break; + case STATUS_OCCUPIED_MAC: + strcat(online_list, "Occupied"); + break; + case STATUS_AWAY: + strcat(online_list, "Away"); + break; + case STATUS_DND: + strcat(online_list, "DND"); + break; + } + strcat(online_list, "\t"); + } + contact = contact->next; + } + online_list[strlen(online_list) - 1] = 0; + + g_free(cmdbuf); + cmdbuf = g_strdup(online_list); + cmdlen = g_htonl(strlen(cmdbuf) + 1); + write(sock, &cmdlen, sizeof(unsigned long)); + write(sock, cmdbuf, strlen(cmdbuf) + 1); + } + + /* COMMAND: SENDMSGMENU */ + else if (strstr(cmd,"sendmsgmenu")) + { + gchar *mycmd; + gchar *newcmd, *newuin; + int iuin; + + mycmd = strdup(cmd); + newcmd = strtok(mycmd, "_"); + newuin = strtok(NULL, "_"); + iuin = atoi(newuin); + + contact = Contacts; + + while( contact != NULL ) + { + if (kontakt->uin == iuin) + { + GdkEventButton *event; + + event = g_new0( GdkEventButton, 1 ); + event->type = GDK_KEY_PRESS; + ((GdkEventKey*)event)->keyval = GDK_Return; + + icq_sendmessage_window(MainData->lb_userwin, event, contact); + } + + contact = contact->next; + } + + g_free(mycmd); + break; + } + + /* COMMAND: SENDMSG */ + else if (!strcasecmp(cmd,"sendmsg")) + { + icq_sendmessage_window_from_menu(NULL, NULL); + + break; + } /* COMMAND: MSG */ else if (!strcasecmp(cmd,"msg")) *************** *** 172,177 **** --- 453,460 ---- if (!strcasecmp(args,"dnd")) icq_set_status_dnd( NULL, NULL ); } + + /* COMMAND: READEVENT */ else if(!strcasecmp(cmd,"readevent"))