Пример #1
0
// Check that the conversation hasn't been closed
static gboolean
purple_conversation_is_valid(PurpleConversation *conv)
{
	GList *convs = purple_get_conversations();
	
	return (g_list_find(convs, conv) != NULL);
}
Пример #2
0
/**************************************************************************************************
    Load plugin
**************************************************************************************************/
static gboolean
plugin_load(PurplePlugin *plugin)
{
    PidginBuddyList *gtkblist = pidgin_blist_get_default_gtk_blist();
	GList *convs = purple_get_conversations();

    if (purple_prefs_get_bool("/plugins/core/hidemenu/default_state")) {
        hmb_is_menu_visible = FALSE;
    } else {
        hmb_is_menu_visible = TRUE;
    }

    // set callback for 'blist created' signal
    purple_signal_connect(pidgin_blist_get_handle(), "gtkblist-created", plugin, 
                          PURPLE_CALLBACK(hmb_blist_created_cb), NULL);
    // set callback for 'conversation displayed' signal
	purple_signal_connect(pidgin_conversations_get_handle(), "conversation-displayed", plugin,
	                      PURPLE_CALLBACK(hmb_conversation_displayed_cb), NULL);

	// hide blist menubar
    hmb_toggle_menubar(gtkblist, NULL);

    // hide conversations menubar
	while (convs) {
		PurpleConversation *conv = (PurpleConversation *)convs->data;
		if (PIDGIN_IS_PIDGIN_CONVERSATION(conv)) {
			hmb_toggle_menubar(NULL, PIDGIN_CONVERSATION(conv));
		}
		convs = convs->next;
	}

	return TRUE;
}
Пример #3
0
static void
timestamp_new_convo(PurpleConversation *conv)
{
	if (!g_list_find(purple_get_conversations(), conv))
		return;

	purple_conversation_set_data(conv, "timestamp-last", GINT_TO_POINTER(0));
}
Пример #4
0
static gboolean plugin_unload(PurplePlugin *plugin)
{
    GList *convs;
    for (convs = purple_get_conversations(); convs != NULL; convs = convs->next) {
        PurpleConversation *conv = (PurpleConversation *)convs->data;
        if(PIDGIN_IS_PIDGIN_CONVERSATION(conv)) {
            detach_from_conversation(conv);
        }
    }
    return TRUE;
}
Пример #5
0
static VALUE list_conversations(VALUE self)
{
  VALUE array = rb_ary_new();
  
  GList *iter = purple_get_conversations();
  for (; iter; iter = iter->next) {
    VALUE conversation = Data_Wrap_Struct(cConversation, NULL, NULL, iter->data);
    rb_ary_push(array, conversation);
  }

  return array;
}
Пример #6
0
static gboolean plugin_load(PurplePlugin *plugin)
{
    pastesend_plugin = plugin;
    GList *convs;
    for (convs = purple_get_conversations(); convs != NULL; convs = convs->next) {
        attach_to_conversation((PurpleConversation *)convs->data);
    }

    void *conv_handle = purple_conversations_get_handle();
    purple_signal_connect(conv_handle, "conversation-created", plugin, PURPLE_CALLBACK(attach_to_conversation), NULL);

    return TRUE;
}
Пример #7
0
static gboolean
plugin_unload(PurplePlugin *plugin)
{
	GList *convs = purple_get_conversations();

	while (convs) {
		PurpleConversation *conv = (PurpleConversation *)convs->data;

		/* kill signals */
		detach_signals(conv);

		convs = convs->next;
	}

	return TRUE;
}
Пример #8
0
static void
apply_notify()
{
	GList *convs = purple_get_conversations();

	while (convs) {
		PurpleConversation *conv = (PurpleConversation *)convs->data;

		/* detach signals */
		detach_signals(conv);
		/* reattach appropriate signals */
		attach_signals(conv);

		convs = convs->next;
	}
}
Пример #9
0
static gboolean plugin_unload(PurplePlugin *plugin)
{
	GList *convs = purple_get_conversations();

	while (convs) {
		PurpleConversation *conv = (PurpleConversation *)convs->data;

		/* Remove context menu item button */
		if (PIDGIN_IS_PIDGIN_CONVERSATION(conv)) {
			remove_close_offline_menu_item_pidgin(PIDGIN_CONVERSATION(conv));
		}

		convs = convs->next;
	}
    
	return TRUE;
}
Пример #10
0
PurpleConversation *
jabber_find_unnormalized_conv(const char *name, PurpleAccount *account)
{
	PurpleConversation *c = NULL;
	GList *cnv;

	g_return_val_if_fail(name != NULL, NULL);

	for(cnv = purple_get_conversations(); cnv; cnv = cnv->next) {
		c = (PurpleConversation*)cnv->data;
		if(purple_conversation_get_type(c) == PURPLE_CONV_TYPE_IM &&
				!purple_utf8_strcasecmp(name, purple_conversation_get_name(c)) &&
				account == purple_conversation_get_account(c))
			return c;
	}

	return NULL;
}
Пример #11
0
static void
apply_method()
{
	GList *convs;
	PidginWindow *purplewin = NULL;

	for (convs = purple_get_conversations(); convs != NULL;
	     convs = convs->next) {
		PurpleConversation *conv = (PurpleConversation *)convs->data;

		/* remove notifications */
		unnotify(conv, FALSE);

		purplewin = PIDGIN_CONVERSATION(conv)->win;
		if (GPOINTER_TO_INT(purple_conversation_get_data(conv, "notify-message-count")) != 0)
			/* reattach appropriate notifications */
			notify(conv, FALSE);
	}
}
Пример #12
0
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;
}
Пример #13
0
static gboolean plugin_load(PurplePlugin *plugin)
{
     
	GList *convs = purple_get_conversations();
	void *gtk_conv_handle = pidgin_conversations_get_handle();

	purple_signal_connect(gtk_conv_handle, "conversation-displayed", plugin,
	                      PURPLE_CALLBACK(conversation_displayed_cb), NULL);
	while (convs) {
		PurpleConversation *conv = (PurpleConversation *)convs->data;

		/* Setup context menu action */
		if (PIDGIN_IS_PIDGIN_CONVERSATION(conv)) {
			create_close_offline_menu_item_pidgin(PIDGIN_CONVERSATION(conv));
		}

		convs = convs->next;
	}
	return TRUE;
}
Пример #14
0
static gboolean
plugin_unload(PurplePlugin *plugin)
{
	PurpleConversation *conv;
	PidginConversation *gtkconv;
	GList *l;

	for (l = purple_get_conversations(); l != NULL; l = l->next) {
		conv = (PurpleConversation *)l->data;

		if (!PIDGIN_IS_PIDGIN_CONVERSATION(conv))
			continue;

		gtkconv = PIDGIN_CONVERSATION(conv);

		gstroke_cleanup(gtkconv->imhtml);
		gstroke_disable(gtkconv->imhtml);
	}

	return TRUE;
}
Пример #15
0
static gboolean
plugin_load(PurplePlugin *plugin)
{
	PurpleConversation *conv;
	GList *l;

	for (l = purple_get_conversations(); l != NULL; l = l->next) {
		conv = (PurpleConversation *)l->data;

		if (!PIDGIN_IS_PIDGIN_CONVERSATION(conv))
			continue;

		attach_signals(conv);
	}

	purple_signal_connect(purple_conversations_get_handle(),
						"conversation-created",
						plugin, PURPLE_CALLBACK(new_conv_cb), NULL);

	return TRUE;
}
Пример #16
0
/**************************************************************************************************
    Toggle menubars state
**************************************************************************************************/
static void 
hmb_toggle_menubar_state()
{
    PidginBuddyList *gtkblist = pidgin_blist_get_default_gtk_blist();
	GList *convs = purple_get_conversations();
   
    // toggle menu visibility status
    hmb_is_menu_visible = !hmb_is_menu_visible;
    
    // toggle blist
    hmb_toggle_menubar(gtkblist, NULL);
	
    // toggle conversations
    while (convs) {
		PurpleConversation *conv = (PurpleConversation *)convs->data;
		if (PIDGIN_IS_PIDGIN_CONVERSATION(conv)) {
			hmb_toggle_menubar(NULL, PIDGIN_CONVERSATION(conv));
		}
		convs = convs->next;
	}
}
Пример #17
0
static gboolean
plugin_load(PurplePlugin *plugin)
{
	GList *convs = purple_get_conversations();
	void *conv_handle = purple_conversations_get_handle();
	void *gtk_conv_handle = pidgin_conversations_get_handle();

	my_plugin = plugin;

	purple_signal_connect(gtk_conv_handle, "displayed-im-msg", plugin,
	                    PURPLE_CALLBACK(message_displayed_cb), NULL);
	purple_signal_connect(gtk_conv_handle, "displayed-chat-msg", plugin,
	                    PURPLE_CALLBACK(message_displayed_cb), NULL);
	purple_signal_connect(gtk_conv_handle, "conversation-switched", plugin,
	                    PURPLE_CALLBACK(conv_switched), NULL);
	purple_signal_connect(conv_handle, "sent-im-msg", plugin,
	                    PURPLE_CALLBACK(im_sent_im), NULL);
	purple_signal_connect(conv_handle, "sent-chat-msg", plugin,
	                    PURPLE_CALLBACK(chat_sent_im), NULL);
	purple_signal_connect(conv_handle, "conversation-created", plugin,
	                    PURPLE_CALLBACK(conv_created), NULL);
	purple_signal_connect(conv_handle, "deleting-conversation", plugin,
	                    PURPLE_CALLBACK(deleting_conv), NULL);
#if 0
	purple_signal_connect(gtk_conv_handle, "conversation-dragging", plugin,
	                    PURPLE_CALLBACK(conversation_dragging), NULL);
#endif

	while (convs) {
		PurpleConversation *conv = (PurpleConversation *)convs->data;

		/* attach signals */
		attach_signals(conv);

		convs = convs->next;
	}

	return TRUE;
}
Пример #18
0
static gboolean
timestamp_displaying_conv_msg(PurpleAccount *account, const char *who,
			      char **buffer, PurpleConversation *conv,
			      PurpleMessageFlags flags, void *data)
{
	time_t now = time(NULL) / interval * interval;
	time_t then;

	if (!g_list_find(purple_get_conversations(), conv))
		return FALSE;

	then = GPOINTER_TO_INT(purple_conversation_get_data(
		conv, "timestamp-last"));

	if (now - then >= interval) {
		timestamp_display(conv, then, now);
		purple_conversation_set_data(
			conv, "timestamp-last", GINT_TO_POINTER(now));
	}

	return FALSE;
}
Пример #19
0
void AccountCollector::collectNow(PurpleAccount *account, bool remove) {
	if (account->ui_data == NULL) {
		Log("AccountCollector","freeing account " << purple_account_get_username(account));
		
		if (remove)
			g_hash_table_remove(m_accounts, purple_account_get_username(account));

		purple_account_set_enabled(account, purple_core_get_ui(), FALSE);

		purple_notify_close_with_handle(account);
		purple_request_close_with_handle(account);

		purple_accounts_remove(account);

		GSList *buddies = purple_find_buddies(account, NULL);
		while(buddies) {
			PurpleBuddy *b = (PurpleBuddy *) buddies->data;
			purple_blist_remove_buddy(b);
			buddies = g_slist_delete_link(buddies, buddies);
		}

		/* Remove any open conversation for this account */
		for (GList *it = purple_get_conversations(); it; ) {
			PurpleConversation *conv = (PurpleConversation *) it->data;
			it = it->next;
			if (purple_conversation_get_account(conv) == account)
				purple_conversation_destroy(conv);
		}

		/* Remove this account's pounces */
 			// purple_pounce_destroy_all_by_account(account);

		/* This will cause the deletion of an old buddy icon. */
		purple_buddy_icons_set_account_icon(account, NULL, 0);

		purple_account_destroy(account);
// 		VALGRIND_DO_LEAK_CHECK;
	}
}
Пример #20
0
static void got_new_messages(FacebookAccount *fba, const gchar *data,
		gsize data_len, gpointer userdata)
{
	JsonParser *parser;

	PurpleConnection *pc = userdata;

	purple_debug_misc("facebook", "got new messages:\n%s\n", data);

	/* for (;;);{"t":"msg","c":"p_800753867","ms":[{"type":"msg",
		"msg":{"text":"yes","time":1211176515861,"clientTime":1211176514750,
		"msgID":"367146364"},"from":596176850,"to":800753867,
		"from_name":"Jeremy Lawson","to_name":"Eion Robb",
		"from_first_name":"Jeremy","to_first_name":"Eion"}]} */
	/* for (;;);{"t":"refresh"} */
	/* for (;;);{"t":"msg","c":"p_800753867","ms":[{"type":"msg",
		"msg":{"text":"p**n head","time":1211177326689,"clientTime":1211177325,
		"msgID":"-1992480367"},"from":800753867,"to":596176850,
		"from_name":"Eion Robb","to_name":"Jeremy Lawson",
		"from_first_name":"Eion","to_first_name":"Jeremy"}]} */
	/* for (;;);{"t":"msg","c":"p_800753867","ms":[{"type":"typ","st":1,
		"from":596176850,"to":800753867},{"type":"msg","msg":{"text":"nubile!",
		"time":1211177334019,"clientTime":1211177326690,"msgID":"696260545"},
		"from":596176850,"to":800753867,"from_name":"Jeremy Lawson",
		"to_name":"Eion Robb","from_first_name":"Jeremy","to_first_name":"Eion"},
		{"type":"msg","msg":{"text":"test2","time":1211177336688,
		"clientTime":1211177326691,"msgID":"1527815367"},"from":596176850,
		"to":800753867,"from_name":"Jeremy Lawson","to_name":"Eion Robb",
		"from_first_name":"Jeremy","to_first_name":"Eion"},{"type":"msg",
		"msg":{"text":"ahhhhhhh!","time":1211177344361,"clientTime":1211177326692,
		"msgID":"4028916254"},"from":596176850,"to":800753867,
		"from_name":"Jeremy Lawson","to_name":"Eion Robb",
		"from_first_name":"Jeremy","to_first_name":"Eion"}]} */
	/* for (;;);{"t":"msg","c":"p_800753867","ms":[{"type":"msg",
		"msg":{"text":"2","time":1211178167261,"clientTime":1211178164656,
		"msgID":"3382240259"},"from":596176850,"to":800753867,
		"from_name":"Jeremy Lawson","to_name":"Eion Robb",
		"from_first_name":"Jeremy","to_first_name":"Eion"}]} */
	/* for (;;);{"t":"refresh", "seq":1} */

	parser = fb_get_parser(data, data_len);
	if (!parser)
	{
		/* Sometimes proxies will return incorrect data, so we just shrug 
		 * it off.
		 * TODO: Only do this for proxies.  And when we do it, keep track
		 * of consecutive failures in the case something is actually
		 * wrong with Facebook.  Eventually this condition should cause
		 * failure */
		/* Continue looping, waiting for more messages */
		purple_debug_error("facebook",
				"got data back, but it's not even json\n");
				
		fb_get_new_messages(fba);
		return;
	}

	JsonObject *objnode = fb_get_json_object(parser, NULL);

	if (json_object_has_member(objnode, "t")) {
		const gchar* command = json_node_get_string(json_object_get_member(objnode, "t"));
		if (g_str_equal(command, "refresh")) {
			if (json_object_has_member(objnode, "seq")) {
				fba->message_fetch_sequence = json_node_get_int(
					json_object_get_member(objnode, "seq"));
			}

			/* grab history items for all open conversations */
			GList *conversations = purple_get_conversations();
			while (conversations != NULL) {
				PurpleConversation *conv =
					(PurpleConversation *)conversations->data;
				if (fb_conversation_is_fb(conv)) {
					purple_debug_info("facebook",
						"checking for dropped messages with %s\n",
						conv->name);
					fb_history_fetch(fba, conv->name, FALSE);
				}
				conversations = conversations->next;
			}

			/* refresh means that the channel is invalid */
			fb_reconnect(fba);
			json_parser_free(parser);
			return;
		} else if (g_str_equal(command, "continue")) {
			/* continue means that the server wants us to remake the connection.
 			 * continue the loop and wait for messages. noop. */
		} else if (g_str_equal(command, "msg")) {
			parse_new_messages(pc, fba,
				json_node_get_array(json_object_get_member(objnode, "ms")));
		}
	}
	
	if (json_object_has_member(objnode, "s"))
	{
		gint new_seq = json_node_get_int(json_object_get_member(objnode, "s"));
		fba->message_fetch_sequence = new_seq;
	}

	json_parser_free(parser);

	/* Continue looping, waiting for more messages */
	fb_get_new_messages(fba);
}