/* ------------------ * send public key to other person in conversation * ------------------ */ static void menu_action_sendkey_cb(PurpleConversation *conv, void* data) { // check if user selected a main key const char* fpr = purple_prefs_get_string(PREF_MY_KEY); if (fpr == NULL) fpr = ""; if (strcmp(fpr,"") != 0) { char* key = NULL; // get key key = get_key_armored(fpr); if (key != NULL) { // send key PurpleConvIm* im_data = purple_conversation_get_im_data(conv); if (im_data != NULL) { purple_conv_im_send_with_flags(im_data,key,PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_INVISIBLE | PURPLE_MESSAGE_RAW ); purple_conversation_write(conv,"","Public key sent!",PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG,time(NULL)); } } }else { purple_conversation_write(conv,"","You haven't selected a personal key yet.",PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG,time(NULL)); } }
bool PurpleIMChat::sendMessageCbk(void * dataIn) { Mutex::ScopedLock lock(PurpleIMChat::_mutex); PurpleIMChatCallbackData* cbData = (PurpleIMChatCallbackData*) dataIn; IMChatSession* chatSession = cbData->getIMChatSession(); // const char * message = (const char *)((misc_t *)data)->data_ptr2; // char *cleanMess = (char *) message; // bool cleaned = false; std::string cleanMsg = cbData->getMessage(); mConvInfo_t *mConv = FindChatStructById(chatSession->getId()); PurpleConversation *gConv = mConv->purple_conv_session; //VOXOX - JRT - 2009.07.09 // special case for ICQ PurpleAccount *gAccount = purple_conversation_get_account(gConv); PurplePlugin *prpl = purple_find_prpl(purple_account_get_protocol_id(gAccount)); if (prpl) { PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); if (prpl_info->list_icon != NULL) { if (!strcmp("icq", prpl_info->list_icon(gAccount, NULL))) { // cleanMess = (char *) purple_markup_strip_html(message); cleanMsg= purple_markup_strip_html( cbData->getMessage().c_str() ); // cleaned = true; } } } if (purple_conversation_get_type(gConv) == PURPLE_CONV_TYPE_IM) { purple_conv_im_send_with_flags(PURPLE_CONV_IM(gConv), cleanMsg.c_str(), PURPLE_MESSAGE_SEND); } else if (purple_conversation_get_type(gConv) == PURPLE_CONV_TYPE_CHAT) { purple_conv_chat_send_with_flags(PURPLE_CONV_CHAT(gConv), cleanMsg.c_str(), PURPLE_MESSAGE_SEND); } // if (cleaned) // { // g_free(cleanMess); // } timeoutRemove( cbData ); delete cbData; return TRUE; }
/** * A function to send a chat or im message to the specific conversation * without emitting "sending-im" or "sending-chat" signal, which would * cause an infinite loop for this plugin. * * taken from conversation.c with signal emission removed. */ static void splitter_common_send(PurpleConversation *conv, const char *message, PurpleMessageFlags msgflags) { PurpleConversationType type; PurpleAccount *account; PurpleConnection *gc; char *sent = NULL; if (strlen(message) == 0) return; account = purple_conversation_get_account(conv); #if PURPLE_VERSION_CHECK(3,0,0) gc = purple_conversation_get_connection(conv); #else gc = purple_conversation_get_gc(conv); #endif g_return_if_fail(account != NULL); g_return_if_fail(gc != NULL); type = purple_conversation_get_type(conv); if ((purple_conversation_get_features(conv) & PURPLE_CONNECTION_HTML) && !(msgflags & PURPLE_MESSAGE_RAW)) { sent = purple_markup_linkify(message); } else sent = g_strdup(message); msgflags |= PURPLE_MESSAGE_SEND; splitter_injected_message = TRUE; if (type == PURPLE_CONV_TYPE_IM) { if (sent != NULL && sent[0] != '\0') purple_conv_im_send_with_flags(PURPLE_CONV_IM(conv), sent, msgflags); } else { if (sent != NULL && sent[0] != '\0') purple_conv_chat_send_with_flags(PURPLE_CONV_CHAT(conv), sent, msgflags); } splitter_injected_message = FALSE; g_free(sent); }
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)); }