Index: src/protocols/silc/.cvsignore
===================================================================
RCS file: /cvsroot/gaim/gaim/src/protocols/silc/.cvsignore,v
retrieving revision 1.1
diff -u -p -u -r1.1 .cvsignore
--- src/protocols/silc/.cvsignore 1 May 2004 19:34:44 -0000 1.1
+++ src/protocols/silc/.cvsignore 21 Jun 2004 19:59:16 -0000
@@ -1,6 +1,9 @@
*.lo
*.la
+*.lib
+*.dll
.libs
.deps
Makefile
Makefile.in
+Makefile.mingw
Index: src/protocols/silc/Makefile.am
===================================================================
RCS file: /cvsroot/gaim/gaim/src/protocols/silc/Makefile.am,v
retrieving revision 1.3
diff -u -p -u -r1.3 Makefile.am
--- src/protocols/silc/Makefile.am 25 May 2004 17:52:08 -0000 1.3
+++ src/protocols/silc/Makefile.am 21 Jun 2004 19:59:16 -0000
@@ -1,4 +1,4 @@
-EXTRA_DIST = README TODO
+EXTRA_DIST = README TODO Makefile.mingw
pkgdir = $(libdir)/gaim
Index: src/protocols/silc/chat.c
===================================================================
RCS file: /cvsroot/gaim/gaim/src/protocols/silc/chat.c,v
retrieving revision 1.10
diff -u -p -u -r1.10 chat.c
--- src/protocols/silc/chat.c 15 Jun 2004 21:59:04 -0000 1.10
+++ src/protocols/silc/chat.c 21 Jun 2004 19:59:17 -0000
@@ -1003,6 +1003,9 @@ void silcgaim_chat_join_done(SilcClient
/* Set topic */
if (channel->topic)
gaim_conv_chat_set_topic(GAIM_CONV_CHAT(convo), NULL, channel->topic);
+
+ /* Set nick */
+ gaim_conv_chat_set_nick(GAIM_CONV_CHAT(convo), conn->local_entry->nickname);
}
void silcgaim_chat_join(GaimConnection *gc, GHashTable *data)
@@ -1130,7 +1133,7 @@ void silcgaim_chat_invite(GaimConnection
/* Call INVITE */
silc_client_command_call(client, conn, NULL, "INVITE",
chu->channel->channel_name,
- name);
+ name, NULL);
}
void silcgaim_chat_leave(GaimConnection *gc, int id)
@@ -1213,21 +1216,31 @@ int silcgaim_chat_send(GaimConnection *g
SilcChannelPrivateKey key = NULL;
SilcUInt32 flags;
int ret;
+ const char *msg2;
gboolean found = FALSE;
gboolean sign = gaim_prefs_get_bool("/plugins/prpl/silc/sign_chat");
if (!msg || !conn)
return 0;
- /* See if command */
- if (strlen(msg) > 1 && msg[0] == '/') {
+ flags = SILC_MESSAGE_FLAG_UTF8;
+
+ msg2 = msg;
+
+ if (!g_ascii_strncasecmp(msg2, "/me ", 4))
+ {
+ msg2 += 4;
+ if (!msg2)
+ return 0;
+ flags |= SILC_MESSAGE_FLAG_ACTION;
+ } else if (strlen(msg) > 1 && msg[0] == '/') {
if (!silc_client_command_call(client, conn, msg + 1))
gaim_notify_error(gc, ("Call Command"), _("Cannot call command"),
- _("Unknown command"));
+ _("Unknown command"));
return 0;
}
- flags = SILC_MESSAGE_FLAG_UTF8;
+
if (sign)
flags |= SILC_MESSAGE_FLAG_SIGNED;
@@ -1267,8 +1280,8 @@ int silcgaim_chat_send(GaimConnection *g
/* Send channel message */
ret = silc_client_send_channel_message(client, conn, channel, key,
- flags, (unsigned char *)msg,
- strlen(msg), TRUE);
+ flags, (unsigned char *)msg2,
+ strlen(msg2), TRUE);
if (ret)
serv_got_chat_in(gc, id, gaim_connection_get_display_name(gc), 0, msg,
time(NULL));
@@ -1285,7 +1298,7 @@ void silcgaim_chat_set_topic(GaimConnect
SilcChannelUser chu;
gboolean found = FALSE;
- if (!topic || !conn)
+ if (!conn)
return;
/* See if setting topic on private group. Set it
Index: src/protocols/silc/ft.c
===================================================================
RCS file: /cvsroot/gaim/gaim/src/protocols/silc/ft.c,v
retrieving revision 1.2
diff -u -p -u -r1.2 ft.c
--- src/protocols/silc/ft.c 9 May 2004 04:06:58 -0000 1.2
+++ src/protocols/silc/ft.c 21 Jun 2004 19:59:17 -0000
@@ -365,7 +365,7 @@ void silcgaim_ftp_send_file(GaimConnecti
if (!silc_parse_userfqdn(name, &nickname, NULL))
return;
-#if 1
+#ifndef _WIN32
silc_debug = TRUE;
silc_log_set_debug_string("*client*,*ftp*");
#endif
Index: src/protocols/silc/ops.c
===================================================================
RCS file: /cvsroot/gaim/gaim/src/protocols/silc/ops.c,v
retrieving revision 1.6
diff -u -p -u -r1.6 ops.c
--- src/protocols/silc/ops.c 12 Jun 2004 18:36:05 -0000 1.6
+++ src/protocols/silc/ops.c 21 Jun 2004 19:59:18 -0000
@@ -85,16 +85,16 @@ silc_channel_message(SilcClient client,
}
if (flags & SILC_MESSAGE_FLAG_ACTION) {
- msg = g_strdup_printf("%s %s",
- sender->nickname ?
- sender->nickname : "",
+ msg = g_strdup_printf("/me %s",
(const char *)message);
if (!msg)
return;
/* Send to Gaim */
- gaim_conversation_write(convo, NULL, (const char *)msg,
- GAIM_MESSAGE_SYSTEM, time(NULL));
+ serv_got_chat_in(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(convo)),
+ sender->nickname ?
+ sender->nickname : "", 0,
+ msg, time(NULL));
g_free(msg);
return;
}
@@ -157,16 +157,15 @@ silc_private_message(SilcClient client,
}
if (flags & SILC_MESSAGE_FLAG_ACTION && convo) {
- msg = g_strdup_printf("%s %s",
- sender->nickname ?
- sender->nickname : "",
+ msg = g_strdup_printf("/me %s",
(const char *)message);
if (!msg)
return;
/* Send to Gaim */
- gaim_conversation_write(convo, NULL, (const char *)msg,
- GAIM_MESSAGE_SYSTEM, time(NULL));
+ serv_got_im(gc, sender->nickname ?
+ sender->nickname : "",
+ msg, 0, time(NULL));
g_free(msg);
return;
}
@@ -241,8 +240,8 @@ silc_notify(SilcClient client, SilcClien
client_entry = va_arg(va, SilcClientEntry);
components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
- g_hash_table_insert(components, strdup("channel"), name);
- serv_got_chat_invite(gc, name, client_entry->nickname, NULL, NULL);
+ g_hash_table_insert(components, strdup("channel"), strdup(name));
+ serv_got_chat_invite(gc, name, client_entry->nickname, NULL, components);
}
break;
@@ -471,7 +470,7 @@ silc_notify(SilcClient client, SilcClien
/* Remove user from channel */
g_snprintf(buf, sizeof(buf), ("Kicked by %s (%s)"),
client_entry2->nickname, tmp ? tmp : "");
- gaim_conv_chat_rename_user(GAIM_CONV_CHAT(convo),
+ gaim_conv_chat_remove_user(GAIM_CONV_CHAT(convo),
client_entry->nickname,
buf);
}
@@ -698,6 +697,7 @@ silc_notify(SilcClient client, SilcClien
break;
default:
+ gaim_debug_info("silc", "Unhandled notification: %d\n", type);
break;
}
@@ -1023,8 +1023,17 @@ silc_command_reply(SilcClient client, Si
convo = gaim_find_conversation_with_account(channel->channel_name,
sg->account);
- if (!convo)
+ if (!convo) {
+ gaim_debug_error("silc", "Got a topic for %s, which doesn't exist\n",
+ channel->channel_name);
break;
+ }
+
+ if (gaim_conversation_get_type(convo) != GAIM_CONV_CHAT) {
+ gaim_debug_error("silc", "Got a topic for %s, which isn't a chat\n",
+ channel->channel_name);
+ break;
+ }
/* Set topic */
if (channel->topic)
@@ -1032,6 +1041,40 @@ silc_command_reply(SilcClient client, Si
}
break;
+ case SILC_COMMAND_NICK:
+ {
+ /* I don't think we should need to do this because the server should
+ * be sending a SILC_NOTIFY_TYPE_NICK_CHANGE when we change our own
+ * nick, but it isn't, so we deal with it here instead. Stu. */
+ SilcClientEntry local_entry;
+ SilcHashTableList htl;
+ SilcChannelUser chu;
+ const char *oldnick;
+
+ if (!success) {
+ return;
+ }
+
+ local_entry = va_arg(vp, SilcClientEntry);
+
+ /* Change nick on all channels */
+ silc_hash_table_list(local_entry->channels, &htl);
+ while (silc_hash_table_get(&htl, NULL, (void *)&chu)) {
+ convo = gaim_find_conversation_with_account(chu->channel->channel_name,
+ sg->account);
+ if (!convo || (gaim_conversation_get_type(convo) != GAIM_CONV_CHAT))
+ continue;
+ oldnick = gaim_conv_chat_get_nick(GAIM_CONV_CHAT(convo));
+ if (strcmp(oldnick, local_entry->nickname)) {
+ gaim_conv_chat_rename_user(GAIM_CONV_CHAT(convo),
+ oldnick, local_entry->nickname);
+ gaim_conv_chat_set_nick(GAIM_CONV_CHAT(convo), local_entry->nickname);
+ }
+ }
+ silc_hash_table_list_reset(&htl);
+ }
+ break;
+
case SILC_COMMAND_LIST:
{
char *topic, *name;
@@ -1100,7 +1143,7 @@ silc_command_reply(SilcClient client, Si
SilcServerEntry server_entry;
char *server_name;
char *server_info;
- char tmp[256];
+ char tmp[256], *msg;
if (!success) {
gaim_notify_error(gc, _("Server Information"),
@@ -1116,8 +1159,10 @@ silc_command_reply(SilcClient client, Si
if (server_name && server_info) {
g_snprintf(tmp, sizeof(tmp), "Server: %s\n%s",
server_name, server_info);
+ msg = g_markup_escape_text(tmp, strlen(tmp));
gaim_notify_info(NULL, _("Server Information"),
- _("Server Information"), tmp);
+ _("Server Information"), msg);
+ g_free(msg);
}
}
break;
@@ -1150,6 +1195,11 @@ silc_command_reply(SilcClient client, Si
break;
default:
+ if (success)
+ gaim_debug_info("silc", "Unhandled command: %d (succeeded)\n", command);
+ else
+ gaim_debug_info("silc", "Unhandled command: %d (failed: %s)\n", command,
+ silc_get_status_message(status));
break;
}
Index: src/protocols/silc/silc.c
===================================================================
RCS file: /cvsroot/gaim/gaim/src/protocols/silc/silc.c,v
retrieving revision 1.14
diff -u -p -u -r1.14 silc.c
--- src/protocols/silc/silc.c 19 Jun 2004 04:57:42 -0000 1.14
+++ src/protocols/silc/silc.c 21 Jun 2004 19:59:18 -0000
@@ -304,7 +304,11 @@ silcgaim_login(GaimAccount *account)
}
/* Schedule SILC using Glib's event loop */
+#ifndef _WIN32
sg->scheduler = g_timeout_add(5, (GSourceFunc)silcgaim_scheduler, sg);
+#else
+ sg->scheduler = g_timeout_add(300, (GSourceFunc)silcgaim_scheduler, sg);
+#endif
}
static int
@@ -336,7 +340,7 @@ silcgaim_close(GaimConnection *gc)
/* Send QUIT */
silc_client_command_call(sg->client, sg->conn, NULL,
- "QUIT", "Leaving", NULL);
+ "QUIT", "Download Gaim: " GAIM_WEBSITE, NULL);
if (sg->conn)
silc_client_close_connection(sg->client, sg->conn);
@@ -869,18 +873,24 @@ silcgaim_send_im(GaimConnection *gc, con
if (!who || !msg)
return 0;
- /* See if command */
- if (strlen(msg) > 1 && msg[0] == '/') {
+ mflags = SILC_MESSAGE_FLAG_UTF8;
+
+ if (!g_ascii_strncasecmp(msg, "/me ", 4)) {
+ msg += 4;
+ if (!msg)
+ return 0;
+ mflags |= SILC_MESSAGE_FLAG_ACTION;
+ } else if (strlen(msg) > 1 && msg[0] == '/') {
if (!silc_client_command_call(client, conn, msg + 1))
gaim_notify_error(gc, ("Call Command"), _("Cannot call command"),
- _("Unknown command"));
+ _("Unknown command"));
return 0;
}
+
if (!silc_parse_userfqdn(who, &nickname, NULL))
return 0;
- mflags = SILC_MESSAGE_FLAG_UTF8;
if (sign)
mflags |= SILC_MESSAGE_FLAG_SIGNED;
@@ -923,7 +933,7 @@ GList *silcgaim_blist_node_menu(GaimBlis
return silcgaim_buddy_menu((GaimBuddy *) node);
} else {
g_return_val_if_reached(NULL);
- }
+ }
}
/********************************* Commands **********************************/
@@ -932,12 +942,25 @@ static GaimCmdRet silcgaim_cmd_chat_part
const char *cmd, char **args, char **error)
{
GaimConnection *gc;
+ GaimConversation *convo;
int id = 0;
gc = gaim_conversation_get_gc(conv);
- id = gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv));
- if (gc == NULL || id == 0)
+ if (gc == NULL)
+ return GAIM_CMD_RET_FAILED;
+
+ if(args && args[0]) {
+ convo = gaim_find_conversation_with_account(args[0], gc->account);
+ } else
+ convo = conv;
+
+ if (gaim_conversation_get_type(convo) != GAIM_CONV_CHAT)
+ return GAIM_CMD_RET_FAILED;
+
+ id = gaim_conv_chat_get_id(GAIM_CONV_CHAT(convo));
+
+ if (id == 0)
return GAIM_CMD_RET_FAILED;
silcgaim_chat_leave(gc, id);
@@ -1092,9 +1115,8 @@ static GaimCmdRet silcgaim_cmd_motd(Gaim
return GAIM_CMD_RET_FAILED;
if (!sg->motd) {
- gaim_notify_error(
- gc, _("Message of the Day"), _("No Message of the Day available"),
- _("There is no Message of the Day associated with this connection"));
+ gaim_notify_error(gc, _("Message of the Day"), _("No Message of the Day available"),
+ _("There is no Message of the Day associated with this connection"));
return GAIM_CMD_RET_FAILED;
}
@@ -1126,11 +1148,12 @@ static GaimCmdRet silcgaim_cmd_detach(Ga
return GAIM_CMD_RET_OK;
}
-static GaimCmdRet silcgaim_cmd_umode(GaimConversation *conv,
+static GaimCmdRet silcgaim_cmd_generic(GaimConversation *conv,
const char *cmd, char **args, char **error)
{
GaimConnection *gc;
SilcGaim sg;
+ char *silccmd, *silcargs;
gc = gaim_conversation_get_gc(conv);
@@ -1142,8 +1165,14 @@ static GaimCmdRet silcgaim_cmd_umode(Gai
if (sg == NULL)
return GAIM_CMD_RET_FAILED;
- silc_client_command_call(sg->client, sg->conn, NULL, "UMODE",
- args[0], NULL);
+ silcargs = g_strjoinv(" ", args);
+ silccmd = g_strconcat(cmd, " ", args ? silcargs : NULL, NULL);
+ g_free(silcargs);
+ if (!silc_client_command_call(sg->client, sg->conn, silccmd)) {
+ g_free(silccmd);
+ return GAIM_CMD_RET_FAILED;
+ }
+ g_free(silccmd);
return GAIM_CMD_RET_OK;
}
@@ -1154,11 +1183,13 @@ static GaimCmdRet silcgaim_cmd_umode(Gai
static void
silcgaim_register_commands(void)
{
- gaim_cmd_register("part", "", GAIM_CMD_P_PRPL,
- GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
+ gaim_cmd_register("part", "w", GAIM_CMD_P_PRPL,
+ GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT |
+ GAIM_CMD_FLAG_PRPL_ONLY | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS,
"prpl-silc", silcgaim_cmd_chat_part, _("part: Leave the chat"));
- gaim_cmd_register("leave", "", GAIM_CMD_P_PRPL,
- GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
+ gaim_cmd_register("leave", "w", GAIM_CMD_P_PRPL,
+ GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT |
+ GAIM_CMD_FLAG_PRPL_ONLY | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS,
"prpl-silc", silcgaim_cmd_chat_part, _("leave: Leave the chat"));
gaim_cmd_register("topic", "s", GAIM_CMD_P_PRPL,
GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
@@ -1194,12 +1225,12 @@ silcgaim_register_commands(void)
GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_motd,
_("motd: View the server's Message Of The Day"));
gaim_cmd_register("detach", "", GAIM_CMD_P_PRPL,
- GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
- GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_detach,
+ GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
+ "prpl-silc", silcgaim_cmd_detach,
_("detach: Detach this session"));
gaim_cmd_register("umode", "w", GAIM_CMD_P_PRPL,
GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
- "prpl-silc", silcgaim_cmd_umode,
+ "prpl-silc", silcgaim_cmd_generic,
_("umode <usermodes>: Set your user options"));
}
@@ -1404,6 +1435,11 @@ init_plugin(GaimPlugin *plugin)
gaim_prefs_add_string("/plugins/prpl/silc/vcard", "");
silcgaim_register_commands();
+
+#ifdef _WIN32
+ silc_net_win32_init();
+#endif
+
}
GAIM_INIT_PLUGIN(silc, init_plugin, info);
Index: src/protocols/silc/silcgaim.h
===================================================================
RCS file: /cvsroot/gaim/gaim/src/protocols/silc/silcgaim.h,v
retrieving revision 1.4
diff -u -p -u -r1.4 silcgaim.h
--- src/protocols/silc/silcgaim.h 15 Jun 2004 04:37:12 -0000 1.4
+++ src/protocols/silc/silcgaim.h 21 Jun 2004 19:59:18 -0000
@@ -127,4 +127,22 @@ void silcgaim_roomlist_cancel(GaimRoomli
void silcgaim_chat_chauth_show(SilcGaim sg, SilcChannelEntry channel,
SilcBuffer channel_pubkeys);
+#ifdef _WIN32
+typedef int uid_t;
+
+struct passwd {
+ char *pw_name; /* user name */
+ char *pw_passwd; /* user password */
+ int pw_uid; /* user id */
+ int pw_gid; /* group id */
+ char *pw_gecos; /* real name */
+ char *pw_dir; /* home directory */
+ char *pw_shell; /* shell program */
+};
+
+struct passwd *getpwuid(int uid);
+int getuid();
+int geteuid();
+#endif
+
#endif /* SILCGAIM_H */
Index: src/protocols/silc/util.c
===================================================================
RCS file: /cvsroot/gaim/gaim/src/protocols/silc/util.c,v
retrieving revision 1.6
diff -u -p -u -r1.6 util.c
--- src/protocols/silc/util.c 13 Jun 2004 17:26:45 -0000 1.6
+++ src/protocols/silc/util.c 21 Jun 2004 19:59:18 -0000
@@ -80,7 +80,7 @@ gboolean silcgaim_check_silc_dir(GaimCon
return FALSE;
}
- g_snprintf(filename, sizeof(filename) - 1, "%s" G_DIR_SEPARATOR_S, silcgaim_silcdir());
+ g_snprintf(filename, sizeof(filename) - 1, "%s", silcgaim_silcdir());
g_snprintf(servfilename, sizeof(servfilename) - 1, "%s" G_DIR_SEPARATOR_S "serverkeys",
silcgaim_silcdir());
g_snprintf(clientfilename, sizeof(clientfilename) - 1, "%s" G_DIR_SEPARATOR_S "clientkeys",
@@ -109,12 +109,14 @@ gboolean silcgaim_check_silc_dir(GaimCon
return FALSE;
}
} else {
+#ifndef _WIN32
/* Check the owner of the dir */
if (st.st_uid != 0 && st.st_uid != pw->pw_uid) {
gaim_debug_error("silc", "You don't seem to own '%s' directory\n",
filename);
return FALSE;
}
+#endif
}
/*
@@ -211,11 +213,13 @@ gboolean silcgaim_check_silc_dir(GaimCon
}
}
+#ifndef _WIN32
/* Check the owner of the public key */
if (st.st_uid != 0 && st.st_uid != pw->pw_uid) {
gaim_debug_error("silc", "You don't seem to own your public key!?\n");
return FALSE;
}
+#endif
if ((stat(file_private_key, &st)) == -1) {
/* If file doesn't exist */
@@ -234,6 +238,7 @@ gboolean silcgaim_check_silc_dir(GaimCon
}
}
+#ifndef _WIN32
/* Check the owner of the private key */
if (st.st_uid != 0 && st.st_uid != pw->pw_uid) {
gaim_debug_error("silc", "You don't seem to own your private key!?\n");
@@ -252,10 +257,26 @@ gboolean silcgaim_check_silc_dir(GaimCon
}
gaim_debug_warning("silc", "Done.\n\n");
}
+#endif
return TRUE;
}
+#ifdef _WIN32
+struct passwd *getpwuid(uid_t uid) {
+ struct passwd *pwd = calloc(1, sizeof(struct passwd));
+ return pwd;
+}
+
+uid_t getuid() {
+ return 0;
+}
+
+uid_t geteuid() {
+ return 0;
+}
+#endif
+
void silcgaim_show_public_key(SilcGaim sg,
const char *name, SilcPublicKey public_key,
GCallback callback, void *context)