Projects >> plugin-Freemail >>87865b01a38ee252bc262f03258377ac3885c881

Chunk
Conflicting content
import freenet.support.api.HTTPRequest;

public class AddAccountToadlet extends WebPage {
<<<<<<< HEAD
	private static final String PATH = "/Freemail/AddAccount";

	private static final List accountCreationTasks = new LinkedList();

=======
	private final PluginRespirator pluginRespirator;
>>>>>>> 6b08747fb50c17df5a39287a415c15e68fa28e96
	private final WoTConnection wotConnection;
	private final AccountManager accountManager;
Solution content
import freenet.support.api.HTTPRequest;

public class AddAccountToadlet extends WebPage {
	private static final String PATH = "/Freemail/AddAccount";

	private final WoTConnection wotConnection;
	private final AccountManager accountManager;
File
AddAccountToadlet.java
Developer's decision
Combination
Kind of conflict
Attribute
Method invocation
Chunk
Conflicting content
			}
		}

<<<<<<< HEAD
		if((task == null) || (task.getState() == TaskState.FINISHED)) {
			//Everything is done
			writeTemporaryRedirect(ctx, "Redirecting to login page", LogInToadlet.getPath());
=======
		if(identitiesWithoutAccount.size() == 0) {
			HTMLNode infobox = addInfobox(contentNode, FreemailL10n.getString("Freemail.AddAccountToadlet.noIdentitiesTitle"));
			infobox.addChild("p", FreemailL10n.getString("Freemail.AddAccountToadlet.noIdentities"));
			writeHTMLReply(ctx, 200, "OK", pageNode.generate());
>>>>>>> 6b08747fb50c17df5a39287a415c15e68fa28e96
			return;
		}
Solution content
			}
		}

		if(identitiesWithoutAccount.size() == 0) {
			HTMLNode infobox = addInfobox(contentNode, FreemailL10n.getString("Freemail.AddAccountToadlet.noIdentitiesTitle"));
			infobox.addChild("p", FreemailL10n.getString("Freemail.AddAccountToadlet.noIdentities"));
			writeHTMLReply(ctx, 200, "OK", pageNode.generate());
			return;
		}
