aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVMiklos <vmiklos@frugalware.org>2007-08-20 22:58:45 +0200
committerVMiklos <vmiklos@frugalware.org>2007-08-20 22:58:45 +0200
commit6627d926b16e5c4a92099d9ea896bd00b5b9a680 (patch)
tree5b816d817345a725fff86576d68e2e3e440360f8
parenta60c3c2bde4e3e4327f4a4815fee43c714da6298 (diff)
implement add/removing contacts
-rw-r--r--skype/README4
-rw-r--r--skype/skype.c23
2 files changed, 25 insertions, 2 deletions
diff --git a/skype/README b/skype/README
index ab4d0151..e55bd290 100644
--- a/skype/README
+++ b/skype/README
@@ -86,9 +86,11 @@ NOTE: the <pass> option is not used currently.
- Marking received messages as seen so that Skype won't say there are unread messages
+- Adding / removing contacts
+
== What needs to be done (aka. TODO)
-- add/remove users, detect when somebody wants to add us
+- detect when somebody wants to add us
- Due to some API limitations, I have no idea how to change status. This affects:
* When you `/away`, Skype will be still show `Online`
diff --git a/skype/skype.c b/skype/skype.c
index e0c3f22e..e0e5901a 100644
--- a/skype/skype.c
+++ b/skype/skype.c
@@ -108,7 +108,8 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c
status++;
ptr = strchr(++user, ' ');
*ptr = '\0';
- if(strcmp(user, sd->username) != 0 && strcmp(user, "echo123") != 0)
+ ptr++;
+ if(!strncmp(ptr, "ONLINESTATUS ", 13) && strcmp(user, sd->username) != 0 && strcmp(user, "echo123") != 0)
{
ptr = g_strdup_printf("%s@skype.com", user);
imcb_add_buddy(ic, ptr, NULL);
@@ -274,10 +275,30 @@ static GList *skype_away_states( struct im_connection *ic )
static void skype_add_buddy( struct im_connection *ic, char *who, char *group )
{
+ char *buf, *nick, *ptr;
+
+ nick = g_strdup_printf("%s", who);
+ ptr = strchr(nick, '@');
+ if(ptr)
+ *ptr = '\0';
+ buf = g_strdup_printf("SET USER %s BUDDYSTATUS 2 Please authorize me\n", nick);
+ skype_write( ic, buf, strlen( buf ) );
+ printf("add '%s'\n", nick);
+ g_free(nick);
}
static void skype_remove_buddy( struct im_connection *ic, char *who, char *group )
{
+ char *buf, *nick, *ptr;
+
+ nick = g_strdup_printf("%s", who);
+ ptr = strchr(nick, '@');
+ if(ptr)
+ *ptr = '\0';
+ buf = g_strdup_printf("SET USER %s BUDDYSTATUS 1\n", nick);
+ skype_write( ic, buf, strlen( buf ) );
+ printf("remove '%s'\n", nick);
+ g_free(nick);
}
void init_plugin(void)