Пример #1
0
static VALUE send_im(VALUE self, VALUE name, VALUE message)
{
  PurpleAccount *account;
  Data_Get_Struct(self, PurpleAccount, account);
  
  if (purple_account_is_connected(account)) {
    int i = serv_send_im(purple_account_get_connection(account), RSTRING_PTR(name), RSTRING_PTR(message), 0);
    return INT2FIX(i);
  } else {
    return Qnil;
  }
}
Пример #2
0
void amsg(IrcCommandDll *intp, char *command, char *args, char *subargs, char *helparg) {
	char *nick,*nnick,*loc;
	
	CHECK_TOC_ONLINE();
	
	/* loc = msg, nick = username to send msg to */
	loc = LOCAL_COPY(args);
	nick = new_next_arg(loc, &loc);
	
	REQUIRED_ARG(nick,command,helparg);
	
	if ( nick[0] == '#' ) {
		struct buddy_chat *b;
		nick++;
		REQUIRED_ARG(nick,command,helparg);
		b = (struct buddy_chat *) find_buddy_chat(nick);
		if ( ! b ) {
			statusprintf("Error not on buddy chat %s", nick);
			return;
		}
		/* chatprintf("sent msg %s to buddy chat %s",loc,nick); */
		serv_chat_send(b->id,loc);
	} else {
		char *ruser,*rnick;
		nnick = (char *) malloc(strlen(nick)+10);
		rnick = rm_space(nick);
		ruser = rm_space(get_dllstring_var("aim_user"));
		sprintf(nnick,"%s@AIM",rnick);
		msgprintf("%s", cparse(fget_string_var(FORMAT_SEND_MSG_FSET), 
			"%s %s %s %s",update_clock(GET_TIME), 
			nnick, ruser, loc));
		serv_send_im(nick,loc);
		RemoveFromLLByKey(msgdthem,rnick);
		AddToLL(msgdthem,rnick,NULL);
#ifdef BITCHX_PATCH
		tks.list = 0;
		tks.pos = -1;
#endif		
		free(rnick); free(ruser);
	}	
	
	debug_printf("sending msg to %s '%s'",nick,loc);	
	return;
}
Пример #3
0
void
translate_sending_message_cb(const gchar *original_phrase, const gchar *translated_phrase, const gchar *detected_language, gpointer userdata)
{
	struct TranslateConvMessage *convmsg = userdata;
	gchar *html_text;
	int err = 0;
	
	html_text = purple_strdup_withhtml(translated_phrase);
	err = serv_send_im(purple_account_get_connection(convmsg->account), convmsg->sender, html_text, convmsg->flags);
	g_free(html_text);
	
	html_text = purple_strdup_withhtml(original_phrase);
	if (err > 0)
	{
		purple_conversation_write(convmsg->conv, convmsg->sender, html_text, convmsg->flags, time(NULL));
	}
	
	purple_signal_emit(purple_conversations_get_handle(), "sent-im-msg",
						convmsg->account, convmsg->sender, html_text);
	
	g_free(html_text);
	g_free(convmsg->sender);
	g_free(convmsg);
}
Пример #4
0
static void send_request_confirmed(MMConversation *mmconv)
{
	PurpleConnection *connection = purple_conversation_get_gc(mmconv->conv);
	const char *convName = purple_conversation_get_name(mmconv->conv);
	serv_send_im(connection, convName, MUSICMESSAGING_CONFIRM_MSG, PURPLE_MESSAGE_SEND);
}
Пример #5
0
static void
pounce_cb(PurplePounce *pounce, PurplePounceEvent events, void *data)
{
	PurpleConversation *conv;
	PurpleAccount *account;
	PurpleBuddy *buddy;
	const char *pouncee;
	const char *alias;

	pouncee = purple_pounce_get_pouncee(pounce);
	account = purple_pounce_get_pouncer(pounce);

	buddy = purple_find_buddy(account, pouncee);
	if (buddy != NULL)
	{
		alias = purple_buddy_get_alias(buddy);
		if (alias == NULL)
			alias = pouncee;
	}
	else
		alias = pouncee;

	if (purple_pounce_action_is_enabled(pounce, "open-window"))
	{
		if (!purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, pouncee, account))
			purple_conversation_new(PURPLE_CONV_TYPE_IM, account, pouncee);
	}

	if (purple_pounce_action_is_enabled(pounce, "popup-notify"))
	{
		char *tmp = NULL;
		const char *name_shown;
		const char *reason;
		struct {
			PurplePounceEvent event;
			const char *format;
		} messages[] = {
			{PURPLE_POUNCE_TYPING, _("%s has started typing to you (%s)")},
			{PURPLE_POUNCE_TYPED, _("%s has paused while typing to you (%s)")},
			{PURPLE_POUNCE_SIGNON, _("%s has signed on (%s)")},
			{PURPLE_POUNCE_IDLE_RETURN, _("%s has returned from being idle (%s)")},
			{PURPLE_POUNCE_AWAY_RETURN, _("%s has returned from being away (%s)")},
			{PURPLE_POUNCE_TYPING_STOPPED, _("%s has stopped typing to you (%s)")},
			{PURPLE_POUNCE_SIGNOFF, _("%s has signed off (%s)")},
			{PURPLE_POUNCE_IDLE, _("%s has become idle (%s)")},
			{PURPLE_POUNCE_AWAY, _("%s has gone away. (%s)")},
			{PURPLE_POUNCE_MESSAGE_RECEIVED, _("%s has sent you a message. (%s)")},
			{0, NULL}
		};
		int i;
		reason = purple_pounce_action_get_attribute(pounce, "popup-notify",
				"reason");

		/*
		 * Here we place the protocol name in the pounce dialog to lessen
		 * confusion about what protocol a pounce is for.
		 */
		for (i = 0; messages[i].format != NULL; i++) {
			if (messages[i].event & events) {
				tmp = g_strdup_printf(messages[i].format, alias,
						purple_account_get_protocol_name(account));
				break;
			}
		}
		if (tmp == NULL)
			tmp = g_strdup(_("Unknown pounce event. Please report this!"));

		/*
		 * Ok here is where I change the second argument, title, from
		 * NULL to the account alias if we have it or the account
		 * name if that's all we have
		 */
		if ((name_shown = purple_account_get_alias(account)) == NULL)
			name_shown = purple_account_get_username(account);

		if (reason == NULL)
		{
			purple_notify_info(NULL, name_shown, tmp, purple_date_format_full(NULL));
		}
		else
		{
			char *tmp2 = g_strdup_printf("%s\n\n%s", reason, purple_date_format_full(NULL));
			purple_notify_info(NULL, name_shown, tmp, tmp2);
			g_free(tmp2);
		}
		g_free(tmp);
	}

	if (purple_pounce_action_is_enabled(pounce, "send-message"))
	{
		const char *message;

		message = purple_pounce_action_get_attribute(pounce, "send-message",
												   "message");

		if (message != NULL)
		{
			conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, pouncee, account);

			if (conv == NULL)
				conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, pouncee);

			purple_conversation_write(conv, NULL, message,
									PURPLE_MESSAGE_SEND, time(NULL));

			serv_send_im(purple_account_get_connection(account), (char *)pouncee, (char *)message, 0);
		}
	}

	if (purple_pounce_action_is_enabled(pounce, "execute-command"))
	{
		const char *command;

		command = purple_pounce_action_get_attribute(pounce,
				"execute-command", "command");

		if (command != NULL)
		{
			char *localecmd = g_locale_from_utf8(command, -1, NULL,
					NULL, NULL);

			if (localecmd != NULL)
			{
				int pid = fork();

				if (pid == 0) {
					char *args[4];

					args[0] = "sh";
					args[1] = "-c";
					args[2] = (char *)localecmd;
					args[3] = NULL;

					execvp(args[0], args);

					_exit(0);
				}
				g_free(localecmd);
			}
		}
	}

	if (purple_pounce_action_is_enabled(pounce, "play-beep"))
	{
		beep();
	}
}
Пример #6
0
int toc_main_interface(int type, char **args) {
	
	switch (type) {
		case TOC_IM_IN: {
			char *msg, *nick;		
			nick = rm_space(args[0]);
			msg = strip_html(args[1]);
			RemoveFromLLByKey(msgdus,nick);
			AddToLL(msgdus,nick,NULL);	
			msgprintf("%s", cparse(fget_string_var(FORMAT_MSG_FSET), 
				"%s %s %s %s",update_clock(GET_TIME), 
				nick, "AIM", msg));			
			if ( is_away ) 
				serv_send_im(args[0],away_message);
			free(nick);
			break;
		}
		case TOC_TRANSLATED_ERROR:
		case TOC_CONNECT_MSGS:
			statusprintf(args[0]);
			break;
		case TOC_BUDDY_LOGGED_OFF:
			statusprintf("%s logged off",args[0]);
			if ( get_dllint_var("aim_window") )
				build_aim_status(get_window_by_name("AIM"));
			break;
		case TOC_BUDDY_LOGGED_ON:
			statusprintf("%s logged on", args[0]);
			if ( get_dllint_var("aim_window") )
				build_aim_status(get_window_by_name("AIM"));
			break;
		case TOC_EVILED:
			statusprintf("You have been warned by %s.", ((args[0] == NULL) ? "an anonymous person" : args[0])); 
			statusprintf("Your new warning level is %s%%" , args[1]);
			if ( get_dllint_var("aim_window") )
				build_aim_status(get_window_by_name("AIM"));
			break;
		case TOC_CHAT_JOIN:
			chatprintf("Joined buddy chat %s",args[1]);
			strncpy(current_chat,args[1],511);
			break;
		case TOC_BUDDY_LEFT_CHAT:
			chatprintf("%s left %s",args[1],args[0]);
			break;
		case TOC_BUDDY_JOIN_CHAT:
			chatprintf("%s joined %s",args[1],args[0]);
			break;
		case TOC_CHAT_LEFT:
			chatprintf("Left chat id: %s",args[0]);	
			break;
		case TOC_CHAT_IN: {
			char *e,*name,*chat;
			/* chatprintf("got msg from chat: <%s@AIM> %s",args[1],args[3]); */
			/* Need to take better action here */
			e = strip_html(args[3]);
			name = rm_space(args[1]);
			chat = rm_space(args[4]);
			msgprintf("%s",cparse(fget_string_var(FORMAT_PUBLIC_OTHER_FSET), "%s %s %s %s", update_clock(GET_TIME), name, chat, e));			
			free(name); free(chat);
			break;
		}
		case TOC_GOTO_URL: 
			statusprintf("GOTO_URL: %s",args[0]);
			break;
		case TOC_CHAT_INVITE:
			statusprintf("Invited to %s by %s '%s'",args[0],args[2],args[3]);
			break;
		case TOC_LAG_UPDATE:
		case TOC_WENT_IDLE:
			if ( get_dllint_var("aim_window") )
				build_aim_status(get_window_by_name("AIM"));
			break;					
		case TOC_DIR_STATUS:
			if ( atoi(args[0]) == 1 )
				statusprintf("Directory information successfully changed.");
			else
				statusprintf("Error altering directory information, error code: %s",args[0]);
			break;
		default:
			statusprintf("INTERNAL ERROR: Unknown toc type: %d",type);
	}
	return 1;
}