diff options
| author | Miklos Vajna <vmiklos@frugalware.org> | 2010-12-13 03:22:20 +0100 | 
|---|---|---|
| committer | Miklos Vajna <vmiklos@frugalware.org> | 2010-12-13 03:22:20 +0100 | 
| commit | 71c4bb6362db328b9768b801109ffd006445a367 (patch) | |
| tree | 5a5b852fbc2d9e8e776e7091957fa2c7d97bdd56 | |
| parent | 77aa416f8ebf36ccdbbe5855ad3fbbfdf7b4724d (diff) | |
Adding /ctcp call|hangup support
| -rw-r--r-- | skype/README | 13 | ||||
| -rw-r--r-- | skype/skype.c | 83 | 
2 files changed, 72 insertions, 24 deletions
| diff --git a/skype/README b/skype/README index 7b7f12cb..13183d70 100644 --- a/skype/README +++ b/skype/README @@ -306,11 +306,16 @@ $ skyped -n -d  - Running Skype on a machine different to BitlBee is possible, the    communication is encrypted. -- Managing outgoing calls (with call duration at the end, including -  SkypeOut calls if you use a phone number instead of a nick): +- Managing outgoing calls (with call duration at the end): -  * `account skype set call nick` -  * `account skype set -del skype/call` +  * `/ctcp nick call` +  * `/ctcp nick hangup` + +- Managing outgoing SkypeOut or conference calls: + +  * `account skype set call +18005551234` +  * `account skype set call nick1 nick2` +  * `account skype set -del call`  - Managing incoming calls via questions, just like when you add / remove    contacts. diff --git a/skype/skype.c b/skype/skype.c index 86614fc6..b2b76ad8 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -1117,12 +1117,34 @@ static char *skype_set_balance(set_t *set, char *value)  	return value;  } +static void skype_call(struct im_connection *ic, char *value) { +	char *nick = g_strdup(value); +	char *ptr = strchr(nick, '@'); + +	if (ptr) +		*ptr = '\0'; +	skype_printf(ic, "CALL %s", nick); +	g_free(nick); +} + +static void skype_hangup(struct im_connection *ic) +{ +	struct skype_data *sd = ic->proto_data; + +	if (sd->call_id) { +		skype_printf(ic, "SET CALL %s STATUS FINISHED", +				sd->call_id); +		g_free(sd->call_id); +		sd->call_id = 0; +	} else +		imcb_error(ic, "There are no active calls currently."); +} +  static char *skype_set_call(set_t *set, char *value)  {  	account_t *acc = set->data;  	struct im_connection *ic = acc->ic; -	struct skype_data *sd = ic->proto_data; -	char *nick, *ptr; +	char *nick;  	if (value) {  #if BITLBEE_VERSION_CODE < BITLBEE_VER(1, 3, 0) @@ -1130,26 +1152,13 @@ static char *skype_set_call(set_t *set, char *value)  		user_t *u = user_find(acc->irc, value);  		/* We are starting a call */  		if (u) -			nick = g_strdup(u->handle); +			nick = u->handle;  		else  #endif -			nick = g_strdup(value); -		ptr = strchr(nick, '@'); -		if (ptr) -			*ptr = '\0'; - -		skype_printf(ic, "CALL %s", nick); -		g_free(nick); -	} else { -		/* We are ending a call */ -		if (sd->call_id) { -			skype_printf(ic, "SET CALL %s STATUS FINISHED", -				sd->call_id); -			g_free(sd->call_id); -			sd->call_id = NULL; -		} else -			imcb_error(ic, "There are no active calls currently."); -	} +			nick = value; +		skype_call(ic, nick); +	} else +		skype_hangup(ic);  	return value;  } @@ -1313,6 +1322,36 @@ static void skype_init(account_t *acc)  			NULL, acc);  } +#if BITLBEE_VERSION_CODE >= BITLBEE_VER(3, 0, 1) +GList *skype_buddy_action_list( bee_user_t *bu ) +{ +	static GList *ret = NULL; + +	if (ret == NULL) +	{ +		static const struct buddy_action ba[3] = { +			{"CALL", "Initiate a call" }, +			{"HANGUP", "Hang up a call" }, +		}; + +		ret = g_list_prepend(ret, (void*) ba + 0); +	} + +	return ret; +} + +void *skype_buddy_action( struct bee_user *bu, const char *action, char * const args[], void *data ) +{ +	if (!g_strcasecmp(action, "CALL")) { +		skype_call(bu->ic, bu->handle); +	} else if (!g_strcasecmp(action, "HANGUP")) { +		skype_hangup(bu->ic); +	} + +	return NULL; +} +#endif +  void init_plugin(void)  {  	struct prpl *ret = g_new0(struct prpl, 1); @@ -1334,5 +1373,9 @@ void init_plugin(void)  	ret->chat_with = skype_chat_with;  	ret->handle_cmp = g_strcasecmp;  	ret->chat_topic = skype_chat_topic; +#if BITLBEE_VERSION_CODE >= BITLBEE_VER(3, 0, 1) +	ret->buddy_action_list = skype_buddy_action_list; +	ret->buddy_action = skype_buddy_action; +#endif  	register_protocol(ret);  } | 
