# HG changeset patch # User Mark Doliner # Date 1125545572 0 # Node ID a6d446cf090fac84ef0029cb1ecc18009e17fe69 # Parent 677a3862260f3276afca8dfa066081fec5ff1c39 [gaim-migrate @ 13640] Get rid of the old gaim-remote. Someone will need to make sure the new D-BUS stuff is distributed in the tarballs and rpms appropriately. Did I miss any pieces? committer: Tailor Script diff -r 677a3862260f -r a6d446cf090f configure.ac --- a/configure.ac Thu Sep 01 03:30:18 2005 +0000 +++ b/configure.ac Thu Sep 01 03:32:52 2005 +0000 @@ -1319,7 +1319,6 @@ gaim.apspec doc/Makefile doc/gaim.1 - doc/gaim-remote.1 intl/Makefile m4macros/Makefile pixmaps/Makefile @@ -1331,7 +1330,6 @@ plugins/Makefile plugins/docklet/Makefile plugins/gevolution/Makefile - plugins/gaim-remote/Makefile plugins/gestures/Makefile plugins/musicmessaging/Makefile plugins/perl/Makefile diff -r 677a3862260f -r a6d446cf090f gaim.apspec.in --- a/gaim.apspec.in Thu Sep 01 03:30:18 2005 +0000 +++ b/gaim.apspec.in Thu Sep 01 03:32:52 2005 +0000 @@ -48,7 +48,6 @@ [Install] # Put your installation script here installExe ./bin/* -installLib ./lib/libgaim-remote.so.0.0.0 # do the plugins copyFiles ./lib/gaim "$PREFIX/lib" installMan 1 ./man/man1/gaim.1 diff -r 677a3862260f -r a6d446cf090f gaim.spec.in --- a/gaim.spec.in Thu Sep 01 03:30:18 2005 +0000 +++ b/gaim.spec.in Thu Sep 01 03:32:52 2005 +0000 @@ -26,14 +26,14 @@ %if "%{_vendor}" == "MandrakeSoft" # Mandrake/Mandriva requirements BuildRequires: libgtk+2.0_0-devel, libnss3-devel, perl-devel -Provides: libgaim-remote0 +Obsoletes: libgaim-remote0 %else # Mandrake 10.2 (and higher?) %if "%{_vendor}" == "Mandrakesoft" # Mandrake/Mandriva requirements BuildRequires: libgtk+2.0_0-devel, libnss3-devel, perl-devel -Provides: libgaim-remote0 +Obsoletes: libgaim-remote0 %else # SuSE & Red Hat / Fedora requirements @@ -152,7 +152,6 @@ %doc %{_mandir}/man3*/* %dir %{_libdir}/gaim -%attr(755, root, root) %{_libdir}/libgaim-remote.so.* %attr(755, root, root) %{_libdir}/libgaimperl.so %attr(755, root, root) %{perl_vendorlib} @@ -183,8 +182,6 @@ %doc plugins/HOWTO %doc HACKING PROGRAMMING_NOTES -%attr(755, root, root) %{_libdir}/libgaim-remote.so -%attr(755, root, root) %{_libdir}/libgaim-remote.la %dir %{_includedir}/gaim %{_includedir}/gaim/*.h %{_libdir}/pkgconfig/gaim.pc diff -r 677a3862260f -r a6d446cf090f plugins/Makefile.am --- a/plugins/Makefile.am Thu Sep 01 03:30:18 2005 +0000 +++ b/plugins/Makefile.am Thu Sep 01 03:32:52 2005 +0000 @@ -1,4 +1,4 @@ -DIST_SUBDIRS = docklet gevolution gaim-remote gestures musicmessaging perl ssl tcl ticker +DIST_SUBDIRS = docklet gevolution gestures musicmessaging perl ssl tcl ticker if BUILD_GEVOLUTION GEVOLUTION_DIR = gevolution @@ -13,7 +13,7 @@ endif SUBDIRS = \ - docklet gaim-remote $(GEVOLUTION_DIR) gestures \ + docklet $(GEVOLUTION_DIR) gestures \ $(PERL_DIR) ssl $(TCL_DIR) ticker plugindir = $(libdir)/gaim diff -r 677a3862260f -r a6d446cf090f plugins/gaim-remote/.cvsignore --- a/plugins/gaim-remote/.cvsignore Thu Sep 01 03:30:18 2005 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -Makefile -Makefile.in -.deps -.libs -*.dll -*.la -*.lo diff -r 677a3862260f -r a6d446cf090f plugins/gaim-remote/Makefile.am --- a/plugins/gaim-remote/Makefile.am Thu Sep 01 03:30:18 2005 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -grincludedir = $(includedir)/gaim - -plugindir = $(libdir)/gaim - -lib_LTLIBRARIES = libgaim-remote.la - -grinclude_HEADERS = \ - remote-socket.h \ - remote.h - -libgaim_remote_la_SOURCES = remote-socket.c -libgaim_remote_la_LIBADD = $(GLIB_LIBS) - -gaim_remote_la_LDFLAGS = -module -avoid-version - -if PLUGINS - -plugin_LTLIBRARIES = gaim-remote.la - -gaim_remote_la_SOURCES = remote.c -gaim_remote_la_LIBADD = libgaim-remote.la $(GTK_LIBS) - -endif - -AM_CPPFLAGS = \ - -DDATADIR=\"$(datadir)\" \ - -DVERSION=\"$(VERSION)\" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/plugins \ - -I$(top_srcdir)/src \ - $(GTK_CFLAGS) \ - $(DEBUG_CFLAGS) diff -r 677a3862260f -r a6d446cf090f plugins/gaim-remote/remote-socket.c --- a/plugins/gaim-remote/remote-socket.c Thu Sep 01 03:30:18 2005 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,201 +0,0 @@ -/* - * gaim-remote - * - * Copyright (C) 2002, Sean Egan - * - * 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 - * - */ - -/* Somewhat inspired by XMMS: - * Copyright (C) 1998-2002 Peter Alm, Mikael Alm, Olle Hallnas, - * Thomas Nilsson and 4Front Technologies - * Copyright (C) 1999-2002 Haavard Kvaalen - */ - -/* This provides code for connecting to a Gaim socket and communicating with - * it. It will eventually be made a library once the core and ui are split. */ - -#include "internal.h" -#include -#include -#include -#include - -void -gaim_remote_session_send_packet(int fd, GaimRemotePacket *p) -{ - int len = sizeof(p->type) + sizeof(p->subtype) + - sizeof(p->length) + p->length; - char *pack = g_malloc(len); - char *a = pack; - - memcpy (a, &(p->type), sizeof(p->type)); - a = a + sizeof(p->type); - memcpy (a, &(p->subtype), sizeof(p->subtype)); - a = a + sizeof(p->subtype); - memcpy (a, &(p->length), sizeof(p->length)); - a = a + sizeof(p->length); - memcpy (a, p->data, p->length); - write(fd, pack, len); - g_free(pack); -} - -void -gaim_remote_packet_append_string(GaimRemotePacket *p, char *str) -{ - int len = p->length + strlen(str); - char *k = g_malloc(len); - - memcpy(k, p->data, p->length); - memcpy(k + p->length, str, strlen(str)); - - if (p->data) - g_free(p->data); - - p->data = k; - p->length = len; -} - -void -gaim_remote_packet_append_char(GaimRemotePacket *p, char c) -{ - int len = p->length + sizeof(char); - char *k = g_malloc(len); - - memcpy(k, p->data, p->length); - k[p->length] = c; - - if (p->data) - g_free(p->data); - - p->data = k; - p->length = len; -} - -void -gaim_remote_packet_append_raw(GaimRemotePacket *p, char *str, int len) -{ - int lent = p->length + len; - char *k = g_malloc(lent); - - memcpy(k, p->data, p->length); - memcpy(k + p->length, str, len); - - if (p->data) - g_free(p->data); - - p->data = k; - p->length = lent; -} - -GaimRemotePacket * -gaim_remote_packet_new(guchar type, guchar subtype) -{ - GaimRemotePacket *p = g_new0(GaimRemotePacket, 1); - p->type = type; - p->subtype = subtype; - p->length = 0; - p->data = NULL; - return p; -} - -void -gaim_remote_packet_free(GaimRemotePacket *p) -{ - if (p->data) - g_free(p->data); - g_free(p); -} - -GaimRemotePacket * -gaim_remote_session_read_packet(int fd) -{ - GaimRemotePacket *p = g_new0(GaimRemotePacket, 1); - char *data = NULL; - - if ((read(fd, &p->type, sizeof(p->type))) != sizeof(p->type)) { - g_free(p); - return NULL; - } - - if ((read(fd, &p->subtype, sizeof(p->subtype))) != sizeof(p->subtype)) { - g_free(p); - return NULL; - } - - if ((read(fd, &p->length, sizeof(p->length))) != sizeof(p->length)) { - g_free(p); - return NULL; - } - - if (p->length) { - data = g_try_malloc(p->length); - - if ((data == NULL) || (read(fd, data, p->length)) != p->length) { - g_free(p); - return NULL; - } - } - - p->data = data; - - return p; -} - -/* copied directly from xmms_connect_to_session */ -int -gaim_remote_session_connect(int session) -{ - gint fd; - uid_t stored_uid, euid; - struct sockaddr_un saddr; - - if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) != -1) - { - saddr.sun_family = AF_UNIX; - stored_uid = getuid(); - euid = geteuid(); - setuid(euid); - sprintf(saddr.sun_path, "%s/gaim_%s.%d", - g_get_tmp_dir(), g_get_user_name(), session); - setreuid(stored_uid, euid); - - if (connect(fd, (struct sockaddr *) &saddr, sizeof (saddr)) != -1) - return fd; - } - - close(fd); - - return -1; -} - -gboolean -gaim_remote_session_exists(int sess) -{ - GaimRemotePacket *pack = NULL; - int fd = gaim_remote_session_connect(sess); - - if (fd > 0) { - pack = gaim_remote_packet_new(CUI_TYPE_META, CUI_META_PING); - gaim_remote_session_send_packet(fd, pack); - gaim_remote_packet_free(pack); - close(fd); - - return TRUE; - } - - return FALSE; -} diff -r 677a3862260f -r a6d446cf090f plugins/gaim-remote/remote-socket.h --- a/plugins/gaim-remote/remote-socket.h Thu Sep 01 03:30:18 2005 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -/* - * gaim-remote - * - * Copyright (C) 2003 Christian Hammond - * Copyright (C) 2002, Sean Egan - * - * 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 _GAIM_SOCKET_H_ -#define _GAIM_SOCKET_H_ - -#include - -typedef struct -{ - unsigned char type; - unsigned char subtype; - unsigned long length; - char *data; - -} GaimRemotePacket; - -void gaim_remote_session_send_packet(int fd, GaimRemotePacket *packet); -int gaim_remote_session_connect(int session); -gboolean gaim_remote_session_exists(int sess); -GaimRemotePacket *gaim_remote_session_read_packet(int fd); - -GaimRemotePacket *gaim_remote_packet_new(guchar type, guchar subtype); -void gaim_remote_packet_free(GaimRemotePacket *p); -void gaim_remote_packet_append_string(GaimRemotePacket *p, char *str); -void gaim_remote_packet_append_char(GaimRemotePacket *p, char c); -void gaim_remote_packet_append_raw(GaimRemotePacket *p, char *str, int len); - -#endif /* _GAIM_SOCKET_H_ */ diff -r 677a3862260f -r a6d446cf090f plugins/gaim-remote/remote.c --- a/plugins/gaim-remote/remote.c Thu Sep 01 03:30:18 2005 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,850 +0,0 @@ -/** - * Remote control plugin for Gaim - * - * Copyright (C) 2003 Christian Hammond. - * Copyright (C) 1998-1999, Mark Spencer - * - * 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. - * - * @todo Make this a core plugin! - */ -#include "internal.h" -#include "gtkgaim.h" - -#ifndef _WIN32 -# include -#endif - -#include -#include - -#include "conversation.h" -#include "core.h" -#include "debug.h" -#include "prpl.h" -#include "notify.h" -#include "util.h" -#include "version.h" - -/* XXX */ -#include "gtkconv.h" -#include "gtkplugin.h" -#include "gaim.h" -#include "prefs.h" - -#include - -#define REMOTE_PLUGIN_ID "gtk-remote" - -struct UI { - GIOChannel *channel; - guint inpa; -}; - -#ifndef _WIN32 -static gint UI_fd = -1; -static guint watcher = 0; -#endif -static int gaim_session = 0; -static GSList *uis = NULL; - -/* AIM URI's ARE FUN :-D */ -static const char * -gaim_remote_handle_uri(const char *uri) -{ - const char *username; - GString *str; - GList *conn; - GaimConnection *gc = NULL; - GaimAccount *account; - - gaim_debug_info("gaim_remote_handle_uri", "Handling URI: %s\n", uri); - - /* Well, we'd better check to make sure we have at least one - AIM account connected. */ - for (conn = gaim_connections_get_all(); conn != NULL; conn = conn->next) { - gc = conn->data; - account = gaim_connection_get_account(gc); - username = gaim_account_get_username(account); - - if (strcmp(gaim_account_get_protocol_id(account), "prpl-oscar") == 0 && - username != NULL && isalpha(*username)) { - - break; - } - } - - if (gc == NULL) - return _("Not connected to AIM"); - - /* aim:goim?screenname=screenname&message=message */ - if (!g_ascii_strncasecmp(uri, "aim:goim?", strlen("aim:goim?"))) { - char *who, *what; - GaimConversation *c; - uri = uri + strlen("aim:goim?"); - - if (!(who = strstr(uri, "screenname="))) { - return _("No screenname given."); - } - /* spaces are encoded as +'s */ - who = who + strlen("screenname="); - str = g_string_new(NULL); - while (*who && (*who != '&')) { - g_string_append_c(str, *who == '+' ? ' ' : *who); - who++; - } - who = g_strdup(str->str); - g_string_free(str, TRUE); - - what = strstr(uri, "message="); - if (what) { - what = what + strlen("message="); - str = g_string_new(NULL); - while (*what && (*what != '&' || !g_ascii_strncasecmp(what, "&", 5))) { - g_string_append_c(str, *what == '+' ? ' ' : *what); - what++; - } - what = g_strdup(str->str); - g_string_free(str, TRUE); - } - - c = gaim_conversation_new(GAIM_CONV_TYPE_IM, gc->account, who); - g_free(who); - - if (what) { - GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(c); - - gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, what, -1); - g_free(what); - } - } else if (!g_ascii_strncasecmp(uri, "aim:addbuddy?", strlen("aim:addbuddy?"))) { - char *who, *group; - uri = uri + strlen("aim:addbuddy?"); - /* spaces are encoded as +'s */ - - if (!(who = strstr(uri, "screenname="))) { - return _("No screenname given."); - } - who = who + strlen("screenname="); - str = g_string_new(NULL); - while (*who && (*who != '&')) { - g_string_append_c(str, *who == '+' ? ' ' : *who); - who++; - } - who = g_strdup(str->str); - g_string_free(str, TRUE); - - group = strstr(uri, "group="); - if (group) { - group = group + strlen("group="); - str = g_string_new(NULL); - while (*group && (*group != '&' || !g_ascii_strncasecmp(group, "&", 5))) { - g_string_append_c(str, *group == '+' ? ' ' : *group); - group++; - } - group = g_strdup(str->str); - g_string_free(str, TRUE); - } - - gaim_debug_misc("gaim_remote_handle_uri", "who: %s\n", who); - gaim_blist_request_add_buddy(gc->account, who, group, NULL); - g_free(who); - if (group) - g_free(group); - } else if (!g_ascii_strncasecmp(uri, "aim:gochat?", strlen("aim:gochat?"))) { - char *room; - GHashTable *components; - int exch = 5; - - uri = uri + strlen("aim:gochat?"); - /* spaces are encoded as +'s */ - - if (!(room = strstr(uri, "roomname="))) { - return _("No roomname given."); - } - room = room + strlen("roomname="); - str = g_string_new(NULL); - while (*room && (*room != '&')) { - g_string_append_c(str, *room == '+' ? ' ' : *room); - room++; - } - room = g_strdup(str->str); - g_string_free(str, TRUE); - components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, - g_free); - g_hash_table_replace(components, g_strdup("room"), room); - g_hash_table_replace(components, g_strdup("exchange"), - g_strdup_printf("%d", exch)); - - serv_join_chat(gc, components); - g_hash_table_destroy(components); - } else { - return _("Invalid AIM URI"); - } - - return NULL; -} - - - -#if 0 -static guchar * -UI_build(guint32 *len, guchar type, guchar subtype, va_list args) -{ - guchar *buffer; - guint32 pos; - int size; - void *data; - - *len = sizeof(guchar) * 2 + 4; - buffer = g_malloc(*len); - pos = 0; - - memcpy(buffer + pos, &type, sizeof(type)); pos += sizeof(type); - memcpy(buffer + pos, &subtype, sizeof(subtype)); pos += sizeof(subtype); - - /* we come back and do size last */ - pos += 4; - - size = va_arg(args, int); - while (size != -1) { - *len += size; - buffer = g_realloc(buffer, *len); - - data = va_arg(args, void *); - memcpy(buffer + pos, data, size); - pos += size; - - size = va_arg(args, int); - } - - pos -= sizeof(guchar) * 2 + 4; - - /* now we do size */ - memcpy(buffer + sizeof(guchar) * 2, &pos, 4); - - return buffer; -} - -static gint -UI_write(struct UI *ui, guchar *data, gint len) -{ - GError *error = NULL; - gint sent; - /* we'll let the write silently fail because the read will pick it up as dead */ - g_io_channel_write_chars(ui->channel, data, len, &sent, &error); - if (error) - g_error_free(error); - return sent; -} - -static void -UI_build_write(struct UI *ui, guchar type, guchar subtype, ...) -{ - va_list ap; - gchar *data; - guint32 len; - - va_start(ap, subtype); - data = UI_build(&len, type, subtype, ap); - va_end(ap); - - UI_write(ui, data, len); - - g_free(data); -} - -static void -UI_broadcast(guchar *data, gint len) -{ - GSList *u = uis; - while (u) { - struct UI *ui = u->data; - UI_write(ui, data, len); - u = u->next; - } -} - -static void -UI_build_broadcast(guchar type, guchar subtype, ...) -{ - va_list ap; - gchar *data; - guint32 len; - - if (!uis) - return; - - va_start(ap, subtype); - data = UI_build(&len, type, subtype, ap); - va_end(ap); - - UI_broadcast(data, len); - - g_free(data); -} -#endif - -#ifndef _WIN32 -static void -meta_handler(struct UI *ui, guchar subtype, gchar *data) -{ - GaimRemotePacket *p; - GError *error = NULL; - - switch (subtype) { - case CUI_META_LIST: - break; - case CUI_META_QUIT: - while (uis) { - ui = uis->data; - uis = g_slist_remove(uis, ui); - g_io_channel_shutdown(ui->channel, TRUE, &error); - g_source_remove(ui->inpa); - g_free(ui); - } - g_timeout_add(0, gaim_core_quit_cb, NULL); - break; - case CUI_META_DETACH: - uis = g_slist_remove(uis, ui); - g_io_channel_shutdown(ui->channel, TRUE, &error); - g_source_remove(ui->inpa); - g_free(ui); - break; - case CUI_META_PING: - p = gaim_remote_packet_new(CUI_TYPE_META, CUI_META_ACK); - gaim_remote_session_send_packet(g_io_channel_unix_get_fd(ui->channel), - p); - gaim_remote_packet_free(p); - break; - default: - gaim_debug_warning("cui", "Unhandled meta subtype %d\n", subtype); - break; - } - - if(error) - g_error_free(error); -} - -static void -plugin_handler(struct UI *ui, guchar subtype, gpointer data) -{ -#ifdef GAIM_PLUGINS - guint id; - GaimPlugin *p; - - switch (subtype) { - /* - case CUI_PLUGIN_LIST: - break; - */ - case CUI_PLUGIN_LOAD: - gaim_plugin_load(gaim_plugin_probe(data)); - break; - case CUI_PLUGIN_UNLOAD: - memcpy(&id, data, sizeof(id)); - p = g_list_nth_data(gaim_plugins_get_loaded(), id); - if (p) { - gaim_plugin_unload(p); - } - break; - default: - gaim_debug_warning("cui", "Unhandled plugin subtype %d\n", subtype); - break; - } -#endif -} - -static void -user_handler(struct UI *ui, guchar subtype, gchar *data) -{ - guint id; - GaimAccount *account; - - switch (subtype) { - /* - case CUI_USER_LIST: - break; - case CUI_USER_ADD: - break; - case CUI_USER_REMOVE: - break; - case CUI_USER_MODIFY: - break; - */ - - case CUI_USER_SIGNON: - if (!data) - return; - memcpy(&id, data, sizeof(id)); - account = g_list_nth_data(gaim_accounts_get_all(), id); - if (account) - gaim_account_connect(account); - /* don't need to do anything here because the UI will get updates from other handlers */ - break; - -#if 0 /* STATUS */ - case CUI_USER_AWAY: - { - GSList* l; - const char* default_away_name = gaim_prefs_get_string("/core/away/default_message"); - - for (l = away_messages; l; l = l->next) { - if (!strcmp(default_away_name, ((struct away_message *)l->data)->name)) { - do_away_message(NULL, l->data); - break; - } - } - } - break; - - case CUI_USER_BACK: - do_im_back(NULL, NULL); - break; - -#endif /* STATUS */ - - case CUI_USER_LOGOUT: - gaim_connections_disconnect_all(); - break; - - default: - gaim_debug_warning("cui", "Unhandled user subtype %d\n", subtype); - break; - } -} - -static void -message_handler(struct UI *ui, guchar subtype, gchar *data) -{ - switch (subtype) { - case CUI_MESSAGE_LIST: - break; - case CUI_MESSAGE_SEND: - if (!data) - return; - { - guint id; - GaimConnection *gc; - guint len; - char *who, *msg; - gint flags; - int pos = 0; - - memcpy(&id, data + pos, sizeof(id)); - pos += sizeof(id); - gc = g_list_nth_data(gaim_connections_get_all(), id); - if (!gc) - return; - - memcpy(&len, data + pos, sizeof(len)); - pos += sizeof(len); - who = g_strndup(data + pos, len + 1); - pos += len; - - memcpy(&len, data + pos, sizeof(len)); - pos += sizeof(len); - msg = g_strndup(data + pos, len + 1); - pos += len; - - memcpy(&flags, data + pos, sizeof(flags)); - serv_send_im(gc, who, msg, flags); - - g_free(who); - g_free(msg); - } - break; - case CUI_MESSAGE_RECV: - break; - default: - gaim_debug_warning("cui", "Unhandled message subtype %d\n", subtype); - break; - } -} - -static gint -gaim_recv(GIOChannel *source, gchar *buf, gint len) -{ - gint total = 0; - gsize cur; - - GError *error = NULL; - - while (total < len) { - if (g_io_channel_read_chars(source, buf + total, len - total, &cur, &error) != G_IO_STATUS_NORMAL) { - if (error) - g_error_free(error); - return -1; - } - if (cur == 0) - return total; - total += cur; - } - - return total; -} - -static void -remote_handler(struct UI *ui, guchar subtype, gchar *data, int len) -{ - const char *resp; - char *send; - GList *c = gaim_connections_get_all(); - GaimConnection *gc = NULL; - GaimAccount *account; - - switch (subtype) { - case CUI_REMOTE_CONNECTIONS: - break; - case CUI_REMOTE_SEND: - if (!data) - return; - { - GaimConversation *conv; - guint tlen, len, len2, quiet; - char *who, *msg; - char *tmp, *from, *proto; - int pos = 0; - - gaim_debug_info("cui", "Got `gaim-remote send` packet\n",data); - gaim_debug_info("cui", "g-r>%s;\n",data); - - tmp = g_strndup(data + pos, 4); - tlen = atoi(tmp); - pos += 4; - - who = g_strndup(data+pos, tlen); - pos += tlen; - - tmp = g_strndup(data + pos, 4); - tlen = atoi(tmp); len=tlen; /* length for 'from' compare */ - pos += 4; - - from = g_strndup(data+pos, tlen); - pos += tlen; - - tmp = g_strndup(data + pos, 4); - tlen = atoi(tmp); len2=tlen; /* length for 'proto' compare */ - pos += 4; - - proto = g_strndup(data+pos, tlen); - pos += tlen; - - tmp = g_strndup(data + pos, 4); - tlen = atoi(tmp); - pos += 4; - - msg = g_strndup(data+pos, tlen); - pos += tlen; - - tmp = g_strndup(data + pos, 1); - quiet = atoi(tmp); /* quiet flag - not in use yet */ - - /* find acct */ - while (c) { - gc = c->data; - account=gaim_connection_get_account(gc); - if ((!gaim_utf8_strcasecmp(from, gaim_account_get_username(account))) && (!g_ascii_strncasecmp(proto, gaim_account_get_protocol_id(account), len2)) ) - break; - c = c->next; - } - if (!gc) - return; - /* end acct find */ - - /* gaim_debug_info("cui", "g-r>To: %s; From: %s; Protocol: %s; Message: %s; Quiet: %d\n",who,from,proto,msg,quiet); */ - conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, gaim_connection_get_account(gc), who); - gaim_conv_im_send(GAIM_CONV_IM(conv), msg); - - /* likely to be used for quiet: - serv_send_im(gc, who, msg, -1, 0); - */ - - g_free(who); - g_free(msg); - g_free(from); - g_free(tmp); - } - break; - - case CUI_REMOTE_URI: - send = g_malloc(len + 1); - memcpy(send, data, len); - send[len] = 0; - resp = gaim_remote_handle_uri(send); - g_free(send); - /* report error */ - break; - - default: - gaim_debug_warning("cui", "Unhandled remote subtype %d\n", subtype); - break; - } -} - -static gboolean -UI_readable(GIOChannel *source, GIOCondition cond, gpointer data) -{ - struct UI *ui = data; - gchar type; - gchar subtype; - gint len; - GError *error = NULL; - gchar *in; - - /* no byte order worries! this'll change if we go to TCP */ - if (gaim_recv(source, &type, sizeof(type)) != sizeof(type)) { - gaim_debug_error("cui", "UI has abandoned us!\n"); - uis = g_slist_remove(uis, ui); - g_io_channel_shutdown(ui->channel, TRUE, &error); - if(error) { - g_error_free(error); - error = NULL; - } - g_source_remove(ui->inpa); - g_free(ui); - return FALSE; - } - - if (gaim_recv(source, &subtype, sizeof(subtype)) != sizeof(subtype)) { - gaim_debug_error("cui", "UI has abandoned us!\n"); - uis = g_slist_remove(uis, ui); - g_io_channel_shutdown(ui->channel, TRUE, &error); - if(error) { - g_error_free(error); - error = NULL; - } - g_source_remove(ui->inpa); - g_free(ui); - return FALSE; - } - - if (gaim_recv(source, (gchar *)&len, sizeof(len)) != sizeof(len)) { - gaim_debug_error("cui", "UI has abandoned us!\n"); - uis = g_slist_remove(uis, ui); - g_io_channel_shutdown(ui->channel, TRUE, &error); - if(error) { - g_error_free(error); - error = NULL; - } - g_source_remove(ui->inpa); - g_free(ui); - return FALSE; - } - - if (len) { - in = g_new0(gchar, len); - if (gaim_recv(source, in, len) != len) { - gaim_debug_error("cui", "UI has abandoned us!\n"); - uis = g_slist_remove(uis, ui); - g_io_channel_shutdown(ui->channel, TRUE, &error); - if(error) { - g_error_free(error); - error = NULL; - } - g_source_remove(ui->inpa); - g_free(ui); - return FALSE; - } - } else - in = NULL; - - switch (type) { - case CUI_TYPE_META: - meta_handler(ui, subtype, in); - break; - case CUI_TYPE_PLUGIN: - plugin_handler(ui, subtype, in); - break; - case CUI_TYPE_USER: - user_handler(ui, subtype, in); - break; - /* - case CUI_TYPE_CONN: - conn_handler(ui, subtype, in); - break; - case CUI_TYPE_BUDDY: - buddy_handler(ui, subtype, in); - break; - */ - case CUI_TYPE_MESSAGE: - message_handler(ui, subtype, in); - break; - /* - case CUI_TYPE_CHAT: - chat_handler(ui, subtype, in); - break; - */ - case CUI_TYPE_REMOTE: - remote_handler(ui, subtype, in, len); - break; - default: - gaim_debug_warning("cui", "Unhandled type %d\n", type); - break; - } - - if (in) - g_free(in); - return TRUE; -} - -static gboolean -socket_readable(GIOChannel *source, GIOCondition cond, gpointer data) -{ - struct sockaddr_un saddr; - guint len = sizeof(saddr); - gint fd; - - struct UI *ui; - - if ((fd = accept(UI_fd, (struct sockaddr *)&saddr, &len)) == -1) - return FALSE; - - ui = g_new0(struct UI, 1); - uis = g_slist_append(uis, ui); - - ui->channel = g_io_channel_unix_new(fd); - ui->inpa = g_io_add_watch(ui->channel, G_IO_IN | G_IO_HUP | G_IO_ERR, UI_readable, ui); - g_io_channel_unref(ui->channel); - - gaim_debug_misc("cui", "Got one\n"); - return TRUE; -} - -static gint -open_socket(char **error) -{ - struct sockaddr_un saddr; - gint fd; - - while (gaim_remote_session_exists(gaim_session)) - gaim_session++; - - gaim_debug_misc("cui", "Session: %d\n", gaim_session); - - if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) != -1) { - mode_t m = umask(0177); - saddr.sun_family = AF_UNIX; - - g_snprintf(saddr.sun_path, sizeof(saddr.sun_path), "%s" G_DIR_SEPARATOR_S "gaim_%s.%d", - g_get_tmp_dir(), g_get_user_name(), gaim_session); - /* Remove any stale socket on this session */ - unlink(saddr.sun_path); - if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)) != -1) - listen(fd, 100); - else { - char *tmp = g_locale_to_utf8(strerror(errno), -1, NULL, NULL, NULL); - *error = g_strdup_printf(_("Failed to assign %s to a socket:\n%s"), - saddr.sun_path, tmp); - g_log(NULL, G_LOG_LEVEL_CRITICAL, - "Failed to assign %s to a socket (Error: %s)", - saddr.sun_path, strerror(errno)); - umask(m); - g_free(tmp); - return -1; - } - umask(m); - } else - g_log(NULL, G_LOG_LEVEL_CRITICAL, "Unable to open socket: %s", strerror(errno)); - return fd; -} -#endif /*! _WIN32*/ - -static gboolean -plugin_load(GaimPlugin *plugin) -{ -#ifndef _WIN32 - GIOChannel *channel; - char *buf = NULL; - - if ((UI_fd = open_socket(&buf)) < 0) { - gaim_notify_error(NULL, NULL, _("Unable to open socket"), buf); - g_free(buf); - return FALSE; - } - - channel = g_io_channel_unix_new(UI_fd); - watcher = g_io_add_watch(channel, G_IO_IN, socket_readable, NULL); - g_io_channel_unref(channel); - - return TRUE; -#else - return FALSE; -#endif -} - -static gboolean -plugin_unload(GaimPlugin *plugin) -{ - /* don't save prefs after plugins are gone... */ -#ifndef _WIN32 - char buf[1024]; - - g_source_remove(watcher); - close(UI_fd); - - g_snprintf(buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S "gaim_%s.%d", - g_get_tmp_dir(), g_get_user_name(), gaim_session); - - g_unlink(buf); - - gaim_debug_misc("core", "Removed core\n"); - - return TRUE; -#else - return FALSE; -#endif -} - -static GaimPluginInfo info = -{ - GAIM_PLUGIN_MAGIC, - GAIM_MAJOR_VERSION, - GAIM_MINOR_VERSION, - GAIM_PLUGIN_STANDARD, /**< type */ - GAIM_GTK_PLUGIN_TYPE, /**< ui_requirement */ - 0, /**< flags */ - NULL, /**< dependencies */ - GAIM_PRIORITY_DEFAULT, /**< priority */ - - REMOTE_PLUGIN_ID, /**< id */ - N_("Remote Control"), /**< name */ - VERSION, /**< version */ - /** summary */ - N_("Provides remote control for gaim applications."), - /** description */ - N_("Gives Gaim the ability to be remote-controlled through third-party " - "applications or through the gaim-remote tool."), - "Sean Egan ", - GAIM_WEBSITE, /**< homepage */ - - plugin_load, /**< load */ - plugin_unload, /**< unload */ - NULL, /**< destroy */ - - NULL, /**< ui_info */ - NULL, /**< extra_info */ - NULL, - NULL -}; - -static void -_init_plugin(GaimPlugin *plugin) -{ -} - -/* This may be horribly wrong. Oh the mayhem! */ -GAIM_INIT_PLUGIN(remote, _init_plugin, info) diff -r 677a3862260f -r a6d446cf090f plugins/gaim-remote/remote.h --- a/plugins/gaim-remote/remote.h Thu Sep 01 03:30:18 2005 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +0,0 @@ -/* - * Remote control plugin for Gaim - * - * Copyright (C) 2003 Christian Hammond. - * Copyright (C) 1998-1999, Mark Spencer - * - * 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 _GAIM_REMOTE_H_ -#define _GAIM_REMOTE_H_ - -#include - - -/* this is the basis of the CUI protocol. */ -#define CUI_TYPE_META 1 -#define CUI_TYPE_PLUGIN 2 -#define CUI_TYPE_USER 3 -#define CUI_TYPE_CONN 4 -#define CUI_TYPE_BUDDY 5 /* BUDDY_LIST, i.e., both groups and buddies */ -#define CUI_TYPE_MESSAGE 6 -#define CUI_TYPE_CHAT 7 -#define CUI_TYPE_REMOTE 8 - /* This is used to send commands to other UI's, - * like "Open new conversation" or "send IM". - * Even though there's much redundancy with the - * other CUI_TYPES, we're better keeping this stuff - * separate because it's intended use is so different */ - -#define CUI_META_LIST 1 - /* 1 is always list; this is ignored by the core. - If we move to TCP this can be a keepalive */ -#define CUI_META_QUIT 2 -#define CUI_META_DETACH 3 - /* you don't need to send this, you can just close - the socket. the core will understand. */ -#define CUI_META_PING 4 -#define CUI_META_ACK 5 - -#define CUI_PLUGIN_LIST 1 -#define CUI_PLUGIN_LOAD 2 -#define CUI_PLUGIN_UNLOAD 3 - -#define CUI_USER_LIST 1 -#define CUI_USER_ADD 2 -#define CUI_USER_REMOVE 3 -#define CUI_USER_MODIFY 4 /* this handles moving them in the list too */ -#define CUI_USER_SIGNON 5 -#define CUI_USER_AWAY 6 -#define CUI_USER_BACK 7 -#define CUI_USER_LOGOUT 8 - -#define CUI_CONN_LIST 1 -#define CUI_CONN_PROGRESS 2 -#define CUI_CONN_ONLINE 3 -#define CUI_CONN_OFFLINE 4 /* this may send a "reason" for why it was killed */ - -#define CUI_BUDDY_LIST 1 -#define CUI_BUDDY_STATE 2 - /* notifies the UI of state changes; UI can use it to - request the current status from the core */ -#define CUI_BUDDY_ADD 3 -#define CUI_BUDDY_REMOVE 4 -#define CUI_BUDDY_MODIFY 5 - -#define CUI_MESSAGE_LIST 1 /* no idea */ -#define CUI_MESSAGE_SEND 2 -#define CUI_MESSAGE_RECV 3 - -#define CUI_CHAT_LIST 1 -#define CUI_CHAT_HISTORY 2 /* is this necessary? should we have one for IMs? */ -#define CUI_CHAT_JOIN 3 /* handles other people joining/parting too */ -#define CUI_CHAT_PART 4 -#define CUI_CHAT_SEND 5 -#define CUI_CHAT_RECV 6 - -#define CUI_REMOTE_CONNECTIONS 2 /* Get a list of gaim_connections */ -#define CUI_REMOTE_URI 3 /* Have the core handle aim:// URI's */ -#define CUI_REMOTE_BLIST 4 /* Return a copy of the buddy list */ -#define CUI_REMOTE_STATE 5 /* Given a buddy, return his presence. */ -#define CUI_REMOTE_NEW_CONVO 6 /* Must give a user, can give an optional message */ -#define CUI_REMOTE_SEND 7 /* Sends a message, a 'quiet' flag determines whether - * a convo window is displayed or not. */ -#define CUI_REMOTE_ADD_BUDDY 8 /* Adds buddy to list */ -#define CUI_REMOTE_REMOVE_BUDDY 9 /* Removes buddy from list */ -#define CUI_REMOTE_JOIN_CHAT 10 /* Joins a chat. */ - /* What else?? */ - -#endif /* _GAIM_REMOTE_H_ */ diff -r 677a3862260f -r a6d446cf090f src/.cvsignore --- a/src/.cvsignore Thu Sep 01 03:30:18 2005 +0000 +++ b/src/.cvsignore Thu Sep 01 03:32:52 2005 +0000 @@ -2,8 +2,7 @@ Makefile .deps .libs -gaim -gaim-remote +gaim gaim.def gaim.lib gaim.dll diff -r 677a3862260f -r a6d446cf090f src/Makefile.am --- a/src/Makefile.am Thu Sep 01 03:30:18 2005 +0000 +++ b/src/Makefile.am Thu Sep 01 03:32:52 2005 +0000 @@ -201,7 +201,7 @@ gaim_client_example_SOURCES = gaim-client-example.c -gaim_client_example_DEPENDENCIES = @LIBOBJS@ libgaim-client.la +gaim_client_example_DEPENDENCIES = @LIBOBJS@ libgaim-client.la gaim_client_example_LDADD = \ @LIBOBJS@ \ @@ -211,7 +211,7 @@ gaim_clientbP = gaim-client-example -gaim-client-example.$(OBJEXT): gaim-client-bindings.h +gaim-client-example.$(OBJEXT): gaim-client-bindings.h # scripts @@ -232,7 +232,7 @@ endif -bin_PROGRAMS = gaim gaim-remote $(gaim_clientbP) +bin_PROGRAMS = gaim $(gaim_clientbP) gaim_SOURCES = \ $(gaim_coresources) \ @@ -333,16 +333,6 @@ $(GTKSPELL_LIBS) \ $(STARTUP_NOTIFICATION_LIBS) -gaim_remote_SOURCES = \ - gaim-remote.c \ - prefix.c \ - prefix.h - -gaim_remote_DEPENDENCIES = @LIBOBJS@ -gaim_remote_LDADD = \ - @LIBOBJS@ $(GLIB_LIBS) $(INTLLIBS) \ - $(top_builddir)/plugins/gaim-remote/libgaim-remote.la - AM_CPPFLAGS = \ -DBR_PTHREADS=0 \ -DDATADIR=\"$(datadir)\" \ diff -r 677a3862260f -r a6d446cf090f src/gaim-remote.c --- a/src/gaim-remote.c Thu Sep 01 03:30:18 2005 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,399 +0,0 @@ -/* - * gaim-remote - * - * Gaim is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * 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 - * - */ - -#include "internal.h" - -#include - -#include - -/* To be implemented: - " info Show information about connected accounts\n" - " list Print buddy list\n" - " ison Show presence state of your buddy\n" - " convo Open a new conversation window\n" - " add Add buddy to buddy list\n" - " remove Remove buddy from list\n" - " -q, --quiet Send message without showing a conversation\n" - " window\n" -*/ - -static struct option longopts[] = { - {"message", required_argument, NULL, 'm'}, - {"to", required_argument, NULL, 't'}, - {"protocol",required_argument, NULL, 'p'}, - {"from", required_argument, NULL, 'f'}, - {"session", required_argument, NULL, 's'}, - {"quiet", no_argument, NULL, 'q'}, - {"help", no_argument, NULL, 'h'}, - {0,0,0,0} -}; - -struct remoteopts { - char *command; - char *uri; - gboolean help, quiet; - char *message, *to, *from, *protocol, *session; - /*int protocol;*/ -}; -struct remoteopts opts; - -/* - * Prints a message to the terminal/shell/console. - * We try to convert "text" from UTF-8 to the user's locale. - * If that fails then UTF-8 is used as a fallback. - * - * If channel is 1, the message is printed to stdout. - * if channel is 2, the message is printed to stderr. - */ -static void -message(char *text, int channel) -{ - char *text_conv = NULL,*text_output; - GError *error = NULL; - - text_conv = g_locale_from_utf8(text, -1, NULL, NULL, &error); - - if (text_conv == NULL) { - g_warning("%s\n", error->message); - g_error_free(error); - } - - text_output = (text_conv ? text_conv : text); - - switch (channel) { - case 1: - puts(text_output); - break; - case 2: - fputs(text_output, stderr); - break; - default: - break; - } - - if (text_conv) - g_free(text_conv); -} - -static void -show_remote_usage(const char *name) -{ - char *text = NULL; - - text = g_strdup_printf(_("Usage: %s command [OPTIONS] [URI]\n\n" - " COMMANDS:\n" - " send Send message\n" - " uri Handle AIM: URI\n" - " away Popup the away dialog with the default message\n" - " back Remove the away dialog\n" - " logout Log out all accounts\n" - " quit Close running copy of Gaim\n" - "\n" - " OPTIONS:\n" - " -m, --message=MESG Message to send or show in conversation window\n" - " -t, --to=SCREENNAME Select a target for command\n" - " -p, --protocol=PROTO Specify protocol to use\n" - " -f, --from=SCREENNAME Specify screen name to use\n" - " -s, --session=SESSION Specify which Gaim session to use\n" - " -h, --help [command] Show help for command\n"), name); - - message(text, 1); - g_free(text); - - return; -} - -int -get_options(int argc, char *argv[]) -{ - int i; - - memset(&opts, 0, sizeof(opts)); - /*opts.protocol = -1;*/ - - while ((i=getopt_long(argc, argv, "m:t:p:f:s:qh", longopts, NULL)) != -1) { - switch (i) { - case 'm': - opts.message = optarg; - break; - case 't': - opts.to = optarg; - break; - case 'p': - opts.protocol = optarg; - break; - case 'f': - opts.from = optarg; - break; - case 's': - opts.session = optarg; - break; - case 'q': - opts.quiet = TRUE; - break; - case 'h': - opts.help = TRUE; - break; - } - } - - /* We must have non getopt'ed argument-- the command */ - if (optind < argc) - opts.command = g_strdup(argv[optind++]); - else - return 1; - - if (opts.help) - return 0; - - /* And we can have another argument--the URI. */ - /* but only if we're using the uri command. */ - if (!strcmp(opts.command, "uri")) { - if (argc-optind == 1) - opts.uri = g_strdup(argv[optind++]); - else - return 1; - } else if (optind == argc) - return 0; - else - return 1; - - return 0; -} - -static int -open_session() { - int fd = 0, session = 0; - char *msg; - - if (opts.session != NULL) - session = atoi(opts.session); - - fd = gaim_remote_session_connect(session); - if (fd < 0) { - msg = g_strdup_printf(_("Gaim not running (on session %d)\nIs the \"Remote Control\" plugin loaded?\n"), session); - message(msg, 2); - g_free(msg); - return -1; - } - - return fd; -} - -static int -send_generic_command(guchar type, guchar subtype) { - int fd = 0; - GaimRemotePacket *p = NULL; - - fd = open_session(); - if (fd < 0) { - return 1; - } - p = gaim_remote_packet_new(type, subtype); - gaim_remote_session_send_packet(fd, p); - close(fd); - gaim_remote_packet_free(p); - - return 0; -} - -static int -send_command_uri() { - int fd = 0; - GaimRemotePacket *p = NULL; - - fd = open_session(); - if (fd < 0) { - return 1; - } - p = gaim_remote_packet_new(CUI_TYPE_REMOTE, CUI_REMOTE_URI); - gaim_remote_packet_append_string(p, opts.uri); - gaim_remote_session_send_packet(fd, p); - close(fd); - gaim_remote_packet_free(p); - - return 0; -} - -static int -send_command_send() { - int fd = 0; - GaimRemotePacket *p = NULL; - char temp[10003]; /* TODO: Future implementation should send packets instead */ - - fd = open_session(); - if (fd < 0) { - return 1; - } - p = gaim_remote_packet_new(CUI_TYPE_REMOTE, CUI_REMOTE_SEND); - - /* - * Format is as follows: - * Each string has a 4 character 'header' containing the length of the string - * The strings are: To, From, Protocol name, Message - * Following the message is the quiet flag, expressed in a single int (0/1) - * Because the header is 4 characters long, there is a 9999 char limit on any - * given string, though none of these strings should be exceeding this. - * -JBS - */ - - if (opts.to && *opts.to && opts.from && *opts.from && - opts.protocol && *opts.protocol && opts.message && *opts.message && - (strlen(opts.to) < 10000) && (strlen(opts.from) < 10000) && - (strlen(opts.protocol) < 20) && (strlen(opts.message) < 10000) ) - { - sprintf(temp, "%04zd%s", strlen(opts.to), opts.to); - gaim_remote_packet_append_string(p, temp); - sprintf(temp, "%04zd%s", strlen(opts.from), opts.from); - gaim_remote_packet_append_string(p, temp); - sprintf(temp, "%04zd%s", strlen(opts.protocol), opts.protocol); - gaim_remote_packet_append_string(p, temp); - sprintf(temp, "%04zd%s", strlen(opts.message), opts.message); - gaim_remote_packet_append_string(p, temp); - sprintf(temp, "%d", 0); /* quiet flag - off for now */ - gaim_remote_packet_append_string(p, temp); - - gaim_remote_session_send_packet (fd, p); - close(fd); - gaim_remote_packet_free(p); - return 0; - } else { - message(_("Insufficient arguments (-t, -f, -p, & -m are all required) or arguments greater than 9999 chars\n"), 2); - close(fd); - gaim_remote_packet_free(p); - return 1; - } -} - -static void -show_longhelp( char *name, char *command) -{ - if (!strcmp(command, "uri")) { - message(_("\n" - "Using AIM: URIs:\n" - "Sending an IM to a screen name:\n" - " gaim-remote uri 'aim:goim?screenname=Penguin&message=hello+world'\n" - "In this case, 'Penguin' is the screen name we wish to IM, and 'hello world'\n" - "is the message to be sent. '+' must be used in place of spaces.\n" - "Please note the quoting used above - if you run this from a shell the '&'\n" - "needs to be escaped, or the command will stop at that point.\n" - "Also,the following will just open a conversation window to a screen name,\n" - "with no message:\n" - " gaim-remote uri 'aim:goim?screenname=Penguin'\n\n" - "Joining a chat:\n" - " gaim-remote uri 'aim:gochat?roomname=PenguinLounge'\n" - "...joins the 'PenguinLounge' chat room.\n\n" - "Adding a buddy to your buddy list:\n" - " gaim-remote uri 'aim:addbuddy?screenname=Penguin'\n" - "...prompts you to add 'Penguin' to your buddy list.\n"), 1); - } - - else if (!strcmp(command, "logout")) { - message(_("\nLog out all accounts\n"), 1); - } - - else if (!strcmp(command, "quit")) { - message(_("\nClose running copy of Gaim\n"), 1); - } - - else if (!strcmp(command, "away")) { - message(_("\nMark all accounts as \"away\" with the default message.\n"), 1); - } - - else if (!strcmp(command, "back")) { - message(_("\nSet all accounts as not away.\n"), 1); - } - - else if (!strcmp(command, "send")) { - message(_("\nSend instant message\n"), 1); - } - - else { - show_remote_usage(name); - } -} - -int main(int argc, char *argv[]) -{ -#ifdef ENABLE_NLS - setlocale (LC_ALL, ""); - bindtextdomain(PACKAGE, LOCALEDIR); - bind_textdomain_codeset(PACKAGE, "UTF-8"); - textdomain(PACKAGE); -#endif - - if (get_options(argc, argv)) { - show_remote_usage(argv[0]); - return 0; - } - - if (!strcmp(opts.command, "uri")) { - if (opts.help) - show_longhelp(argv[0], "uri"); - else - return send_command_uri(); - } - - else if (!strcmp(opts.command, "send")) { - if (opts.help) - show_longhelp(argv[0], "send"); - else - return send_command_send(); - } - - else if (!strcmp(opts.command, "away")) { - if (opts.help) - show_longhelp(argv[0], "away"); - else - return send_generic_command(CUI_TYPE_USER, CUI_USER_AWAY); - } - - else if (!strcmp(opts.command, "back")) { - if (opts.help) - show_longhelp(argv[0], "back"); - else - return send_generic_command(CUI_TYPE_USER, CUI_USER_BACK); - } - - else if (!strcmp(opts.command, "logout")) { - if (opts.help) - show_longhelp(argv[0], "logout"); - else - return send_generic_command(CUI_TYPE_USER, CUI_USER_LOGOUT); - } - - else if (!strcmp(opts.command, "quit")) { - if (opts.help) - show_longhelp(argv[0], "quit"); - else - return send_generic_command(CUI_TYPE_META, CUI_META_QUIT); - } - - else { - show_remote_usage(argv[0]); - return 1; - } - - return 0; -}