astyle pass

This commit is contained in:
Jesse Vincent 2010-01-18 00:11:02 +00:00
parent 9301aabc8c
commit 4493044340
9 changed files with 156 additions and 154 deletions

View File

@ -857,7 +857,7 @@ public class MessagingController implements Runnable
{
listener.synchronizeMailboxStarted(account, folder);
}
Exception commandException = null;
try
{
@ -1827,23 +1827,23 @@ public class MessagingController implements Runnable
String folder = command.arguments[0];
String uid = command.arguments[1];
if (account.getErrorFolderName().equals(folder))
{
return;
}
LocalStore localStore = (LocalStore) Store.getInstance(
account.getLocalStoreUri(),
mApplication);
localFolder = (LocalFolder) localStore.getFolder(folder);
LocalMessage localMessage = (LocalMessage) localFolder.getMessage(uid);
if (localMessage == null)
{
return;
}
Store remoteStore = Store.getInstance(account.getStoreUri(), mApplication);
remoteFolder = remoteStore.getFolder(folder);
if (!remoteFolder.exists())
@ -1858,13 +1858,13 @@ public class MessagingController implements Runnable
{
return;
}
Message remoteMessage = null;
if (!localMessage.getUid().startsWith(K9.LOCAL_UID_PREFIX))
{
remoteMessage = remoteFolder.getMessage(localMessage.getUid());
}
if (remoteMessage == null)
{
if (localMessage.isSet(Flag.X_REMOTE_COPY_STARTED))
@ -1877,7 +1877,7 @@ public class MessagingController implements Runnable
{
Log.w(K9.LOG_TAG, "Local message has flag " + Flag.X_REMOTE_COPY_STARTED + " already set, and there is a remote message with " +
" uid " + rUid + ", assuming message was already copied and aborting this copy");
String oldUid = localMessage.getUid();
localMessage.setUid(rUid);
localFolder.changeUid(localMessage);
@ -1892,7 +1892,7 @@ public class MessagingController implements Runnable
Log.w(K9.LOG_TAG, "No remote message with message-id found, proceeding with append");
}
}
/*
* If the message does not exist remotely we just upload it and then
* update our local copy with the new uid.
@ -1907,7 +1907,7 @@ public class MessagingController implements Runnable
String oldUid = localMessage.getUid();
localMessage.setFlag(Flag.X_REMOTE_COPY_STARTED, true);
remoteFolder.appendMessages(new Message[] { localMessage });
localFolder.changeUid(localMessage);
for (MessagingListener l : getListeners())
{
@ -1946,9 +1946,9 @@ public class MessagingController implements Runnable
fp.add(FetchProfile.Item.BODY);
localFolder.fetch(new Message[] { localMessage }, fp, null);
String oldUid = localMessage.getUid();
localMessage.setFlag(Flag.X_REMOTE_COPY_STARTED, true);
remoteFolder.appendMessages(new Message[] { localMessage });
localFolder.changeUid(localMessage);
for (MessagingListener l : getListeners())
@ -2184,7 +2184,7 @@ public class MessagingController implements Runnable
{
String folder = command.arguments[0];
String uid = command.arguments[1];
if (account.getErrorFolderName().equals(folder))
{
return;
@ -2388,8 +2388,8 @@ public class MessagingController implements Runnable
{
l.folderStatusChanged(account, folder, 0);
}
if (account.getErrorFolderName().equals(folder))
{
return;
@ -4027,7 +4027,7 @@ public class MessagingController implements Runnable
Log.e(K9.LOG_TAG, "Unable to synchronize account " + account.getName(), e);
addErrorMessage(account, e);
}
}
}
catch (Exception e)

View File

@ -207,15 +207,16 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
String authType = null;
if (uri.getUserInfo() != null)
{
String[] userInfoParts = uri.getUserInfo().split(":");
String[] userInfoParts = uri.getUserInfo().split(":");
username = userInfoParts[0];
if (userInfoParts.length > 1)
{
password = userInfoParts[1];
}
if (userInfoParts.length > 2) {
authType = userInfoParts[2];
}
if (userInfoParts.length > 1)
{
password = userInfoParts[1];
}
if (userInfoParts.length > 2)
{
authType = userInfoParts[2];
}
}
if (username != null)

View File

@ -760,8 +760,8 @@ public class ImapStore extends Store
}
else
{
throw new MessagingException("IMAPMessage.copyMessages: remote destination folder " + folder.getName()
+ " does not exist and could not be created for " + getLogId()
throw new MessagingException("IMAPMessage.copyMessages: remote destination folder " + folder.getName()
+ " does not exist and could not be created for " + getLogId()
, true);
}
}
@ -793,7 +793,7 @@ public class ImapStore extends Store
{
ImapFolder remoteTrashFolder = (ImapFolder)getStore().getFolder(trashFolderName);
String remoteTrashName = encodeFolderName(remoteTrashFolder.getPrefixedName());
if (!exists(remoteTrashName))
{
/*
@ -2472,7 +2472,7 @@ public class ImapStore extends Store
receiver.pushError("IMAP server is not IDLE capable: " + mConnection.toString(), null);
throw new MessagingException("IMAP server is not IDLE capable:" + mConnection.toString());
}
if (responses != null)
{
handleUntaggedResponses(responses);

View File

@ -124,7 +124,8 @@ public class SmtpTransport extends Transport
{
mPassword = userInfoParts[1];
}
if (userInfoParts.length > 2) {
if (userInfoParts.length > 2)
{
mAuthType = userInfoParts[2];
}
}

View File

@ -14,7 +14,7 @@ class AccountReceiver extends BroadcastReceiver
{
receptor = nReceptor;
}
@Override
public void onReceive(Context context, Intent intent)
{
@ -29,5 +29,5 @@ class AccountReceiver extends BroadcastReceiver
receptor.accounts(bundle.getStringArray(K9RemoteControl.K9_ACCOUNT_UUIDS), bundle.getStringArray(K9RemoteControl.K9_ACCOUNT_DESCRIPTIONS));
}
}
}

View File

@ -1,6 +1,6 @@
package com.fsck.k9.remotecontrol;
/**
*
*
* @author Daniel I. Applebaum
* The interface to implement in order to accept the arrays containing the UUIDs and descriptions of
* the accounts configured in K-9 Mail. Should be passed to fetchAccounts(Context, K9AccountReceptor)

View File

@ -11,14 +11,14 @@ import android.util.Log;
/**
* Utillity definitions for Android applications to control the behavior of K-9 Mail. All such applications must declare the following permission:
* <uses-permission android:name="com.fsck.k9.permission.REMOTE_CONTROL"/>
* in their AndroidManifest.xml In addition, all applications sending remote control messages to K-9 Mail must
*
* in their AndroidManifest.xml In addition, all applications sending remote control messages to K-9 Mail must
*
* An application that wishes to act on a particular Account in K-9 needs to fetch the list of configured Accounts by broadcasting an
* {@link Intent} using K9_REQUEST_ACCOUNTS as the Action. The broadcast must be made using the {@link ContextWrapper}
* sendOrderedBroadcast(Intent intent, String receiverPermission, BroadcastReceiver resultReceiver,
* sendOrderedBroadcast(Intent intent, String receiverPermission, BroadcastReceiver resultReceiver,
* Handler scheduler, int initialCode, String initialData, Bundle initialExtras).sendOrderedBroadcast}
* method in order to receive the list of Account UUIDs and descriptions that K-9 will provide.
*
*
* @author Daniel I. Applebaum
*
*/
@ -31,7 +31,7 @@ public class K9RemoteControl
public final static String K9_REMOTE_CONTROL_PERMISSION = "com.fsck.k9.permission.REMOTE_CONTROL";
/**
* {@link Intent} Action to be sent to K-9 using {@link ContextWrapper.sendOrderedBroadcast} in order to fetch the list of configured Accounts.
* The responseData will contain two String[] with keys K9_ACCOUNT_UUIDS and K9_ACCOUNT_DESCRIPTIONS
* The responseData will contain two String[] with keys K9_ACCOUNT_UUIDS and K9_ACCOUNT_DESCRIPTIONS
*/
public final static String K9_REQUEST_ACCOUNTS = "com.fsck.k9.K9RemoteControl.requestAccounts";
public final static String K9_ACCOUNT_UUIDS = "com.fsck.k9.K9RemoteControl.accountUuids";
@ -41,7 +41,7 @@ public class K9RemoteControl
* The {@link {@link Intent}} Action to set in order to cause K-9 to check mail. (Not yet implemented)
*/
//public final static String K9_CHECK_MAIL = "com.fsck.k9.K9RemoteControl.checkMail";
/**
* The {@link {@link Intent}} Action to set when remotely changing K-9 Mail settings
*/
@ -56,10 +56,10 @@ public class K9RemoteControl
* specified with K9_ACCOUNT_UUID
*/
public final static String K9_ALL_ACCOUNTS = "com.fsck.k9.K9RemoteControl.allAccounts";
public final static String K9_ENABLED = "true";
public final static String K9_DISABLED = "false";
/*
* Key for the {@link Intent} Extra for controlling whether notifications will be generated for new unread mail.
* Acceptable values are K9_ENABLED and K9_DISABLED
@ -75,7 +75,7 @@ public class K9RemoteControl
* Acceptable values are K9_ENABLED and K9_DISABLED
*/
public final static String K9_VIBRATE_ENABLED = "com.fsck.k9.K9RemoteControl.notificationEnabled";
public final static String K9_FOLDERS_NONE = "NONE";
public final static String K9_FOLDERS_ALL = "ALL";
public final static String K9_FOLDERS_FIRST_CLASS = "FIRST_CLASS";
@ -93,14 +93,14 @@ public class K9RemoteControl
* K9_FOLDERS_NOT_SECOND_CLASS, K9_FOLDERS_NONE
*/
public final static String K9_POLL_CLASSES = "com.fsck.k9.K9RemoteControl.pollClasses";
public final static String[] K9_POLL_FREQUENCIES = { "-1", "1", "5", "10", "15", "30", "60", "120", "180", "360", "720", "1440"};
public final static String[] K9_POLL_FREQUENCIES = { "-1", "1", "5", "10", "15", "30", "60", "120", "180", "360", "720", "1440"};
/**
* Key for the {@link Intent} Extra to set with the desired poll frequency. The value is a String representing a number of minutes.
* Acceptable values are available in K9_POLL_FREQUENCIES
*/
public final static String K9_POLL_FREQUENCY = "com.fsck.k9.K9RemoteControl.pollFrequency";
/**
* Key for the {@link Intent} Extra to set for controlling K-9's global "Background sync" setting.
* Acceptable values are K9_BACKGROUND_OPERATIONS_ALWAYS, K9_BACKGROUND_OPERATIONS_NEVER
@ -110,7 +110,7 @@ public class K9RemoteControl
public final static String K9_BACKGROUND_OPERATIONS_WHEN_CHECKED = "WHEN_CHECKED";
public final static String K9_BACKGROUND_OPERATIONS_ALWAYS = "ALWAYS";
public final static String K9_BACKGROUND_OPERATIONS_NEVER = "NEVER";
/**
* Key for the {@link Intent} Extra to set for controlling which display theme K-9 will use. Acceptable values are
* K9_THEME_LIGHT, K9_THEME_DARK
@ -118,15 +118,15 @@ public class K9RemoteControl
public final static String K9_THEME = "com.fsck.k9.K9RemoteControl.theme";
public final static String K9_THEME_LIGHT = "LIGHT";
public final static String K9_THEME_DARK = "DARK";
protected static String LOG_TAG = "K9RemoteControl";
public static void set(Context context, Intent broadcastIntent)
{
broadcastIntent.setAction(K9RemoteControl.K9_SET);
context.sendBroadcast(broadcastIntent, K9RemoteControl.K9_REMOTE_CONTROL_PERMISSION);
}
public static void fetchAccounts(Context context, K9AccountReceptor receptor)
{
Intent accountFetchIntent = new Intent();
@ -134,7 +134,7 @@ public class K9RemoteControl
AccountReceiver receiver = new AccountReceiver(receptor);
context.sendOrderedBroadcast(accountFetchIntent, K9RemoteControl.K9_REMOTE_CONTROL_PERMISSION, receiver, null, Activity.RESULT_OK, null, null);
}
}

View File

@ -36,7 +36,7 @@ public class RemoteControlReceiver extends CoreReceiver
for (int i = 0; i < accounts.length; i++)
{
Account account = accounts[i];
uuids[i] = account.getUuid();
descriptions[i] = account.getDescription();
}
@ -48,9 +48,9 @@ public class RemoteControlReceiver extends CoreReceiver
{
Log.e(K9.LOG_TAG, "Could not handle K9_RESPONSE_INTENT", e);
}
}
return tmpWakeLockId;
}

View File

@ -24,7 +24,7 @@ public class RemoteControlService extends CoreService
public static void set(Context context, Intent i, Integer wakeLockId)
{
// Intent i = new Intent();
// Intent i = new Intent();
i.setClass(context, RemoteControlService.class);
i.setAction(RemoteControlService.SET_ACTION);
addWakeLockId(i, wakeLockId);
@ -36,132 +36,132 @@ public class RemoteControlService extends CoreService
}
public static final int REMOTE_CONTROL_SERVICE_WAKE_LOCK_TIMEOUT = 20000;
@Override
public void startService(final Intent intent, final int startId)
{
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "RemoteControlService started with startId = " + startId);
final Preferences preferences = Preferences.getPreferences(this);
if (RESCHEDULE_ACTION.equals(intent.getAction()))
final Preferences preferences = Preferences.getPreferences(this);
if (RESCHEDULE_ACTION.equals(intent.getAction()))
{
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "RemoteControlService requesting MailService reschedule");
MailService.actionReschedule(this, null);
}
else if (RemoteControlService.SET_ACTION.equals(intent.getAction()))
{
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "RemoteControlService got request to change settings");
execute(getApplication(), new Runnable()
{
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "RemoteControlService requesting MailService reschedule");
MailService.actionReschedule(this, null);
}
else if (RemoteControlService.SET_ACTION.equals(intent.getAction()))
{
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "RemoteControlService got request to change settings");
execute(getApplication(), new Runnable()
public void run()
{
public void run()
try
{
try
String uuid = intent.getStringExtra(K9_ACCOUNT_UUID);
boolean allAccounts = intent.getBooleanExtra(K9_ALL_ACCOUNTS, false);
if (K9.DEBUG)
{
String uuid = intent.getStringExtra(K9_ACCOUNT_UUID);
boolean allAccounts = intent.getBooleanExtra(K9_ALL_ACCOUNTS, false);
if (K9.DEBUG)
if (allAccounts)
{
if (allAccounts)
{
Log.i(K9.LOG_TAG, "RemoteControlService changing settings for all accounts");
}
else
{
Log.i(K9.LOG_TAG, "RemoteControlService changing settings for account with UUID " + uuid);
}
Log.i(K9.LOG_TAG, "RemoteControlService changing settings for all accounts");
}
Account[] accounts = preferences.getAccounts();
for (Account account : accounts)
else
{
if (allAccounts || account.getUuid().equals(uuid))
Log.i(K9.LOG_TAG, "RemoteControlService changing settings for account with UUID " + uuid);
}
}
Account[] accounts = preferences.getAccounts();
for (Account account : accounts)
{
if (allAccounts || account.getUuid().equals(uuid))
{
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "RemoteControlService changing settings for account " + account.getDescription());
String notificationEnabled = intent.getStringExtra(K9_NOTIFICATION_ENABLED);
String ringEnabled = intent.getStringExtra(K9_RING_ENABLED);
String vibrateEnabled = intent.getStringExtra(K9_VIBRATE_ENABLED);
String pushClasses = intent.getStringExtra(K9_PUSH_CLASSES);
String pollClasses = intent.getStringExtra(K9_POLL_CLASSES);
String pollFrequency = intent.getStringExtra(K9_POLL_FREQUENCY);
if (notificationEnabled != null)
{
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "RemoteControlService changing settings for account " + account.getDescription());
String notificationEnabled = intent.getStringExtra(K9_NOTIFICATION_ENABLED);
String ringEnabled = intent.getStringExtra(K9_RING_ENABLED);
String vibrateEnabled = intent.getStringExtra(K9_VIBRATE_ENABLED);
String pushClasses = intent.getStringExtra(K9_PUSH_CLASSES);
String pollClasses = intent.getStringExtra(K9_POLL_CLASSES);
String pollFrequency = intent.getStringExtra(K9_POLL_FREQUENCY);
if (notificationEnabled != null)
account.setNotifyNewMail(Boolean.parseBoolean(notificationEnabled));
}
if (ringEnabled != null)
{
account.setRing(Boolean.parseBoolean(ringEnabled));
}
if (vibrateEnabled != null)
{
account.setVibrate(Boolean.parseBoolean(vibrateEnabled));
}
if (pushClasses != null)
{
account.setFolderPushMode(FolderMode.valueOf(pushClasses));
}
if (pollClasses != null)
{
account.setFolderSyncMode(FolderMode.valueOf(pollClasses));
}
if (pollFrequency != null)
{
String[] allowedFrequencies = getResources().getStringArray(R.array.account_settings_check_frequency_values);
for (String allowedFrequency : allowedFrequencies)
{
account.setNotifyNewMail(Boolean.parseBoolean(notificationEnabled));
}
if (ringEnabled != null)
{
account.setRing(Boolean.parseBoolean(ringEnabled));
}
if (vibrateEnabled != null)
{
account.setVibrate(Boolean.parseBoolean(vibrateEnabled));
}
if (pushClasses != null)
{
account.setFolderPushMode(FolderMode.valueOf(pushClasses));
}
if (pollClasses != null)
{
account.setFolderSyncMode(FolderMode.valueOf(pollClasses));
}
if (pollFrequency != null)
{
String[] allowedFrequencies = getResources().getStringArray(R.array.account_settings_check_frequency_values);
for (String allowedFrequency : allowedFrequencies)
if (allowedFrequency.equals(pollFrequency))
{
if (allowedFrequency.equals(pollFrequency))
{
account.setAutomaticCheckIntervalMinutes(Integer.parseInt(allowedFrequency));
}
account.setAutomaticCheckIntervalMinutes(Integer.parseInt(allowedFrequency));
}
}
account.save(Preferences.getPreferences(RemoteControlService.this));
}
account.save(Preferences.getPreferences(RemoteControlService.this));
}
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "RemoteControlService changing global settings");
String backgroundOps = intent.getStringExtra(K9_BACKGROUND_OPERATIONS);
if (K9RemoteControl.K9_BACKGROUND_OPERATIONS_ALWAYS.equals(backgroundOps)
|| K9RemoteControl.K9_BACKGROUND_OPERATIONS_NEVER.equals(backgroundOps)
|| K9RemoteControl.K9_BACKGROUND_OPERATIONS_WHEN_CHECKED.equals(backgroundOps))
{
K9.setBackgroundOps(backgroundOps);
}
}
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "RemoteControlService changing global settings");
String theme = intent.getStringExtra(K9_THEME);
if (theme != null)
{
K9.setK9Theme(K9RemoteControl.K9_THEME_DARK.equals(theme) ? android.R.style.Theme : android.R.style.Theme_Light);
}
SharedPreferences sPrefs = preferences.getPreferences();
Editor editor = sPrefs.edit();
K9.save(editor);
editor.commit();
Intent i = new Intent();
i.setClassName(getApplication().getPackageName(), "com.fsck.k9.service.RemoteControlService");
i.setAction(RESCHEDULE_ACTION);
long nextTime = System.currentTimeMillis() + 10000;
BootReceiver.scheduleIntent(RemoteControlService.this, nextTime, i);
}
catch (Exception e)
String backgroundOps = intent.getStringExtra(K9_BACKGROUND_OPERATIONS);
if (K9RemoteControl.K9_BACKGROUND_OPERATIONS_ALWAYS.equals(backgroundOps)
|| K9RemoteControl.K9_BACKGROUND_OPERATIONS_NEVER.equals(backgroundOps)
|| K9RemoteControl.K9_BACKGROUND_OPERATIONS_WHEN_CHECKED.equals(backgroundOps))
{
Log.e(K9.LOG_TAG, "Could not handle K9_SET", e);
Toast toast = Toast.makeText(RemoteControlService.this, e.getMessage(), Toast.LENGTH_LONG);
toast.show();
K9.setBackgroundOps(backgroundOps);
}
String theme = intent.getStringExtra(K9_THEME);
if (theme != null)
{
K9.setK9Theme(K9RemoteControl.K9_THEME_DARK.equals(theme) ? android.R.style.Theme : android.R.style.Theme_Light);
}
SharedPreferences sPrefs = preferences.getPreferences();
Editor editor = sPrefs.edit();
K9.save(editor);
editor.commit();
Intent i = new Intent();
i.setClassName(getApplication().getPackageName(), "com.fsck.k9.service.RemoteControlService");
i.setAction(RESCHEDULE_ACTION);
long nextTime = System.currentTimeMillis() + 10000;
BootReceiver.scheduleIntent(RemoteControlService.this, nextTime, i);
}
catch (Exception e)
{
Log.e(K9.LOG_TAG, "Could not handle K9_SET", e);
Toast toast = Toast.makeText(RemoteControlService.this, e.getMessage(), Toast.LENGTH_LONG);
toast.show();
}
}
, RemoteControlService.REMOTE_CONTROL_SERVICE_WAKE_LOCK_TIMEOUT, startId);
}
, RemoteControlService.REMOTE_CONTROL_SERVICE_WAKE_LOCK_TIMEOUT, startId);
}
}
}