当前位置: 首页>>代码示例>>C++>>正文


C++ purple_conversation_write函数代码示例

本文整理汇总了C++中purple_conversation_write函数的典型用法代码示例。如果您正苦于以下问题:C++ purple_conversation_write函数的具体用法?C++ purple_conversation_write怎么用?C++ purple_conversation_write使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了purple_conversation_write函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: translate_receiving_chat_msg_cb

void
translate_receiving_chat_msg_cb(const gchar *original_phrase, const gchar *translated_phrase, const gchar *detected_language, gpointer userdata)
{
	struct TranslateConvMessage *convmsg = userdata;
	PurpleChat *chat;
	gchar *html_text;
	const gchar *stored_lang = "";
	const gchar *language_name = NULL;
	gchar *message;
	
	if (detected_language)
	{
		chat = purple_blist_find_chat(convmsg->account, convmsg->conv->name);
		stored_lang = purple_blist_node_get_string((PurpleBlistNode *)chat, DEST_LANG_SETTING);
		purple_blist_node_set_string((PurpleBlistNode *)chat, DEST_LANG_SETTING, detected_language);
		
		language_name = get_language_name(detected_language);
		
		if (language_name != NULL)
		{
			message = g_strdup_printf("Now translating to %s (auto-detected)", language_name);
			purple_conversation_write(convmsg->conv, NULL, message, PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG, time(NULL));
			g_free(message);
		}
	}
	
	html_text = purple_strdup_withhtml(translated_phrase);
	
	purple_conversation_write(convmsg->conv, convmsg->sender, html_text, convmsg->flags, time(NULL));
	
	g_free(html_text);
	g_free(convmsg->sender);
	g_free(convmsg);
}
开发者ID:Javran,项目名称:purple-plugin-pack,代码行数:34,代码来源:translate.c

示例2: SendMsgTimeout_cb

void SendMsgTimeout_cb(struct fetion_account_data *sip, struct sipmsg *msg, struct transaction *tc)
{
	PurpleConversation *conv;
	const gchar *who;
	char *reason;
	who = sipmsg_find_header(msg,"T");
	if(!who) 
		return;

	conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, who, sip->gc->account);
	if(conv)
	{
		switch (msg->response)
		{
			case 401:
				reason = g_strdup_printf(_("Message may have not been sent,because of Unauthoried !"));
				break;
			case 504:
				reason = g_strdup_printf(_("Message may have not been sent,because of Server Time-out !"));
				break;
			default:
				reason = g_strdup_printf(_("Message may have not been sent,because of timeout!"));
				
		}
		purple_conversation_write(conv, NULL, reason, PURPLE_MESSAGE_ERROR, time(NULL));
		purple_conversation_write(conv, NULL, msg->body, PURPLE_MESSAGE_RAW, time(NULL));

		g_free(reason);
	}


}
开发者ID:scljz,项目名称:fetion,代码行数:32,代码来源:f_chat.c

示例3: menu_action_sendkey_cb

/* ------------------
 * 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));
	}
}
开发者ID:bitboulder,项目名称:Pidgin-GPG,代码行数:31,代码来源:pidgin-gpg.c

示例4: menu_action_retrievekey_cb

/* ------------------
 * try to retrieve key from server
 * ------------------ */
static void
menu_action_retrievekey_cb(PurpleConversation *conv, void* data)
{
	char sys_msg_buffer[1000];
	// check if the user with the jid=conv->name has signed his presence
	char* bare_jid = get_bare_jid(conv->name);

	// get stored info about user
	struct list_item* item = g_hash_table_lookup(list_fingerprints,bare_jid);
	if (item != NULL)
	{
		char* userid = NULL;
		if (is_key_available(item->fpr,FALSE,TRUE,&userid) == FALSE)
		{
			sprintf(sys_msg_buffer,"Did not find key with ID '%s' on keyservers.",item->fpr);
			purple_conversation_write(conv,"",sys_msg_buffer,PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG,time(NULL));
		}else
		{
			// found key -> enable mode_enc
			sprintf(sys_msg_buffer,"Found key with ID '%s'/'%s' for '%s' on keyservers.",item->fpr,userid,bare_jid);
			purple_conversation_write(conv,"",sys_msg_buffer,PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG,time(NULL));
			purple_conversation_write(conv,"","Encryption enabled",PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG,time(NULL));
			item->mode_sec = TRUE;
		}
		if (userid != NULL)
			free(userid);
	}

	free(bare_jid);
}
开发者ID:bitboulder,项目名称:Pidgin-GPG,代码行数:33,代码来源:pidgin-gpg.c

