bool QuetzalChat::sendMessage(const Message &message) { if (!m_conv->account->gc) return false; purple_conv_chat_send(PURPLE_CONV_CHAT(m_conv), message.text().toUtf8().constData()); return true; }
gboolean pop(gpointer p) { char *reply = ""; queue_t *q = (queue_t*)p; queue_item_t *item; if (q->len > 0) { item = q->q[0]; q->len--; if (q->len > 0) { memmove(q->q, &(q->q[1]), q->len * sizeof(queue_item_t*)); // q->q = realloc(q->q, q->len * sizeof(queue_item_t*)); } if (purple_conversation_get_type(item->conv) == PURPLE_CONV_TYPE_IM) { // reply = alice(item->name, item->msg, item->conv); purple_conv_im_send(PURPLE_CONV_IM(item->conv), item->msg); } else if (purple_conversation_get_type(item->conv) == PURPLE_CONV_TYPE_CHAT) { // reply = alice(item->name, item->msg, item->conv); purple_conv_chat_send(PURPLE_CONV_CHAT(item->conv), item->msg); } printf (NAME ": %s\n", reply); free(item->name); free(item->msg); free(item); } return 1; }
static gboolean received_chat_msg_cb(PurpleAccount *account, char *sender, char *message, PurpleConversation *conv, PurpleMessageFlags flags, gpointer data) { PurpleConvChat *chat = PURPLE_CONV_CHAT(conv); purple_debug_info(PLUGIN_ID, "%s\n", message); /* only listen to rooms on the list */ if (!g_list_find(chatroom_list, chat)) return FALSE; /* stop duplicated messages from QQ Qun */ if (!strcmp(account->protocol_id, "prpl-qq") && (account->alias) && !strcmp(sender, account->alias)) return FALSE; /* if received, push to other chatrooms on the list */ if ( (flags & PURPLE_MESSAGE_RECV) ) { char *msg = format_message(sender, message); void forward_chat_message(gpointer data, gpointer user_data) { PurpleConvChat *chatroom = (PurpleConvChat*)data; if(chatroom != chat) { purple_conv_chat_send(chatroom, msg); } }
static void plonkers_display(PurpleConversation *conv) { gchar *text = NULL; g_return_if_fail(conv); text = plonkers_format_info(conv); if(!text) return; purple_conv_chat_send(PURPLE_CONV_CHAT(conv), text); if(text) g_free(text); }
static VALUE conversation_chat_send(VALUE self, VALUE message) { PurpleConversation *conversation; Data_Get_Struct(self, PurpleConversation, conversation); PurpleConvChat *chat_data = PURPLE_CONV_CHAT(conversation); if (chat_data == NULL) { return Qnil; } else { purple_conv_chat_send(chat_data, StringValueCStr(message)); return Qtrue; } }
static PurpleCmdRet cmd_func(PurpleConversation *conv, const gchar *cmd, gchar **args, gchar *error, void *data) { GString *msgstr = NULL; guint32 quotes = 0, quoteid = 0; msgstr = g_string_new(""); srand(time(NULL)); if(!strcmp(cmd, "bash")) { g_string_append(msgstr, "http://www.bash.org/?"); quotes = BASH_QUOTES; } else { g_string_append(msgstr, "http://qdb.us/"); quotes = QDB_QUOTES; } if(*args == NULL || args[0] == NULL) quoteid = (rand() % quotes) + 1; else quoteid = atoi(args[0]); if(quoteid > quotes) quoteid %= quotes; g_string_append_printf(msgstr, "%i", quoteid); switch(purple_conversation_get_type(conv)) { case PURPLE_CONV_TYPE_IM: purple_conv_im_send(PURPLE_CONV_IM(conv), msgstr->str); break; case PURPLE_CONV_TYPE_CHAT: purple_conv_chat_send(PURPLE_CONV_CHAT(conv), msgstr->str); break; default: g_string_free(msgstr, TRUE); return PURPLE_CMD_RET_FAILED; } g_string_free(msgstr, TRUE); return PURPLE_CMD_RET_OK; }
static PurpleCmdRet send_to_all(PurpleConversation *conv, const gchar *cmd, gchar **markup, gchar *error, void *data) { PurpleConversation *conversation = NULL; GList *conversations = purple_get_conversations(); while(conversations != NULL) { conversation = conversations->data; if(conv->type == PURPLE_CONV_TYPE_IM) purple_conv_im_send(PURPLE_CONV_IM(conversation), markup[0]); else if(conv->type == PURPLE_CONV_TYPE_CHAT) purple_conv_chat_send(PURPLE_CONV_CHAT(conversation), markup[0]); conversations = conversations->next; } //g_free(msg); return PURPLE_CMD_RET_OK; }
static void purple_chat_msg( struct groupchat *gc, char *message, int flags ) { PurpleConversation *pc = gc->data; purple_conv_chat_send( purple_conversation_get_chat_data( pc ), message ); }
xmlnode * _h_elim_message ( const char *name , const char *id , SEXP_VALUE *args , gpointer data ) { fprintf(stderr, "(elim-debug entered _h_elim_message)"); ASSERT_ALISTP( args, id, name ); elim_ping(); const char *aname = ALIST_VAL_STR( args, "account-name" ); const char *proto = ALIST_VAL_STR( args, "im-protocol" ); gpointer auid = ALIST_VAL_PTR( args, "account-uid" ); PurpleAccount *acct = auid ? find_acct_by_uid( auid ) : purple_accounts_find( aname, proto ); if( !acct ) { sexp_val_free( args ); return response_error( ENXIO, id, name, "unknown account" ); } PurpleConversationType pt = PURPLE_CONV_TYPE_UNKNOWN; gpointer cuid = ALIST_VAL_PTR( args, "conv-uid" ); const char *cname = ALIST_VAL_STR( args, "conv-name" ); PurpleConversation *pc = find_conv_by_acct_uid( acct, cuid ); if ( pc ) pt = purple_conversation_get_type( pc ); else { pt = PURPLE_CONV_TYPE_ANY; pc = purple_find_conversation_with_account( pt, cname, acct ); if( !pc ) { pt = PURPLE_CONV_TYPE_IM; pc = purple_conversation_new( pt, acct, cname ); } else { pt = purple_conversation_get_type( pc ); } } if( !pc ) { sexp_val_free( args ); return response_error( ENXIO, id, name, "new conversation failed" ); } PurpleConvIm *pci = NULL; PurpleConvChat *pcc = NULL; const char *msg = ALIST_VAL_STRING( args, "text" ); char *esc = g_markup_escape_text( msg, -1 ); int len = strlen( esc ); switch( pt ) { case PURPLE_CONV_TYPE_IM: pci = purple_conversation_get_im_data( pc ); purple_conv_im_send( pci, esc ); break; case PURPLE_CONV_TYPE_CHAT: pcc = purple_conversation_get_chat_data( pc ); purple_conv_chat_send( pcc, esc ); break; default: g_free ( esc ); sexp_val_free( args ); return response_error( EINVAL, id, name, "unknown conversation type" ); } xmlnode *rval = xnode_new( "alist" ); AL_INT( rval, "bytes" , len ); AL_PTR( rval, "conv-uid" , pc ); AL_STR( rval, "conv-name", purple_conversation_get_name(pc) ); g_free ( esc ); sexp_val_free( args ); fprintf(stderr, "(elim-debug leaving _h_elim_message)"); return response_value( 0, id, name, rval ); }
static void entry_key_pressed(GntWidget *w, FinchConv *ggconv) { const char *text = gnt_entry_get_text(GNT_ENTRY(ggconv->entry)); if (*text == '/' && *(text + 1) != '/') { PurpleConversation *conv = ggconv->active_conv; PurpleCmdStatus status; const char *cmdline = text + 1; char *error = NULL, *escape; escape = g_markup_escape_text(cmdline, -1); status = purple_cmd_do_command(conv, cmdline, escape, &error); g_free(escape); switch (status) { case PURPLE_CMD_STATUS_OK: break; case PURPLE_CMD_STATUS_NOT_FOUND: purple_conversation_write(conv, "", _("No such command."), PURPLE_MESSAGE_NO_LOG, time(NULL)); break; case PURPLE_CMD_STATUS_WRONG_ARGS: purple_conversation_write(conv, "", _("Syntax Error: You typed the wrong number of arguments " "to that command."), PURPLE_MESSAGE_NO_LOG, time(NULL)); break; case PURPLE_CMD_STATUS_FAILED: purple_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."), PURPLE_MESSAGE_NO_LOG, time(NULL)); break; case PURPLE_CMD_STATUS_WRONG_TYPE: if(purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) purple_conversation_write(conv, "", _("That command only works in chats, not IMs."), PURPLE_MESSAGE_NO_LOG, time(NULL)); else purple_conversation_write(conv, "", _("That command only works in IMs, not chats."), PURPLE_MESSAGE_NO_LOG, time(NULL)); break; case PURPLE_CMD_STATUS_WRONG_PRPL: purple_conversation_write(conv, "", _("That command doesn't work on this protocol."), PURPLE_MESSAGE_NO_LOG, time(NULL)); break; } g_free(error); } else if (!purple_account_is_connected(purple_conversation_get_account(ggconv->active_conv))) { purple_conversation_write(ggconv->active_conv, "", _("Message was not sent, because you are not signed on."), PURPLE_MESSAGE_ERROR | PURPLE_MESSAGE_NO_LOG, time(NULL)); } else { char *escape = purple_markup_escape_text((*text == '/' ? text + 1 : text), -1); switch (purple_conversation_get_type(ggconv->active_conv)) { case PURPLE_CONV_TYPE_IM: purple_conv_im_send_with_flags(PURPLE_CONV_IM(ggconv->active_conv), escape, PURPLE_MESSAGE_SEND); break; case PURPLE_CONV_TYPE_CHAT: purple_conv_chat_send(PURPLE_CONV_CHAT(ggconv->active_conv), escape); break; default: g_free(escape); g_return_if_reached(); } g_free(escape); purple_idle_touch(); } gnt_entry_add_to_history(GNT_ENTRY(ggconv->entry), text); gnt_entry_clear(GNT_ENTRY(ggconv->entry)); }