/**
 * Appcelerator Titanium Mobile
 * Copyright (c) 2009-2010 by Appcelerator, Inc. All Rights Reserved.
 * Licensed under the terms of the Apache Public License
 * Please see the LICENSE included with this distribution for details.
 */
package ti.modules.titanium.facebook;

import java.util.HashMap;
import java.util.Map;

import org.appcelerator.titanium.util.Log;

import android.app.Activity;

/**
 * Dialog for handling stream posts
 * 
 */
public class FBStreamDialog extends FBDialog {
	private static final String LOG = FBPermissionDialog.class.getSimpleName();
	private static final String FB_STREAM_URL = "http://www.facebook.com/connect/prompt_feed.php";

	private final String attachment;
	private final String actionLinks;
	private final String targetId;
	private final String userMessagePrompt;

	/**
	 * @param context
	 * @param session
	 */
	public FBStreamDialog(Activity context, FBSession session,
			FacebookModule tb, String attachment, String actionLinks,
			String targetId, String userMessagePrompt) {
		super(context, session);
		this.attachment = attachment;
		this.actionLinks = actionLinks;
		this.targetId = targetId;
		this.userMessagePrompt = userMessagePrompt;
	}

	@Override
	protected void load() {
		Map<String, String> params = new HashMap<String, String>(1);
		params.put("display", "touch");

		try {
			Map<String, String> postParams = new HashMap<String, String>(8);
			postParams.put("api_key", mSession.getApiKey());
			postParams.put("session_key", mSession.getSessionKey());
			postParams.put("preview", "1");
			postParams.put("callback", "fbconnect:success");
			postParams.put("cancel", "fbconnect:cancel");
			postParams.put("attachment", attachment);
			postParams.put("action_links", actionLinks);
			postParams.put("target_id", targetId);
			postParams.put("user_message_prompt", userMessagePrompt);

			this.loadURL(FB_STREAM_URL, "post", params, postParams);
		} catch (Exception e) {
			Log.e(LOG, "Error loading URL: " + FB_STREAM_URL, e);
		}
	}

}

@@ -1325,16 +1325,111 @@
 touch%22);
+%0A%09%09params.put(%22callback%22, %22fbconnect://success%22);%0A%09%09params.put(%22cancel%22, %22fbconnect://cancel%22);
 %0A%0A%09%09try 
@@ -1649,109 +1649,8 @@
 %22);%0A
-%09%09%09postParams.put(%22callback%22, %22fbconnect:success%22);%0A%09%09%09postParams.put(%22cancel%22, %22fbconnect:cancel%22);%0A
 %09%09%09p

Put the facebook success/cancel urls in GET params instead of POST-- now the activity accurately sets the result.