File
AddAccountToadlet.java
Developer's decision
Version 2
Kind of conflict
Comment
If statement
Method invocation
Variable
Chunk
Conflicting content
		} catch(NoSuchElementException e) {
		confirmPassword.addChild("input", new String[] {"type",     "name"},
		                                  new String[] {"password", "passwordVerification"});

<<<<<<< HEAD
	private void addPasswordForm(HTMLNode parent, String identity) {
		HTMLNode infobox = addInfobox(parent, "Choose a password");
		infobox.addChild("p", "While your account in being created, please select a password. This" +
				"will be used when logging in to your account from an email client");

		HTMLNode passwordForm = pluginRespirator.addFormChild(infobox, path(), "password");
		passwordForm.addChild("input", new String[] {"type",   "name",   "value"},
		                               new String[] {"hidden", "action", "setPassword"});

		//FIXME: Doing it this way allows the password of any identity to be changed
		passwordForm.addChild("input", new String[] {"type",   "name",     "value"},
		                               new String[] {"hidden", "identity", identity});

		passwordForm.addChild("input", new String[] {"type",     "name"},
		                               new String[] {"password", "password"});
		passwordForm.addChild("input", new String[] {"type",     "name"},
		                               new String[] {"password", "passwordVerify"});
		passwordForm.addChild("input", new String[] {"type", "name", "value"},
		                               new String[] {"submit", "submit", "Set password"});
	}

	private void makeWebPagePost(ToadletContext ctx, HTTPRequest req) throws ToadletContextClosedException, IOException {
		String action;
		try {
			action = req.getPartAsStringThrowing("action", 64);
		} catch(SizeLimitExceededException e) {
			//Someone is deliberately passing bad data, or there is a bug in the PUT code
			Logger.error(this, "Got action that was too long. First 100 bytes: " + req.getPartAsStringFailsafe("action", 100));

			//TODO: Write a better message
			writeHTMLReply(ctx, 200, "OK", "The request contained bad data. This is probably a bug in Freemail");
			return;
		} catch(NoSuchElementException e) {
			action = "addAccount";
		}
			Logger.error(this, "Got OwnIdentityID that was too long. First 100 bytes: " + req.getPartAsStringFailsafe("OwnIdentityID", 100));

			//TODO: Write a better message
			//Someone is deliberately passing bad data, or there is a bug in the PUT code

			writeHTMLReply(ctx, 200, "OK", "The request contained bad data. This is probably a bug in Freemail");
			return;
		if("addAccount".equals(action)) {
			addAccount(ctx, req);
		} else if("setPassword".equals(action)) {
			setPassword(ctx, req);
		} else {
			Logger.error(this, "Got unknown action: " + action);
			//TODO: Write a better message
			writeHTMLReply(ctx, 200, "OK", "The request contained bad data. This is probably a bug in Freemail");
		}
	}

	private void addAccount(ToadletContext ctx, HTTPRequest req) throws ToadletContextClosedException, IOException {
		//Get the identity id
		String identity;
		try {
			identity = req.getPartAsStringThrowing("OwnIdentityID", 64);
		} catch(SizeLimitExceededException e) {
			//Someone is deliberately passing bad data, or there is a bug in the PUT code
			Logger.error(this, "Got POST request without OwnIdentityID");

			//TODO: Write a better message
			writeHTMLReply(ctx, 200, "OK", "The request didn't contain the expected data. This is probably a bug in Freemail");
			return;
		}

		AccountCreationTask task = new AccountCreationTask(accountManager, identity, wotConnection);
		FreemailPlugin.getExecutor().submit(task);
		synchronized(accountCreationTasks) {
			accountCreationTasks.add(task);
		}

		writeTemporaryRedirect(ctx, "Account added, redirecting to login page", getIdentityStatusPath(identity));
	}

	private void setPassword(ToadletContext ctx, HTTPRequest req) throws ToadletContextClosedException, IOException {
=======
		addAccountForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "submit", FreemailL10n.getString("Freemail.AddAccountToadlet.submit") });

		writeHTMLReply(ctx, 200, "OK", pageNode.generate());
	}

	private void makeWebPagePost(ToadletContext ctx, HTTPRequest req) throws ToadletContextClosedException, IOException {
		//Check the form password
		String pass;
		try {
			pass = req.getPartAsStringThrowing("formPassword", 32);
		} catch(SizeLimitExceededException e) {
			writeHTMLReply(ctx, 403, "Forbidden", "Form password too long");
			return;
		} catch(NoSuchElementException e) {
			writeHTMLReply(ctx, 403, "Forbidden", "Missing form password");
			return;
		}

		if((pass.length() == 0) || !pass.equals(pluginRespirator.getNode().clientCore.formPassword)) {
			writeHTMLReply(ctx, 403, "Forbidden", "Invalid form password.");
			return;
		}

>>>>>>> 6b08747fb50c17df5a39287a415c15e68fa28e96
		//Get the identity id
		String identity = req.getPartAsStringFailsafe("OwnIdentityID", 64);
Solution content
		confirmPassword.addChild("input", new String[] {"type",     "name"},
		                                  new String[] {"password", "passwordVerification"});

		addAccountForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "submit", FreemailL10n.getString("Freemail.AddAccountToadlet.submit") });

		writeHTMLReply(ctx, 200, "OK", pageNode.generate());
	}

	private void makeWebPagePost(ToadletContext ctx, HTTPRequest req) throws ToadletContextClosedException, IOException {
		//Check the form password
		String pass;
		try {
			pass = req.getPartAsStringThrowing("formPassword", 32);
		} catch(SizeLimitExceededException e) {
			writeHTMLReply(ctx, 403, "Forbidden", "Form password too long");
			return;
		} catch(NoSuchElementException e) {
			writeHTMLReply(ctx, 403, "Forbidden", "Missing form password");
			return;
		}

		if((pass.length() == 0) || !pass.equals(pluginRespirator.getNode().clientCore.formPassword)) {
			writeHTMLReply(ctx, 403, "Forbidden", "Invalid form password.");
			return;
		}

		//Get the identity id
		String identity = req.getPartAsStringFailsafe("OwnIdentityID", 64);
File
AddAccountToadlet.java
Developer's decision
Version 2
Kind of conflict
Comment
If statement
Method declaration
Method invocation
Method signature
Try statement
Variable
Chunk
Conflicting content
			throw new AssertionError();
		}

