Exemplo n.º 1
0
static void
lh_migrate_source_request_cb(void *ignored, PurpleRequestFields *fields)
{
    PurpleRequestFields *request;
    PurpleRequestFieldGroup *group;
    PurpleRequestField *field;

    source_account = purple_request_fields_get_account(fields,
                     "migrate_source_acct");
    valid_target_prpl_id = purple_account_get_protocol_id(source_account);

    /* It seems Purple is super-picky about the order of these first three calls */
    /* create a request */
    request = purple_request_fields_new();

    /* now create a field group */
    group = purple_request_field_group_new(NULL);
    /* and add that group to the request created above */
    purple_request_fields_add_group(request, group);

    /* create a field */
    field = purple_request_field_account_new("migrate_target_acct",
            _("Account"), NULL);

    /* mark the field as required */
    purple_request_field_set_required(field, TRUE);

    /* filter this list so that only accounts with the same prpl as the
     * source account can be chosen as a destination */
    purple_request_field_account_set_filter(field, lh_migrate_filter);

    /* add the field to the group created above */
    purple_request_field_group_add_field(group, field);

    /* and finally we can create the request */
    purple_request_fields(purple_get_blist(), _("Listhandler - Copying"),
                          _("Choose the account to add buddies to:"), NULL,
                          request, _("_Add"),
                          G_CALLBACK(lh_migrate_target_request_cb), _("_Cancel"),
                          NULL, NULL, NULL, NULL, NULL);

    return;
}
Exemplo n.º 2
0
static gboolean plugin_unload(PurplePlugin *plugin)
{
	void *conv_handle;
	struct crazychat *extra;
	assert(plugin);
	extra = (struct crazychat*) plugin->info->extra_info;
	cc_destroy(extra);
	conv_handle = purple_conversations_get_handle();
	purple_signal_disconnect(PIDGIN_BLIST
			       (purple_get_blist()),
			       "drawing-menu", plugin,
			       PURPLE_CALLBACK(cc_buddy_menu));
	purple_signal_disconnect(conv_handle, "received-im", plugin,
			       PURPLE_CALLBACK(receive_im_cb));
	purple_signal_disconnect(conv_handle, "displaying-im-msg", plugin,
			       PURPLE_CALLBACK(display_im_cb));
	Debug("CrazyChat plugin unloaded.\n");
	return TRUE;
}
Exemplo n.º 3
0
static gboolean cc_signed_on(PurpleConnection *gc, void *plugin)
{
	struct crazychat *extra;
	void *conv_handle;

	assert(plugin);
	extra = (struct crazychat*)((PurplePlugin*)plugin)->info->extra_info;
	purple_signal_disconnect
	    (purple_connections_get_handle(), "signed-on",
	     plugin, PURPLE_CALLBACK(cc_signed_on));
	purple_signal_connect(PIDGIN_BLIST
			    (purple_get_blist()),
			    "drawing-menu", plugin,
			    PURPLE_CALLBACK(cc_buddy_menu), NULL);
	conv_handle = purple_conversations_get_handle();
	purple_signal_connect(conv_handle, "received-im-msg", plugin,
		PURPLE_CALLBACK(receive_im_cb), extra);
	purple_signal_connect(conv_handle, "displaying-im-msg", plugin,
		PURPLE_CALLBACK(display_im_cb), extra);
	return FALSE;
}
Exemplo n.º 4
0
static void
use_icon_theme(GtkWidget *w, GtkWidget *window)
{
	/* I don't quite understand the icon-theme stuff. For example, I don't
	 * know why PidginIconTheme needs to be abstract, or how PidginStatusIconTheme
	 * would be different from other PidginIconTheme's (e.g. PidginStockIconTheme)
	 * etc., but anyway, this works for now.
	 *
	 * Here's an interesting note: A PidginStatusIconTheme can be used for both
	 * stock and status icons. Like I said, I don't quite know how they could be
	 * different. So I am going to just keep it as it is, for now anyway, until I
	 * have the time to dig through this, or someone explains this stuff to me
	 * clearly.
	 *		-- Sad
	 */
	PidginStatusIconTheme *theme = create_icon_theme(window);
	pidgin_stock_load_status_icon_theme(PIDGIN_STATUS_ICON_THEME(theme));
	pidgin_stock_load_stock_icon_theme((PidginStockIconTheme *)theme);
	pidgin_blist_refresh(purple_get_blist());
	g_object_unref(theme);
}
Exemplo n.º 5
0
static gboolean
plugin_load(PurplePlugin *plugin)
{
	PurpleBuddyList *list = purple_get_blist();
	void *conn_handle = purple_connections_get_handle();

	if (!check_timeout(NULL)) {
		purple_debug_warning("mailchk", "Could not read $MAIL or /var/spool/mail/$USER\n");
		return FALSE;
	}

	if (list && PURPLE_IS_GTK_BLIST(list) && PIDGIN_BLIST(list)->vbox)
		timer = g_timeout_add(2000, check_timeout, NULL);

	purple_signal_connect(conn_handle, "signed-on",
						plugin, PURPLE_CALLBACK(signon_cb), NULL);
	purple_signal_connect(conn_handle, "signed-off",
						plugin, PURPLE_CALLBACK(signoff_cb), NULL);

	return TRUE;
}
Exemplo n.º 6
0
/*
  ns_get_buddies
  Add buddies to watchlist
*/
void netsoul_get_buddies (PurpleConnection* gc)
{
  PurpleBlistNode *gnode, *cnode, *bnode;

  purple_debug_info("netsoul", "ns_get_buddies\n");

  for(gnode = purple_get_blist()->root; gnode; gnode = gnode->next) {
    if(!PURPLE_BLIST_NODE_IS_GROUP(gnode)) continue;
    for(cnode = gnode->child; cnode; cnode = cnode->next) {
      if(!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) continue;
      for(bnode = cnode->child; bnode; bnode = bnode->next) {
	if(!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) continue;
	if(((PurpleBuddy*)bnode)->account == gc->account)
	{
	  PurpleBuddy *buddy = (PurpleBuddy*)bnode;
	  gchar *photo = NULL;
	  purple_debug_info("netsoul", "netsoul_add_buddy %s\n", buddy->name);

	  NetsoulBuddy *nb = g_new0(NetsoulBuddy, 1);
	  buddy->proto_data = nb;
	  nb->login = g_strdup(buddy->name);
	  // Get photo
	  photo = g_strdup_printf("%s%s", NETSOUL_PHOTO_URL, buddy->name);

	  purple_util_fetch_url(photo, TRUE, NULL, FALSE, netsoul_got_photo, buddy);

	  // if contact is not already is watch list, add it
	  ns_watch_buddy(gc, buddy);
	}
      }
    }
  }
  // watch_log_user
  NetsoulData *ns = gc->proto_data;
  ns_watch_log_user(gc);
  ns_list_users(gc, ns->watchlist);
}
Exemplo n.º 7
0
void
lh_migrate_action_cb(PurplePluginAction *action)
{
    PurpleRequestFields *request;
    PurpleRequestFieldGroup *group;
    PurpleRequestField *field;

    /* It seems Purple is super-picky about the order of these first three calls */
    /* create a request */
    request = purple_request_fields_new();

    /* now create a field group */
    group = purple_request_field_group_new(NULL);
    /* and add that group to the request created above */
    purple_request_fields_add_group(request, group);

    /* create a field */
    field = purple_request_field_account_new("migrate_source_acct",
            _("Account"), NULL);

    /* mark the field as required */
    purple_request_field_set_required(field, TRUE);

    /* let's show offline accounts too */
    purple_request_field_account_set_show_all(field, TRUE);

    /* add the field to the group created above */
    purple_request_field_group_add_field(group, field);

    /* and finally we can create the request */
    purple_request_fields(purple_get_blist(), _("Listhandler - Copying"),
                          _("Choose the account to copy from:"), NULL, request,
                          _("C_opy"), G_CALLBACK(lh_migrate_source_request_cb),
                          _("_Cancel"), NULL, NULL, NULL, NULL, NULL);
    return;
}
static void buddy_set_priority_cb(PurpleBlistNode *node, gpointer priority) {
	purple_blist_node_set_int(node, "extended_sort_method_priority", GPOINTER_TO_INT(priority));
	pidgin_blist_refresh(purple_get_blist());
}
Exemplo n.º 9
0
static void blist_set_ontop(gboolean val) {
	if(!blist)
		return;

	gtk_window_set_keep_above(GTK_WINDOW(PIDGIN_BLIST(purple_get_blist())->window), val);
}
static void sort_method_ext_blist_sort(
	PurpleBlistNode *node, PurpleBuddyList *blist,
	GtkTreeIter group, GtkTreeIter *cur, GtkTreeIter *ret
) {
	GtkTreeIter tmp_iter;
	PidginBuddyList *gtkblist;

	gtkblist = PIDGIN_BLIST(purple_get_blist());
	

	if(!PURPLE_BLIST_NODE_IS_CONTACT(node) && !PURPLE_BLIST_NODE_IS_CHAT(node)) {
		sort_method_none(node, blist, group, cur, ret);
		return;	
	}

	/* Get first child of group. Insert immediately if group is empty. */
	if (!gtk_tree_model_iter_children(GTK_TREE_MODEL(gtkblist->treemodel), &tmp_iter, &group)) {
		gtk_tree_store_insert(gtkblist->treemodel, ret, &group, 0);
		return;
	}

	/* Go trough all children */
	do {
		GValue val;
		PurpleBlistNode *n;
		gint cmp1, cmp2, cmp3;

		/* Retrieve a BlistNode from a TreeModelNode */
		val.g_type=0;
		gtk_tree_model_get_value(GTK_TREE_MODEL(gtkblist->treemodel), &tmp_iter, NODE_COLUMN, &val);
		n = g_value_get_pointer(&val);

		/* Comparing... */
		cmp1 = compare(
			purple_prefs_get_int(PLUGIN_PREFS_PREFIX "/sort1"),
			purple_prefs_get_bool(PLUGIN_PREFS_PREFIX "/sort1_reverse"),
			node, n
		);
		cmp2 = compare(
			purple_prefs_get_int(PLUGIN_PREFS_PREFIX "/sort2"),
			purple_prefs_get_bool(PLUGIN_PREFS_PREFIX "/sort2_reverse"),
			node, n
		);
		cmp3 = compare(
			purple_prefs_get_int(PLUGIN_PREFS_PREFIX "/sort3"),
			purple_prefs_get_bool(PLUGIN_PREFS_PREFIX "/sort3_reverse"),
			node, n
		);

		/* Insert node before the current? */
		/* TODO: refactor */
		if(cmp1 < 0 ||
			(cmp1 == 0 &&
				(cmp2 < 0 ||
					(cmp2 == 0 &&
						(cmp3 < 0 ||
							(cmp3 == 0 && node < n)))))) {
			if(cur == NULL) {
				gtk_tree_store_insert_before(gtkblist->treemodel, ret, &group, &tmp_iter);
			} else {
				gtk_tree_store_move_before(gtkblist->treemodel, cur, &tmp_iter);
				*ret = *cur;
			}
			return;
		}

		g_value_unset(&val);

		/* Get next node */
	} while(gtk_tree_model_iter_next(GTK_TREE_MODEL(gtkblist->treemodel), &tmp_iter));

	/* Insert at the end */
	if(cur == NULL) {
		gtk_tree_store_append(gtkblist->treemodel, ret, &group);
	} else {
		gtk_tree_store_move_before(gtkblist->treemodel, cur, NULL);
		*ret = *cur;
	}
	return;
	
}
Exemplo n.º 11
0
//
// Callback that's invoked once the main JSON file is downloaded.
//
// If the SoupMessage returns a successful response then this callback will
// trigger the processing of the users asynchronously. It will also register a
// a callback that will process all new buddies that are added while Pidgin is
// running.
//
static void
budicons_got_json_response (SoupSession *session, SoupMessage *message, gpointer data) {
	BudiconsPlugin *plugin = (BudiconsPlugin *) data;

	{
		char *url = soup_uri_to_string(soup_message_get_uri(message), FALSE);
		g_print("Downloaded URL %s: %d\n", url, message->status_code);
		g_free(url);
	}

	if (! SOUP_STATUS_IS_SUCCESSFUL (message->status_code)) {
		g_print("SOUP Message was not successful (%d)\n", message->status_code);
		return;
	}


	const char *buffer = message->response_body->data;
	gsize length = (gsize) message->response_body->length;

	const char *mime = soup_message_headers_get_content_type(message->response_headers, NULL);
	if (! (EQ(mime, "application/json") || EQ(mime, "text/plain"))) {
		g_print("Got the wrong mime type (%s) for the JSON file\n", mime);
		return;
	}


	// Parse the JSON file
	GError *error = NULL;
	plugin->users = budicons_json_parse_users(buffer, length, &error);
	if (plugin->users == NULL) {
		char *url = soup_uri_to_string(soup_message_get_uri(message), FALSE);
		g_print("Failed to parse URL %s: %s\n", url, error->message);
		g_free(url);
		g_error_free(error);
		return;
	}


	// Register a callback for every new buddy added
	purple_signal_connect(
		purple_blist_get_handle(),
		"buddy-added",
		plugin->purple,
		PURPLE_CALLBACK(budicons_buddy_added_callback),
		plugin
	);


	// Collect the buddies to process
	PurpleBuddyList *list = purple_get_blist();
	if (list == NULL) {return;}

	plugin->buddies = NULL;
	for (PurpleBlistNode *group = list->root; group; group = group->next) {
		if (! PURPLE_BLIST_NODE_IS_GROUP(group)) {continue;}

		for (PurpleBlistNode *contact = group->child; contact; contact = contact->next) {
			if (! PURPLE_BLIST_NODE_IS_CONTACT(contact)) {continue;}

			for (PurpleBlistNode *blist = contact->child; blist; blist = blist->next) {
				if (! PURPLE_BLIST_NODE_IS_BUDDY(blist)) {continue;}

				PurpleBuddy *buddy = (PurpleBuddy *) blist;
				plugin->buddies = g_slist_prepend(plugin->buddies, buddy);
			}
		}
	}


	// Start a few workers that will process the buddies registered so far
	plugin->buddy_iter = plugin->buddies;
	guint workers = budicons_prefs_get_workers();
	for (guint i = 0; i < workers; ++i) {

		// No more buddies to process
		if (plugin->buddy_iter == NULL) {break;}

		// Create a new worker
		BudiconsWorker *worker = g_new0(BudiconsWorker, 1);
		worker->plugin = plugin;
		worker->id = i;
		g_print("[%d] Started a new worker\n", worker->id);

		budicons_worker_iter(worker);
	}
}