Beispiel #1
0
static void gfire_game_manager_remove_cb(GtkBuilder *p_builder, GtkWidget *p_button)
{
	if (!p_builder)
	{
		purple_debug_error("gfire", "Couldn't build game manager interface.\n");
		return;
	}

	GtkWidget *edit_game_combo = GTK_WIDGET(gtk_builder_get_object(p_builder, "edit_game_combo"));

	gchar *selected_game = gtk_combo_box_get_active_text(GTK_COMBO_BOX(edit_game_combo));
	if (selected_game)
	{
		guint32 game_id = gfire_game_id(selected_game);
		g_free(selected_game);

		if(game_id == 0)
		{
			purple_notify_message(NULL, PURPLE_NOTIFY_MSG_ERROR, _("Manage Games: error"),
								  _("Couldn't remove game"), _("No such game, please try again!"), NULL, NULL);
			return;
		}

		GList *cur = gfire_games_config;
		while(cur)
		{
			if(((gfire_game_configuration*)cur->data)->game_id == game_id)
				break;
			cur = g_list_next(cur);
		}

		if(!cur)
		{
			purple_notify_message(NULL, PURPLE_NOTIFY_MSG_ERROR, _("Manage Games: error"),
								  _("Couldn't remove game"), _("This game is not yet added as it seems, please add it first!"), NULL, NULL);
			return;
		}

		gfire_game_configuration_free((gfire_game_configuration*)cur->data);
		gfire_games_config = g_list_delete_link(gfire_games_config, cur);

		gfire_game_save_config_xml();

		purple_notify_message(NULL, PURPLE_NOTIFY_MSG_INFO, _("Manage Games: game removed"),
							  _("Game removed"), _("The game has been successfully removed."), NULL, NULL);
	}
	else
		purple_notify_message(NULL, PURPLE_NOTIFY_MSG_ERROR, _("Manage Games: error"),
							  _("Couldn't remove game"), _("Please try again. Make sure you select a game to remove."), NULL, NULL);

	gfire_game_manager_reload_ui(p_builder);
}
Beispiel #2
0
void gfire_update_games_list_cb(PurpleUtilFetchUrlData *p_url_data, gpointer p_data, const gchar *p_buf, gsize p_len, const gchar *p_error_message)
{
	gfire_games_update_done();

	if (!p_data || !p_buf || !p_len)
		purple_debug_error("gfire", "An error occured while updating the games list. Website down?\n");
	else if(purple_util_write_data_to_file("gfire_games.xml", p_buf, p_len))
	{
		gfire_game_load_games_xml();

		gchar *version = gfire_game_get_version_str();
		gchar *msg = g_strdup_printf(_("The Games List has been updated to version: %s."), version);
		g_free(version);
#ifdef USE_NOTIFICATIONS
		if(purple_account_get_bool(purple_connection_get_account(p_data), "use_notify", TRUE))
			gfire_notify_system(_("New Gfire Game List Version"), msg);
		else
#endif // USE_NOTIFICATIONS
			purple_notify_message(NULL, PURPLE_NOTIFY_MSG_INFO, _("New Gfire Game List Version"),
								  _("New Gfire Game List Version"), msg, NULL, NULL);
		g_free(msg);
	}
	else
		purple_debug_error("gfire", "An error occured while updating the games list. Website down?\n");
}
static gboolean
plugin_load(PurplePlugin *plugin) {
	purple_notify_message(plugin, PURPLE_NOTIFY_MSG_INFO, "Whisper Library activated!",
		"This is the whisper library plugin :)", NULL, NULL, NULL);

	return TRUE;
}
Beispiel #4
0
/* This function is the callback for the plugin action we added. All we're
 * doing here is displaying a message. When the user selects the plugin
 * action, this function is called. */