<<<<<<< HEAD
		writeTemporaryRedirect(ctx, "Redirecting to status page", getIdentityStatusPath(identity));
=======
		writeTemporaryRedirect(ctx, "Account added, redirecting to login page", "/Freemail/Login");
>>>>>>> 6b08747fb50c17df5a39287a415c15e68fa28e96
	}

	@Override
Solution content
			throw new AssertionError();
		}

		writeTemporaryRedirect(ctx, "Account added, redirecting to login page", "/Freemail/Login");
	}

	@Override
File
AddAccountToadlet.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Chunk
Conflicting content
import freemail.AccountManager;
import freemail.FreemailAccount;
import freemail.utils.Logger;
<<<<<<< HEAD
import freemail.wot.OwnIdentity;
import freemail.wot.WoTConnection;
=======
import freenet.client.HighLevelSimpleClient;
>>>>>>> 6b08747fb50c17df5a39287a415c15e68fa28e96
import freenet.clients.http.PageNode;
import freenet.clients.http.ToadletContext;
import freenet.clients.http.ToadletContextClosedException;
Solution content
import freemail.AccountManager;
import freemail.FreemailAccount;
import freemail.utils.Logger;
import freenet.clients.http.PageNode;
import freenet.clients.http.ToadletContext;
import freenet.clients.http.ToadletContextClosedException;
File
LogInToadlet.java
Developer's decision
None
Kind of conflict
Import
Chunk
Conflicting content

	private static final String PATH = "/Freemail/Login";
	private final AccountManager accountManager;
<<<<<<< HEAD
	private final WoTConnection wotConnection;
	public LogInToadlet(PluginRespirator pluginRespirator, AccountManager accountManager, WoTConnection wotConnection) {
		super(pluginRespirator);
=======
	private final PluginRespirator pluginRespirator;

	public LogInToadlet(HighLevelSimpleClient client, PluginRespirator pluginRespirator, AccountManager accountManager, SessionManager sessionManager) {
		super(client, pluginRespirator.getPageMaker(), sessionManager);
		this.pluginRespirator = pluginRespirator;
>>>>>>> 6b08747fb50c17df5a39287a415c15e68fa28e96
		this.accountManager = accountManager;
	}
Solution content
	private static final String PATH = "/Freemail/Login";

	private final AccountManager accountManager;

	public LogInToadlet(PluginRespirator pluginRespirator, AccountManager accountManager) {
		super(pluginRespirator);

		this.accountManager = accountManager;
	}
File
LogInToadlet.java
Developer's decision
Manual
Kind of conflict
Attribute
Method invocation
Method signature
Chunk
Conflicting content
				//FIXME: Nickname might be ambiguous

	private void addNewAccountBox(HTMLNode parent) {
		HTMLNode boxContent = addInfobox(parent, "Add account");
<<<<<<< HEAD

		HTMLNode addAccountForm = pluginRespirator.addFormChild(boxContent, AddAccountToadlet.getPath(), "addAccount");
		HTMLNode ownIdSelector = addAccountForm.addChild("select", "name", "OwnIdentityID");

		for(OwnIdentity oid : wotConnection.getAllOwnIdentities()) {
			if(accountManager.getAccount(oid.getIdentityID()) == null) {
				ownIdSelector.addChild("option", "value", oid.getIdentityID(), oid.getNickname());
			}
		}
		addAccountForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "submit", "Add account" });
=======
		boxContent.addChild("a", "href", "/Freemail/AddAccount", "You can add another account here");