示例5: conversation_created_cb

/* ------------------
 * called on new conversations
 * ------------------ */
void conversation_created_cb(PurpleConversation *conv, char* data)
{
	char sys_msg_buffer[1000];
	if (purple_conversation_get_type(conv) != PURPLE_CONV_TYPE_IM)
		return;

	purple_debug_info(PLUGIN_ID, "conversation name: %s\n",conv->name);

	// check if the user with the jid=conv->name has signed his presence
	char* bare_jid = get_bare_jid(conv->name);

	// get stored info about user
	struct list_item* item = g_hash_table_lookup(list_fingerprints,bare_jid);
	if (item == NULL)
	{
		sprintf(sys_msg_buffer,"No encryption support in client of '%s'",bare_jid);
	}else
	{
		sprintf(sys_msg_buffer,"Client of user %s supports encryption",bare_jid);
	}

	// display a basic message
	purple_conversation_write(conv,"",sys_msg_buffer,PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG,time(NULL));

	if (item != NULL)
	{
		char* userid = NULL;
		// check if we have key locally
		if (is_key_available(item->fpr,FALSE,FALSE,&userid) == FALSE)
		{
			if (userid != NULL)
				free(userid);
			userid = NULL;

			sprintf(sys_msg_buffer,"User has key with ID '%s', but we do not have it locally, try Options->\"Try to retrieve key of '%s' from server\"",item->fpr,bare_jid);
			purple_conversation_write(conv,"",sys_msg_buffer,PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG,time(NULL));
		}else
		{
			// key is already available locally -> enable mode_enc
			sprintf(sys_msg_buffer,"'%s' uses key with id '%s'/'%s'",bare_jid,userid,item->fpr);
			purple_conversation_write(conv,"",sys_msg_buffer,PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG,time(NULL));
			item->mode_sec = TRUE;
		}
		if (userid != NULL)
			free(userid);
		userid = NULL;
		// if we have the key now, move to secure mode
		if (item->mode_sec == TRUE)
			sprintf(sys_msg_buffer,"Encryption enabled");
		else
			sprintf(sys_msg_buffer,"Encryption disabled");
	}else
		sprintf(sys_msg_buffer,"Encryption disabled");

	// display message about received message
	purple_conversation_write(conv,"",sys_msg_buffer,PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG,time(NULL));

	free(bare_jid);
}
开发者ID:bitboulder,项目名称:Pidgin-GPG,代码行数:62,代码来源:pidgin-gpg.c

示例6: fx_im_send