static void
plugin_action_test_cb (PurplePluginAction * action)
{
	purple_notify_message (action->plugin, PURPLE_NOTIFY_MSG_INFO,
		"Plugin Actions Test", "This is a plugin actions test :)", NULL, NULL,
		NULL, NULL);
}
Beispiel #5
0
static void tgprpl_xfer_send_init (PurpleXfer *X) {
  struct tgp_xfer_send_data *data = X->data;
  
  purple_xfer_start (X, -1, NULL, 0);
  
  const char *file = purple_xfer_get_filename (X);
  const char *localfile = purple_xfer_get_local_filename (X);
  const char *who = purple_xfer_get_remote_user (X);
  debug ("xfer_on_init (file=%s, local=%s, who=%s)", file, localfile, who);
  
  tgl_peer_t *P = find_peer_by_name (data->conn->TLS, who);
  if (P) {
    if (tgl_get_peer_type (P->id) != TGL_PEER_ENCR_CHAT) {
      tgl_do_send_document (data->conn->TLS, P->id, (char*) localfile, NULL,
                            0, TGL_SEND_MSG_FLAG_DOCUMENT_AUTO, tgprpl_xfer_on_finished, data);
    }
    else {
      purple_notify_message (_telegram_protocol, PURPLE_NOTIFY_MSG_ERROR, "Not supported",
                             "Sorry, sending documents to encrypted chats not yet supported.",
                             NULL, NULL, NULL);
    }
  }
  
  data->timer = purple_timeout_add (100, tgprpl_xfer_upload_progress, X);
}
static void
plugin_action_test_cb (PurplePluginAction * action)
{
	purple_notify_message (question_and_answer_plugin, PURPLE_NOTIFY_MSG_INFO,
		"Question & Answer client", "This is a plugin of Question and Answer client", NULL, NULL,
		NULL);
}
Beispiel #7
0
static gboolean
plugin_load(PurplePlugin *plugin)
{
	purple_notify_message(plugin, PURPLE_NOTIFY_MSG_INFO, "Hi there!",
	                      "This is the gotr plugin", NULL, NULL, NULL);

	return TRUE;
}
void music_messaging_done_session(const int session)
{
	MMConversation *mmconv = (MMConversation *)g_list_nth_data(conversations, session);
	
	purple_notify_message(plugin_pointer, PURPLE_NOTIFY_MSG_INFO, "Session",
						"Session Complete", NULL, NULL, NULL);
	
	session_end(mmconv);
}
Beispiel #9
0
static gboolean
plugin_load (PurplePlugin * plugin, GError ** error)
{
	purple_notify_message (plugin, PURPLE_NOTIFY_MSG_INFO, "Hello World!",
		"This is the Hello World! plugin :)", NULL, NULL,
		NULL, NULL);

	return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// Registers the LNR window and requests TS session change notifications.
/////////////////////////////////////////////////////////////////////////////
static gboolean plugin_load(PurplePlugin *plugin)
{
    WNDCLASSEX wcx;
    HWND hwnd;
    wcx.cbSize = sizeof(WNDCLASSEX);
    wcx.lpszClassName = "pidgin_lockonaway";
    wcx.lpfnWndProc = (WNDPROC)LnrWindowProc;
    wcx.style = wcx.cbClsExtra = wcx.cbWndExtra = 0;
    wcx.hbrBackground = NULL;
    wcx.hInstance = NULL;
    wcx.hIcon = NULL;
    wcx.hCursor = NULL;
    wcx.hIconSm = NULL;

    // Register the class with Windows
    if(!RegisterClassEx(&wcx))
    {
        purple_notify_message(plugin, PURPLE_NOTIFY_MSG_INFO, "Lock 'n' Roll",
            "RegisterClassEx failed, sorry.", NULL, NULL, NULL);
        return FALSE;
    }

    hwnd = CreateWindowEx(0, "pidgin_lockonaway", "", 0, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, NULL, NULL, NULL, NULL);
    if(hwnd == NULL)
    {
        purple_notify_message(plugin, PURPLE_NOTIFY_MSG_INFO, "Lock 'n' Roll",
            "CreateWindowEx failed, sorry.", NULL, NULL, NULL);
        return FALSE;
    }

    if(!WTSRegisterSessionNotification(hwnd, NOTIFY_FOR_THIS_SESSION))
    {
        purple_notify_message(plugin, PURPLE_NOTIFY_MSG_INFO, "Lock 'n' Roll",
            "WTSRegisterSessionNotification failed, sorry.", NULL, NULL, NULL);
        return FALSE;
    }

    lnr_reactivate_status = NULL;
    lnr_handle = plugin;
    lnr_hwnd = hwnd;

    return TRUE;
}
Beispiel #11
0
void send_inline_picture_done (struct tgl_state *TLS, void *extra, int success, struct tgl_message *msg) {
  if (!success) {
    char *errormsg = g_strdup_printf ("%d: %s", TLS->error_code, TLS->error);
    failure (errormsg);
    purple_notify_message (_telegram_protocol, PURPLE_NOTIFY_MSG_ERROR, _("Sending image failed."),
                           errormsg, NULL, NULL, NULL);
    g_free (errormsg);
    return;
  }
}
Beispiel #12
0
void irc_msg_time(struct irc_conn *irc, const char *name, const char *from, char **args)
{
	PurpleConnection *gc;

	gc = purple_account_get_connection(irc->account);
	if (gc == NULL || args == NULL || args[2] == NULL)
		return;

	purple_notify_message(gc, PURPLE_NOTIFY_MSG_INFO, _("Time Response"),
			    _("The IRC server's local time is:"),
			    args[2], NULL, NULL);
}
Beispiel #13
0
static void *
tinyurl_notify_uri(const char *uri)
{
	char *fullurl = NULL;
	GntWidget *win;
	PurpleHttpConnection *hc;
	const gchar *tiny_url;

	/* XXX: The following expects that finch_notify_message gets called. This
	 * may not always happen, e.g. when another plugin sets its own
	 * notify_message. So tread carefully. */
	win = purple_notify_message(NULL, PURPLE_NOTIFY_MSG_INFO, _("URI"), uri,
			_("Please wait while TinyURL fetches a shorter URL ..."), NULL, NULL, NULL);
	if (!GNT_IS_WINDOW(win) || !g_object_get_data(G_OBJECT(win), "info-widget"))
		return win;

	tiny_url = g_hash_table_lookup(tinyurl_cache, uri);
	if (tiny_url) {
		tinyurl_notify_tinyuri(win, tiny_url);
		return win;
	}

	if (g_ascii_strncasecmp(uri, "http://", 7) && g_ascii_strncasecmp(uri, "https://", 8)) {
		fullurl = g_strdup_printf("%shttp%%3A%%2F%%2F%s",
				purple_prefs_get_string(PREF_URL), purple_url_encode(uri));
	} else {
		fullurl = g_strdup_printf("%s%s", purple_prefs_get_string(PREF_URL),
				purple_url_encode(uri));
	}

	g_object_set_data_full(G_OBJECT(win), "gnttinyurl-original", g_strdup(uri), g_free);

	/* Store the return value of purple_http_get and destroy that when win
	 * is destroyed, so that the callback for purple_http_get does not try
	 * to molest a non-existent window
	 */
	hc = purple_http_get(NULL, tinyurl_notify_fetch_cb, win, fullurl);
	g_free(fullurl);
	g_signal_connect_swapped(G_OBJECT(win), "destroy",
			G_CALLBACK(purple_http_conn_cancel), hc);

	return win;
}
Beispiel #14
0
void
campfire_join_chat(PurpleConnection * gc, GHashTable * data)
{
	GList *hash_keys = NULL;
	CampfireConn *campfire = gc->proto_data;
	gchar *desired_name = NULL;
	gchar *id   = NULL;
	gchar *name = NULL;
	gboolean room_name_error = FALSE;


	purple_debug_info("campfire", "1: %p\n", data);
	desired_name = g_hash_table_lookup(data, "room");
	purple_debug_info("campfire", "2\n");
	if (desired_name) {
		campfire->desired_room = g_strdup(desired_name);
		campfire->needs_join = TRUE;
		hash_keys = g_hash_table_get_keys(data);
		g_list_foreach(hash_keys, campfire_print_key, NULL);
		/* do this if you haven't done a room query yet */
		if (!campfire->roomlist) {
			campfire_roomlist_get_list(gc);
		} else {
			campfire_join_chat_after_room_query(campfire, campfire->desired_room);
		}
	} else {
		id   = g_hash_table_lookup(data,  "id");
		name = g_hash_table_lookup(data, "name");
		if (!id || !name) {
			room_name_error = TRUE;
			purple_notify_message(campfire->gc, PURPLE_NOTIFY_MSG_ERROR,
			                      "campfire error",
			                      "hash table error.",
			                      NULL,
			                      NULL,
			                      NULL);
		}
		if (!room_name_error) {
			purple_debug_info("campfire", "trying to JOIN CHAT room id %s\n", id);
			campfire_room_join(campfire, id, name);
		}
	}
}
void music_messaging_change_failed(const int session, const char *id, const char *command, const char *parameters)
{
	MMConversation *mmconv = (MMConversation *)g_list_nth_data(conversations, session);
	
	purple_notify_message(plugin_pointer, PURPLE_NOTIFY_MSG_INFO, command,
                        parameters, NULL, NULL, NULL);
	
	if (mmconv->started)
	{
		if (mmconv->originator)
		{
			GString *to_send = g_string_new("");
			g_string_append_printf(to_send, "##MM## failed %s %s %s##MM##", id, command, parameters);
			
			purple_conv_im_send(PURPLE_CONV_IM(mmconv->conv), to_send->str);
		} else
		{
			/* Do nothing. If they aren't the originator, then they can't confirm. */
		}
	}
}
Beispiel #16
0
static void gfire_game_manager_add_cb(GtkBuilder *p_builder, GtkWidget *p_button)
{
	if(!p_builder)
	{
		purple_debug_error("gfire", "Couldn't access game manager interface.\n");
		return;
	}

	GtkWidget *add_game_entry = GTK_WIDGET(gtk_builder_get_object(p_builder, "add_game_entry"));
	GtkWidget *add_detection_button = GTK_WIDGET(gtk_builder_get_object(p_builder, "add_detection_button"));
	GtkWidget *add_executable_check_button = GTK_WIDGET(gtk_builder_get_object(p_builder, "add_executable_check_button"));
	GtkWidget *add_launch_button = GTK_WIDGET(gtk_builder_get_object(p_builder, "add_launch_button"));

	GtkWidget *add_prefix_entry = GTK_WIDGET(gtk_builder_get_object(p_builder, "add_prefix_entry"));

	const gchar *game_name = gtk_entry_get_text(GTK_ENTRY(add_game_entry));
	gchar *game_detect = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(add_detection_button));
	gboolean game_launch_use_detect = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(add_executable_check_button));
	gchar *game_launch = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(add_launch_button));

	const gchar *game_prefix = gtk_entry_get_text(GTK_ENTRY(add_prefix_entry));

	if (game_name && game_detect && ((!game_launch_use_detect && game_launch) || game_launch_use_detect))
	{
		guint32 game_id;

		game_id = gfire_game_id(game_name);

		if(game_id == 0)
		{
			purple_notify_message(NULL, PURPLE_NOTIFY_MSG_ERROR, _("Manage Games: error"), _("Couldn't add game"),
							  _("There's no such game, please try again."), NULL, NULL);
			g_free(game_detect);
			g_free(game_launch);
			return;
		}

		if(!gfire_game_config_by_id(game_id))
		{
#ifndef _WIN32
			gchar real_game_detect[PATH_MAX];
			realpath(game_detect, real_game_detect);
#else
			gchar *real_game_detect = game_detect;
#endif // _WIN32

			gfire_game_configuration *gconf = gfire_game_configuration_create(game_id, real_game_detect,
																			  game_launch_use_detect ? real_game_detect :
																			  game_launch, game_prefix);

			gfire_games_config = g_list_append(gfire_games_config, gconf);
			gfire_game_config_sort();
			gfire_game_save_config_xml();

			purple_notify_message(NULL, PURPLE_NOTIFY_MSG_INFO, _("Manage Games: game added"),
							  game_name, _("The game has been successfully added."), NULL, NULL);
		}
		else
		{
			purple_notify_message(NULL, PURPLE_NOTIFY_MSG_INFO, _("Manage Games: warning"), _("Game already added"),
						  _("This game is already added, you can configure it if you want."), NULL, NULL);

			g_free(game_launch);
			g_free(game_detect);

			return;
		}

		g_free(game_launch);
		g_free(game_detect);
	}
	else
	{
		purple_notify_message(NULL, PURPLE_NOTIFY_MSG_ERROR, _("Manage Games: error"),
					  _("Couldn't add game"), _("Please try again. Make sure you fill in all fields."), NULL, NULL);
		return;
	}

	gfire_game_manager_reload_ui(p_builder);
}
Beispiel #17
0
void
campfire_join_chat_after_room_query(CampfireConn *campfire, gchar *room_name)
{
	/*alternate when not using "Room List" */
	/* @TODO: error checking may be too simple */
	GList *fields;
	GList *rooms;
	PurpleRoomlistRoom *r;
	PurpleRoomlistField *f;
	gsize i;
	gsize list_size;
	gsize id_field_index = 0;
	gboolean found = FALSE;
	gchar *id   = NULL;
	gchar *name = NULL;
	gboolean room_name_error = FALSE;

	fields = purple_roomlist_get_fields(campfire->roomlist);
	g_list_foreach(fields, campfire_print_field_name, NULL);
	list_size = g_list_length(fields);

	/* find "id" field */
	for (i = 0; i < list_size; i++) {
		f = g_list_nth_data(fields, i);
		purple_debug_info("campfire", "field name: %s\n", f->name);
		if (strcmp("id", f->name) == 0) {
			id_field_index = i;
			found = TRUE;
			break;
		}
	}
	if (!found) {
		room_name_error = TRUE;
		purple_notify_message(campfire->gc, PURPLE_NOTIFY_MSG_ERROR,
		                      "campfire error",
		                      "couldn't find 'id' field in roomlist.",
		                      NULL,
		                      NULL,
		                      NULL);
	} else {
		found = FALSE;
	}
	rooms = campfire->roomlist->rooms;
	list_size = g_list_length(rooms);
	purple_debug_info("campfire", "join debug 6\n");

	/* find typed/chosen room name in available room names */
	for (i = 0; i < list_size; i++) {
		r = (PurpleRoomlistRoom *)g_list_nth_data(rooms, i);
		if (strcmp(r->name, room_name) == 0) {
			purple_debug_info("campfire", "room found\n");
			purple_debug_info("campfire", "room desired: %s\n", room_name);
			purple_debug_info("campfire", "room found: %s\n", r->name);
			id = g_list_nth_data(r->fields, id_field_index);
			name = r->name;
			found = TRUE;
			break;
		}
	}

	if (!found) {
		room_name_error = TRUE;
		purple_notify_message(campfire->gc, PURPLE_NOTIFY_MSG_ERROR,
		                      "campfire error",
		                      "couldn't find room name in roomlist.",
		                      room_name,
		                      NULL,
		                      NULL);
	}
	if (!room_name_error) {
		purple_debug_info("campfire", "trying to JOIN CHAT room id %s\n", id);
		campfire_room_join(campfire, id, name);
	}
}
static gboolean
intercept_received(PurpleAccount *account, char **sender, char **message, PurpleConversation *conv, int *flags)
{
	MMConversation *mmconv;
	
	if (conv == NULL) {
		/* XXX: This is just to avoid a crash (#2726).
		 *      We may want to create the conversation instead of returning from here
		 */
		return FALSE;
	}

	mmconv = mmconv_from_conv(conv);
	
	purple_debug_misc("purple-musicmessaging", "Intercepted: %s\n", *message);
	if (strstr(*message, MUSICMESSAGING_PREFIX))
	{
		char *parsed_message = strtok(strstr(*message, MUSICMESSAGING_PREFIX), "<");
		purple_debug_misc("purple-musicmessaging", "Received an MM Message: %s\n", parsed_message);
				
		if (mmconv->started)
		{
			if (strstr(parsed_message, "request"))
			{
				if (mmconv->originator)
				{
					int session = mmconv_from_conv_loc(conv);
					char *id = (mmconv->conv)->name;
					char *command;
					char *parameters;
					
					purple_debug_misc("purple-musicmessaging", "Sending request to gscore.\n");
					
					/* Get past the first two terms - '##MM##' and 'request' */
					strtok(parsed_message, " "); /* '##MM##' */
					strtok(NULL, " "); /* 'request' */
					
					command = strtok(NULL, " ");
					parameters = strtok(NULL, "#");
					
					send_change_request (session, id, command, parameters);
					
				}
			} else if (strstr(parsed_message, "confirm"))
			{
				if (!mmconv->originator)
				{
					int session = mmconv_from_conv_loc(conv);
					char *command;
					char *parameters;
					
					purple_debug_misc("purple-musicmessaging", "Sending confirmation to gscore.\n");
					
					/* Get past the first two terms - '##MM##' and 'confirm' */
					strtok(parsed_message, " "); /* '##MM##' */
					strtok(NULL, " "); /* 'confirm' */
					
					command = strtok(NULL, " ");
					parameters = strtok(NULL, "#");
					
					send_change_confirmed (session, command, parameters);
				}
			} else if (strstr(parsed_message, "failed"))
			{
				char *id;
				char *command;
				
				/* Get past the first two terms - '##MM##' and 'confirm' */
				strtok(parsed_message, " "); /* '##MM##' */
				strtok(NULL, " "); /* 'failed' */
				
				id = strtok(NULL, " ");
				command = strtok(NULL, " ");
				/* char *parameters = strtok(NULL, "#"); DONT NEED PARAMETERS */
				
				if ((mmconv->conv)->name == id)
				{
					purple_notify_message(plugin_pointer, PURPLE_NOTIFY_MSG_ERROR, 
							    _("Music Messaging"),
							    _("There was a conflict in running the command:"), command, NULL, NULL);
				}
			}
		}
		
		message = 0;
	}
	else if (strstr(*message, MUSICMESSAGING_START_MSG))
	{
		purple_debug_misc("purple-musicmessaging", "Received MM request.\n");
		if (!(mmconv->originator))
		{
			mmconv->requested = TRUE;
			return FALSE;
		}
		
	}
	else if (strstr(*message, MUSICMESSAGING_CONFIRM_MSG))
	{
		purple_debug_misc("purple-musicmessagin", "Received MM confirm.\n");
		
		if (mmconv->originator)
		{
			start_session(mmconv);
			return FALSE;
		}
	}
	else
	{
		return FALSE;
		/* Do nothing. */
	}
	return TRUE;
}
Beispiel #19
0
/* process reply to get_memo packet */
void qq_process_get_buddy_memo(PurpleConnection *gc, guint8* data, gint data_len,
		guint32 update_class, guint32 action)
{
	gchar **segments;
	gint bytes;
	gint index;
	guint8 rcv_cmd;
	guint32 rcv_uid;
	guint8 unk1_8;
	guint8 is_success;

	g_return_if_fail(NULL != gc && NULL != data && 0 != data_len);
	/*
	   qq_show_packet("MEMO REACH", data, data_len);
	   */
	purple_debug_info("QQ", "action=0x%02X\n", action);

	bytes = 0;

	/* TX looks a bit clever than before... :) */
	bytes += qq_get8(&rcv_cmd, data+bytes);
	purple_debug_info("QQ", "rcv_cmd=0x%02X\n", rcv_cmd);

	/* it's possible that packet contains no buddy uid and no memo!!!
	 * go to next step according to previous action sent */
	if (1 == data_len) { /* only one byte */
		purple_debug_info("QQ", "memo packet contains no buddy uid and memo...\n");
		if (QQ_BUDDY_MEMO_MODIFY == action) {
			qq_create_buddy_memo(gc, (guint32)update_class, QQ_BUDDY_MEMO_MODIFY);
			return;
		}
		return;
	}

	switch (rcv_cmd) {
		case QQ_BUDDY_MEMO_MODIFY:
		case QQ_BUDDY_MEMO_REMOVE:
			bytes += qq_get8(&is_success, data+bytes);
			if (QQ_BUDDY_MEMO_REQUEST_SUCCESS == is_success) {
				purple_notify_message(gc, PURPLE_NOTIFY_MSG_INFO,
						_("Memo Modify"), _("Server says:"),
						_("Your request was accepted."),
						NULL, NULL);
				purple_debug_info("QQ", "memo change succeessfully!\n");
			}
			else {
				purple_notify_message(gc, PURPLE_NOTIFY_MSG_INFO,
						_("Memo Modify"), _("Server says:"),
						_("Your request was rejected."),
						NULL, NULL);
				purple_debug_info("QQ", "memo change failed\n");
			}
			break;
		case QQ_BUDDY_MEMO_GET:
			bytes += qq_get32(&rcv_uid, data+bytes);
			purple_debug_info("QQ", "rcv_uid=%u\n", rcv_uid);
			bytes += qq_get8(&unk1_8, data+bytes);
			purple_debug_info("QQ", "unk1_8=0x%02X\n", unk1_8);
			segments = g_new0(gchar*, QQ_MEMO_SIZE);
			for (index = 0; index < QQ_MEMO_SIZE; index++) {
				/* get utf8 string */
				bytes += qq_get_vstr(&segments[index], QQ_CHARSET_DEFAULT, data+bytes);
				/*
				   purple_debug_info("QQ", "bytes:%d, seg:%s\n", bytes, segments[index]);
				   */
			}

			/* common action, update buddy memo */
			update_buddy_memo(gc, rcv_uid, segments[QQ_MEMO_ALIAS]);

			/* memo is thing that we regard our buddy as, so we need one more buddy_uid */
			memo_modify_dialogue(gc, rcv_uid, segments, action);
			break;
		default:
			purple_debug_info("QQ", "received an UNKNOWN memo cmd!!!\n");
			break;
	}
}
static void
send_online_buddy_cb (PurpleBlistNode *cnode, gpointer data)
{
	PurplePlugin *plugin = (PurplePlugin *)data;
	PurpleConnection *gc;
   GSList *blist;
   PurpleBlistNode *gnode, *node;
   PurpleBuddy *b, *buddy;
   PurpleGroup *g, *check_group;
   const char *name, *gname, *receiver;
   int count = 0;
   PurpleAccount *account;
	PurpleIMConversation *im;
	gchar *buddylist = NULL;
	int total, flag = 0, counter = 0;
	gchar *group_info;

   const gchar *groupname = purple_group_get_name(data);
	purple_debug_info("send-option", "The group selected is: %s", groupname);

   buddy = (PurpleBuddy *)cnode;
	purple_debug_info("send-option", "Inside send_online_buddy_cb");
	receiver = purple_buddy_get_name(buddy); 
	purple_debug_info("send-option", "Receiver name: %s", receiver);
	account = purple_buddy_get_account(buddy);
	gc = purple_account_get_connection(account);

	im = purple_conversations_find_im_with_account(receiver, purple_connection_get_account(gc));
       if(im)
	      purple_debug_info("send-option", "Yayy, IM!");
       else
         purple_debug_info("send-option", "Boo! No IM :(");
	if (im == NULL)
      im = purple_im_conversation_new(purple_connection_get_account(gc), receiver);

   for(gnode = purple_blist_get_buddy_list()->root;
       gnode != NULL;
       gnode = gnode->next)
   {
	    if (PURPLE_IS_GROUP(gnode)) {
         g = (PurpleGroup*)gnode; 
		 /*fishy. It says g may be uninitiliazed here. What can I initilalie g to in the else, to get rid of the warning*/  	
         if (g != data)
			   continue;
			else
            break;
       }
	}

   gname = purple_group_get_name(g);
	total = purple_counting_node_get_online_count(PURPLE_COUNTING_NODE(g));;
   purple_debug_info("send-option", "%s (%d): \n",gname, total);
   group_info = g_strdup_printf("%s (%d):\n",gname, total);
	buddylist = g_strconcat(group_info, "\t","\t", NULL);
			 
   for (blist = purple_blist_get_buddies(); 
	  	  blist != NULL;
		  blist = blist->next)
   {
       node = blist->data;

       if (PURPLE_IS_BUDDY(node)) {
		 b = (PurpleBuddy*)node;
       name = purple_buddy_get_alias(b);                  
       check_group = purple_buddy_get_group(b);
                  
       if (data == check_group && PURPLE_BUDDY_IS_ONLINE(b)) {
          ++count;
			 ++counter;

	       if (flag == 1 && counter != total) {
             buddylist = g_strconcat(name, ",\t", NULL);
             flag = 0;
          } else if (flag == 1 && counter == total) {
             buddylist = g_strconcat(name, ".\t", NULL);
				 purple_debug_info(NULL, "%s", buddylist);	
             purple_conversation_send(PURPLE_CONVERSATION(im), buddylist); 
				 buddylist = NULL;
				 count = 0;
			 } else{
				 if (count <= 20 && counter != total) {
				  buddylist = g_strconcat(buddylist, name, ",\t", NULL);	/*fishy cant insert newline*/	
				 } else {
					if (counter == total)
						 buddylist = g_strconcat(buddylist, name, ".\t", NULL);
					else
                   buddylist = g_strconcat(buddylist, name, ",\t", NULL);
						 
                   purple_debug_info(NULL, "%s", buddylist);	
                   purple_conversation_send(PURPLE_CONVERSATION(im), buddylist); 
						 buddylist = NULL;
						 count = 0;
						 flag = 1;
             }
	       }
          }
	    }
	}
   purple_debug_info("send-option", "The counter is (%d): \n",counter);
   
   purple_notify_message (plugin, PURPLE_NOTIFY_MSG_INFO,
		    "Send online buddies", "Successfully sent your online buddies :)", NULL, NULL,
		     NULL, NULL);
	
	g_free(buddylist);
}
Beispiel #21
0
static void gfire_game_manager_edit_cb(GtkBuilder *p_builder, GtkWidget *p_button)
{

	if (!p_builder)
	{
		purple_debug_error("gfire", "Couldn't access game manager interface.\n");
		return;
	}

	GtkWidget *edit_game_combo = GTK_WIDGET(gtk_builder_get_object(p_builder, "edit_game_combo"));
	GtkWidget *edit_detection_button = GTK_WIDGET(gtk_builder_get_object(p_builder, "edit_detection_button"));
	GtkWidget *edit_executable_check_button = GTK_WIDGET(gtk_builder_get_object(p_builder, "edit_executable_check_button"));
	GtkWidget *edit_launch_button = GTK_WIDGET(gtk_builder_get_object(p_builder, "edit_launch_button"));
	GtkWidget *edit_prefix_entry = GTK_WIDGET(gtk_builder_get_object(p_builder, "edit_prefix_entry"));

	gchar *game_name = gtk_combo_box_get_active_text(GTK_COMBO_BOX(edit_game_combo));
	gchar *game_detect = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(edit_detection_button));
	gboolean game_launch_use_detect = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(edit_executable_check_button));
	gchar *game_launch = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(edit_launch_button));

	const gchar *game_prefix = gtk_entry_get_text(GTK_ENTRY(edit_prefix_entry));

	if (game_name && game_detect && ((!game_launch_use_detect && game_launch) || game_launch_use_detect))
	{
		guint32 game_id;

		game_id = gfire_game_id(game_name);

		gfire_game_configuration *gconf = (gfire_game_configuration*)gfire_game_config_by_id(game_id);

		if (gconf)
		{
#ifndef _WIN32
			gchar real_game_detect[PATH_MAX];
			realpath(game_detect, real_game_detect);
#else
			gchar *real_game_detect = game_detect;
#endif // _WIN32

			if(gconf->detect_file)
				g_free(gconf->detect_file);

			gconf->detect_file = g_strdup(real_game_detect);

			if(gconf->launch_file)
				g_free(gconf->launch_file);

			gconf->launch_file = g_strdup(game_launch_use_detect ? real_game_detect : game_launch);

			if(gconf->launch_prefix)
				g_free(gconf->launch_prefix);

			gconf->launch_prefix = g_strdup(game_prefix);
		}
		else
		{
			purple_notify_message(NULL, PURPLE_NOTIFY_MSG_INFO, _("Manage Games: warning"), _("Game launch data not found"),
						  _("This game is not yet added as it seems, please add it first!"), NULL, NULL);
			g_free(game_launch);
			g_free(game_detect);
			g_free(game_name);

			return;
		}

		g_free(game_launch);
		g_free(game_detect);
		g_free(game_name);

		gfire_game_save_config_xml();

		purple_notify_message(NULL, PURPLE_NOTIFY_MSG_INFO, _("Manage Games: game edited"), _("Game edited"), _("The game has been successfully edited."), NULL, NULL);
	}
	else
	{
		purple_notify_message(NULL, PURPLE_NOTIFY_MSG_ERROR, _("Manage Games: error"),
					  _("Couldn't edit game"), _("Please try again. Make sure you fill in all fields."), NULL, NULL);
		return;
	}

	gfire_game_manager_reload_ui(p_builder);
}
Beispiel #22
0
static void
purple_xfer_choose_file_ok_cb(void *user_data, const char *filename)
{
	PurpleXfer *xfer;
	PurpleXferType type;
	struct stat st;
	gchar *dir;

	xfer = (PurpleXfer *)user_data;
	type = purple_xfer_get_type(xfer);

	if (g_stat(filename, &st) != 0) {
		/* File not found. */
		if (type == PURPLE_XFER_RECEIVE) {
#ifndef _WIN32
			int mode = W_OK;
#else
			int mode = F_OK;
#endif
			dir = g_path_get_dirname(filename);

			if (g_access(dir, mode) == 0) {
				purple_xfer_request_accepted(xfer, filename);
			} else {
				purple_xfer_ref(xfer);
				purple_notify_message(
					NULL, PURPLE_NOTIFY_MSG_ERROR, NULL,
					_("Directory is not writable."), NULL,
					(PurpleNotifyCloseCallback)purple_xfer_choose_file, xfer);
			}

			g_free(dir);
		}
		else {
			purple_xfer_show_file_error(xfer, filename);
			purple_xfer_cancel_local(xfer);
		}
	}
	else if ((type == PURPLE_XFER_SEND) && (st.st_size == 0)) {

		purple_notify_error(NULL, NULL,
						  _("Cannot send a file of 0 bytes."), NULL);

		purple_xfer_cancel_local(xfer);
	}
	else if ((type == PURPLE_XFER_SEND) && S_ISDIR(st.st_mode)) {
		/*
		 * XXX - Sending a directory should be valid for some protocols.
		 */
		purple_notify_error(NULL, NULL,
						  _("Cannot send a directory."), NULL);

		purple_xfer_cancel_local(xfer);
	}
	else if ((type == PURPLE_XFER_RECEIVE) && S_ISDIR(st.st_mode)) {
		char *msg, *utf8;
		utf8 = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
		msg = g_strdup_printf(
					_("%s is not a regular file. Cowardly refusing to overwrite it.\n"), utf8);
		g_free(utf8);
		purple_notify_error(NULL, NULL, msg, NULL);
		g_free(msg);
		purple_xfer_request_denied(xfer);
	}
	else if (type == PURPLE_XFER_SEND) {
#ifndef _WIN32
		int mode = R_OK;
#else
		int mode = F_OK;
#endif

		if (g_access(filename, mode) == 0) {
			purple_xfer_request_accepted(xfer, filename);
		} else {
			purple_xfer_ref(xfer);
			purple_notify_message(
				NULL, PURPLE_NOTIFY_MSG_ERROR, NULL,
				_("File is not readable."), NULL,
				(PurpleNotifyCloseCallback)purple_xfer_choose_file, xfer);
		}
	}
	else {
		purple_xfer_request_accepted(xfer, filename);
	}

	purple_xfer_unref(xfer);
}
static void
send_group_list_cb (PurpleBlistNode *cnode, gpointer data)
{
	PurplePlugin *plugin = (PurplePlugin *)data;
	PurpleBuddy *buddy;
	const char *receiver, *gname = NULL;
	PurpleAccount *account;
	PurpleIMConversation *im;
	PurpleConnection *gc;
	PurpleBlistNode *gnode;
	PurpleGroup *g;
	gchar *grouptotal, *grouplist = NULL;
	int count = 0, counter = 0, flag = 0, total = 0;

	buddy = (PurpleBuddy *)cnode;
	purple_debug_info("send-option", "Inside send_group_list_cb");
	receiver = purple_buddy_get_name(buddy); 
	purple_debug_info("send-option", "Receiver name: %s", receiver);
	account = purple_buddy_get_account(buddy);
	gc = purple_account_get_connection(account);

	im = purple_conversations_find_im_with_account(receiver, purple_connection_get_account(gc));
       if(im)
	      purple_debug_info("send-option", "Yayy, IM!");
       else
         purple_debug_info("send-option", "Boo! No IM :(");
	if (im == NULL)
      im = purple_im_conversation_new(purple_connection_get_account(gc), receiver);

	for(gnode = purple_blist_get_buddy_list()->root;
       gnode != NULL;
       gnode = gnode->next)
   {
	    if (PURPLE_IS_GROUP(gnode)) {
          ++total;
			 grouptotal = g_strdup_printf("Groups (%d):\n", total);
			 grouplist = g_strconcat(grouptotal, gname, ",\t", NULL);
       }
	}

	for(gnode = purple_blist_get_buddy_list()->root;
       gnode != NULL;
       gnode = gnode->next)
   {
	    if (PURPLE_IS_GROUP(gnode)) {
         g = (PurpleGroup*)gnode;
			gname = purple_group_get_name(g);
			purple_debug_info("send-option", " Group checked: %s \n",gname);
			++count;
			++counter;

	       if (flag == 1 && counter != total) {
             grouplist = g_strconcat(gname, ",\t", NULL);
             flag = 0;
          } else if (flag == 1 && counter == total) {
             grouplist = g_strconcat(gname, ".\t", NULL);
				 purple_debug_info(NULL, "%s", grouplist);	
             purple_conversation_send(PURPLE_CONVERSATION(im), grouplist); 
				 grouplist = NULL;
				 count = 0;
			 } else{
				 if (count <= 20 && counter != total) {
				  grouplist = g_strconcat(grouplist, gname, ",\t", NULL);	/*fishy cant insert newline*/	
				 } else {
					if (counter == total)
						 grouplist = g_strconcat(grouplist, gname, ".\t", NULL);
					else
                   grouplist = g_strconcat(grouplist, gname, ",\t", NULL);
						 
                   purple_debug_info(NULL, "%s", grouplist);	
                   purple_conversation_send(PURPLE_CONVERSATION(im), grouplist); 
						 grouplist = NULL;
						 count = 0;
						 flag = 1;
             }
	       }
          
		 }
	}
   purple_notify_message (plugin, PURPLE_NOTIFY_MSG_INFO,
		    "Send group list", "Successfully sent your group list :)", NULL, NULL,
		     NULL, NULL);
	
	g_free(grouplist);	
}