>>>>>>> 6b08747fb50c17df5a39287a415c15e68fa28e96
	}

	private void makeWebPagePost(HTTPRequest req, ToadletContext ctx) throws ToadletContextClosedException, IOException {
Solution content
	private void addNewAccountBox(HTMLNode parent) {
		HTMLNode boxContent = addInfobox(parent, "Add account");
		boxContent.addChild("a", "href", "/Freemail/AddAccount", "You can add another account here");
	}

	private void makeWebPagePost(HTTPRequest req, ToadletContext ctx) throws ToadletContextClosedException, IOException {
File
LogInToadlet.java
Developer's decision
Version 2
Kind of conflict
For statement
Method invocation
Variable
Chunk
Conflicting content
		pluginRespirator.getPageMaker().addNavigationCategory(HomeToadlet.getPath(), FREEMAIL_CATEGORY_NAME, CATEGORY_TITLE, freemail);

		//Register the toadlets that should be visible in the menu
<<<<<<< HEAD
		HomeToadlet homeToadlet = new HomeToadlet(pluginRespirator);
		LogInToadlet loginToadlet = new LogInToadlet(pluginRespirator, freemail.getAccountManager(), freemail.getWotConnection());
		LogOutToadlet logoutToadlet = new LogOutToadlet(pluginRespirator);
		InboxToadlet inboxToadlet = new InboxToadlet(freemail.getAccountManager(), pluginRespirator);
		NewMessageToadlet newMessageToadlet = new NewMessageToadlet(freemail.getWotConnection(), freemail, pluginRespirator);
=======
		HomeToadlet homeToadlet = new HomeToadlet(null, pluginRespirator.getPageMaker(), sessionManager);
		LogInToadlet loginToadlet = new LogInToadlet(null, pluginRespirator, freemail.getAccountManager(), sessionManager);
		LogOutToadlet logoutToadlet = new LogOutToadlet(null, sessionManager, pluginRespirator.getPageMaker());
		InboxToadlet inboxToadlet = new InboxToadlet(null, sessionManager, pluginRespirator.getPageMaker(), freemail.getAccountManager(), pluginRespirator);
		NewMessageToadlet newMessageToadlet = new NewMessageToadlet(null, sessionManager, pluginRespirator.getPageMaker(), freemail.getWotConnection(), freemail);
>>>>>>> 6b08747fb50c17df5a39287a415c15e68fa28e96
		registerToadlet(homeToadlet, FREEMAIL_CATEGORY_NAME, true, "Freemail.HomeToadlet.name", "Freemail.HomeToadlet.title", false);
		registerToadlet(loginToadlet, FREEMAIL_CATEGORY_NAME, true, "Freemail.LoginToadlet.name", "Freemail.LoginToadlet.title", false);
		registerToadlet(logoutToadlet, FREEMAIL_CATEGORY_NAME, true, "Freemail.LogoutToadlet.name", "Freemail.LogoutToadlet.title", false);
Solution content
		pluginRespirator.getPageMaker().addNavigationCategory(HomeToadlet.getPath(), FREEMAIL_CATEGORY_NAME, CATEGORY_TITLE, freemail);

		//Register the toadlets that should be visible in the menu
		HomeToadlet homeToadlet = new HomeToadlet(pluginRespirator);
		LogInToadlet loginToadlet = new LogInToadlet(pluginRespirator, freemail.getAccountManager());
		LogOutToadlet logoutToadlet = new LogOutToadlet(pluginRespirator);
		InboxToadlet inboxToadlet = new InboxToadlet(freemail.getAccountManager(), pluginRespirator);
		NewMessageToadlet newMessageToadlet = new NewMessageToadlet(freemail.getWotConnection(), freemail, pluginRespirator);
		registerToadlet(homeToadlet, FREEMAIL_CATEGORY_NAME, true, "Freemail.HomeToadlet.name", "Freemail.HomeToadlet.title", false);
		registerToadlet(loginToadlet, FREEMAIL_CATEGORY_NAME, true, "Freemail.LoginToadlet.name", "Freemail.LoginToadlet.title", false);
		registerToadlet(logoutToadlet, FREEMAIL_CATEGORY_NAME, true, "Freemail.LogoutToadlet.name", "Freemail.LogoutToadlet.title", false);
File
WebInterface.java
Developer's decision
Manual
Kind of conflict
Method invocation
Variable