static int fx_im_send(PurpleConnection *gc, const gchar *who, const gchar *what, PurpleMessageFlags UNUSED(flags))
{
	PurpleBuddy    *buddy;
	PurplePresence *presence;
	PurpleStatus   *status;
	const gchar    *status_id;
	fetion_account  *sec;
	PurpleConversation *conv;
	fetion_account  *ac = purple_connection_get_protocol_data(gc);

	Contact        *cnt;
	gint            shutdown = 0;

	if(!(buddy = purple_find_buddy(ac->account, who))) return 0;
	presence = purple_buddy_get_presence(buddy);
	status   = purple_presence_get_active_status(presence);
	status_id = purple_status_get_id(status);

	cnt = fetion_contact_list_find_by_userid(ac->user->contactList, who);
	if(cnt->relationStatus == RELATION_STATUS_UNAUTHENTICATED) {
		if(!(conv = purple_find_conversation_with_account(
						PURPLE_CONV_TYPE_ANY, who, ac->account))) return -1;
			purple_conversation_write(conv, NULL,
					  _("Failed to send message: Unverified Buddy!"),
					  PURPLE_MESSAGE_ERROR, time(NULL));
			return -1;
	}
	
	if(cnt->serviceStatus == BASIC_SERVICE_ABNORMAL){
		if(cnt->carrierStatus == CARRIER_STATUS_CLOSED){
			shutdown = 1;
		}else{
			if((cnt->carrier[0] != '\0' && cnt->mobileno[0] == '\0') || cnt->carrier[0] == '\0')
				shutdown = 1;
		}
	}else if(cnt->carrierStatus == CARRIER_STATUS_DOWN)
		if(cnt->carrier[0] != '\0') shutdown = 1;

	if(shutdown) {
		if(!(conv = purple_find_conversation_with_account(
						PURPLE_CONV_TYPE_ANY, who, ac->account))) return -1;
			purple_conversation_write(conv, NULL,
					  _("Fail to send message: Buddy has cancled Fetion service!"),
					  PURPLE_MESSAGE_ERROR, time(NULL));
			return -1;
	}

	/* online,need invite */
	if(strcmp(status_id, "Offline") != 0) {
		if(!(sec = session_find(who))) new_chat(ac, who, what);
		else  fetion_send_sms(sec, who, what);
		return 1;
	}

	fetion_send_sms(ac, who, what);
	return 1;
}
开发者ID:amoblin,项目名称:flyshion,代码行数:57,代码来源:openfetion.c

示例7: purple_find_conversation_with_account

void Poller::op_notified_kickout_from_group(line::Operation &op) {
    std::string msg;

    if (op.param3 == parent.profile.mid) {
        msg = "You were removed from the group by ";
        parent.blist_remove_chat(op.param1, ChatType::GROUP);
    } else {
        msg = "Removed from the group by ";
        parent.blist_update_chat(op.param1, ChatType::GROUP);
    }

    if (parent.contacts.count(op.param2) == 1)
        msg += parent.contacts[op.param2].displayName;
    else
        msg += "(unknown contact)";

    PurpleConversation *conv = purple_find_conversation_with_account(
        PURPLE_CONV_TYPE_CHAT,
        op.param1.c_str(),
        parent.acct);

    if (conv) {
        purple_conversation_write(
            conv,
            op.param3.c_str(),
            msg.c_str(),
            PURPLE_MESSAGE_SYSTEM,
            time(NULL));
    }
}
开发者ID:devunt,项目名称:purple-line,代码行数:30,代码来源:poller.cpp

示例8: receiving_im_msg_cb

/* ------------------
 * called before display of received messages
 * ------------------ */
static gboolean
receiving_im_msg_cb(PurpleAccount *account, char **sender, char **buffer,
				    PurpleConversation *conv, PurpleMessageFlags *flags, void *data)
{
	char sys_msg_buffer[1000];

	// check if the user with the jid=conv->name has signed his presence
	char* bare_jid = get_bare_jid(*sender);

	// set default message
	sprintf(sys_msg_buffer,"Encryption disabled");

	// get encryption key
	struct list_item* item = g_hash_table_lookup(list_fingerprints,bare_jid);
	if (item != NULL)
	{
		if (item->mode_sec == TRUE)
			sprintf(sys_msg_buffer,"Encryption enabled");

		// display a basic message, only if mode changed
		if (item->mode_sec != item->mode_sec_old)
			purple_conversation_write(conv,"",sys_msg_buffer,PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG,time(NULL));
		item->mode_sec_old = item->mode_sec;
	}
	free(bare_jid);

	return FALSE;
}
开发者ID:bitboulder,项目名称:Pidgin-GPG,代码行数:31,代码来源:pidgin-gpg.c

示例9: sending_im_msg_cb

/* ------------------
 * called before message is sent
 * ------------------ */
void sending_im_msg_cb(PurpleAccount *account, const char *receiver,
                       char **message)
{
	PurpleConversation *gconv = NULL;

	// search for conversation
	gconv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, receiver, account);
	if(gconv)
	{
		// check if the user with the jid=conv->name has signed his presence
		char* bare_jid = get_bare_jid(gconv->name);
		// get stored info about user
		struct list_item* item = g_hash_table_lookup(list_fingerprints,bare_jid);
		if (item != NULL)
		{
			// if we are in private mode
			if (item->mode_sec == TRUE)
			{
				// try to get key
				if (is_key_available(item->fpr,FALSE,FALSE,NULL) == FALSE)
				{
					// we do not have key of receiver
					// -> cancel message sending
					free (*message);
					*message = NULL;

					// tell user of this
					purple_conversation_write(gconv,"","The key of the receiver is not available, please ask the receiver for the key before trying to encrypt messages.",PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG,time(NULL));
				}
			}
		}
		free(bare_jid);
	}
}
开发者ID:bitboulder,项目名称:Pidgin-GPG,代码行数:37,代码来源:pidgin-gpg.c

示例10: translate_conversation_created

static void
translate_conversation_created(PurpleConversation *conv)
{
	PurpleBlistNode *node = NULL;
	gchar *message;
	const gchar *language_key;
	const gchar *language_name;
	
	if (conv->type == PURPLE_CONV_TYPE_IM)
		node = (PurpleBlistNode *) purple_find_buddy(conv->account, conv->name);
	else if (conv->type == PURPLE_CONV_TYPE_CHAT)
		node = (PurpleBlistNode *) purple_blist_find_chat(conv->account, conv->name);
	
	if (node != NULL)
	{
		language_key = purple_blist_node_get_string(node, DEST_LANG_SETTING);
		
		if (language_key != NULL)
		{
			language_name = get_language_name(language_key);
		
			message = g_strdup_printf(_("Now translating to %s"), language_name);
			purple_conversation_write(conv, NULL, message, PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG, time(NULL));
			g_free(message);
		}
	}
}
开发者ID:Javran,项目名称:purple-plugin-pack,代码行数:27,代码来源:translate.c

示例11: _start_stream

static void
_start_stream(gpointer data, gint source, PurpleInputCondition condition)
{
	BonjourJabberConversation *bconv = data;
	struct _stream_start_data *ss = bconv->stream_data;
	int len, ret;

	len = strlen(ss->msg);

	/* Start Stream */
	ret = send(source, ss->msg, len, 0);

	if (ret == -1 && errno == EAGAIN)
		return;
	else if (ret <= 0) {
		const char *err = g_strerror(errno);
		PurpleConversation *conv;
		const char *bname = bconv->buddy_name;
		BonjourBuddy *bb = NULL;

		if(bconv->pb) {
			bb = purple_buddy_get_protocol_data(bconv->pb);
			bname = purple_buddy_get_name(bconv->pb);
		}

		purple_debug_error("bonjour", "Error starting stream with buddy %s at %s error: %s\n",
				   bname ? bname : "(unknown)", bconv->ip, err ? err : "(null)");

		conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bname, bconv->account);
		if (conv != NULL)
			purple_conversation_write(conv, NULL,
				  _("Unable to send the message, the conversation couldn't be started."),
				  PURPLE_MESSAGE_SYSTEM, time(NULL));

		bonjour_jabber_close_conversation(bconv);
		if(bb != NULL)
			bb->conversation = NULL;

		return;
	}

	/* This is EXTREMELY unlikely to happen */
	if (ret < len) {
		char *tmp = g_strdup(ss->msg + ret);
		g_free(ss->msg);
		ss->msg = tmp;
		return;
	}

	g_free(ss->msg);
	g_free(ss);
	bconv->stream_data = NULL;

	/* Stream started; process the send buffer if there is one */
	purple_input_remove(bconv->tx_handler);
	bconv->tx_handler = 0;
	bconv->sent_stream_start = FULLY_SENT;

	bonjour_jabber_stream_started(bconv);
}
开发者ID:Draghtnod,项目名称:pidgin,代码行数:60,代码来源:jabber.c

示例12: tgp_msg_sys_out

void tgp_msg_sys_out (struct tgl_state *TLS, const char *msg, tgl_peer_id_t to_id, int no_log) {
  int flags = PURPLE_MESSAGE_SYSTEM;
  if (no_log) {
    flags |= PURPLE_MESSAGE_NO_LOG;
  }
  time_t now;
  time (&now);
  
  switch (tgl_get_peer_type (to_id)) {
    case TGL_PEER_CHAT:
      p2tgl_got_chat_in (TLS, to_id, to_id, msg, flags, now);
      break;
    case TGL_PEER_USER:
    case TGL_PEER_ENCR_CHAT: {
      const char *name = tgp_blist_lookup_purple_name (TLS, to_id);
      PurpleConversation *conv = p2tgl_find_conversation_with_account (TLS, to_id);
      
      g_return_if_fail (name);

      if (! conv) {
        conv = purple_conversation_new (PURPLE_CONV_TYPE_IM, tls_get_pa (TLS), name);
      }
      purple_conversation_write (conv, name, msg, flags, now);
      break;
    }
  }
}
开发者ID:Houlbek,项目名称:telegram-purple,代码行数:27,代码来源:tgp-msg.c

示例13: conversation_created_cb

static void
conversation_created_cb (PurpleConversation *conv, gpointer data)
{
    gchar *str;
    const gchar *tmp_user, *friendly_name;
    MsnSession *session = data;
    struct pn_contact *contact;

    tmp_user = purple_conversation_get_name (conv);
    contact = pn_contactlist_find_contact (session->contactlist, tmp_user);
    if (contact)
        friendly_name = pn_contact_get_friendly_name (contact);
    else
        friendly_name = tmp_user;
    if (!friendly_name)
        friendly_name = tmp_user;

    if (contact && !(contact->list_op & (1 << MSN_LIST_RL)))
    {
        str = g_strdup_printf (_("You are not in %s's contact list."), friendly_name);

        purple_conversation_write (conv, NULL, str, PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NOTIFY, time (NULL));

        g_free (str);
    }
}
开发者ID:allanfreitas,项目名称:msn-pecan,代码行数:26,代码来源:session.c

示例14: bonjour_jabber_stream_ended

static void bonjour_jabber_stream_ended(BonjourJabberConversation *bconv) {

	/* Inform the user that the conversation has been closed */
	BonjourBuddy *bb = NULL;
	const gchar *name = bconv->pb ? purple_buddy_get_name(bconv->pb) : "(unknown)";

	purple_debug_info("bonjour", "Received conversation close notification from %s.\n", name);

	if(bconv->pb != NULL)
		bb = purple_buddy_get_protocol_data(bconv->pb);
#if 0
	if(bconv->pb != NULL) {
		PurpleConversation *conv;
		conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bconv->pb->name, bconv->pb->account);
		if (conv != NULL) {
			char *tmp = g_strdup_printf(_("%s has closed the conversation."), bconv->pb->name);
			purple_conversation_write(conv, NULL, tmp, PURPLE_MESSAGE_SYSTEM, time(NULL));
			g_free(tmp);
		}
	}
#endif
	/* Close the socket, clear the watcher and free memory */
	bonjour_jabber_close_conversation(bconv);
	if(bb)
		bb->conversation = NULL;
}
开发者ID:Draghtnod,项目名称:pidgin,代码行数:26,代码来源:jabber.c

示例15: qq_sys_msg_write

void qq_sys_msg_write(qq_account* ac,LwqqMsgType m_t,const char* serv_id,const char* msg,PurpleMessageFlags type,time_t t)
{
	//ac->qq->dispatch(vp_func_2p,(CALLBACK_FUNC)sys_msg_write,ac->qq,system_msg_new(m_t,serv_id,ac,msg,type,t));

	PurpleConversation* conv = find_conversation(m_t,serv_id,ac);
	if(conv)
		purple_conversation_write(conv,NULL,msg,type,t);
}
开发者ID:5rather,项目名称:pidgin-lwqq,代码行数:8,代码来源:qq_types.c


注:本文中的purple_conversation_write函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。