Some better (non-misleading) error msgs

Also some reindentation
This commit is contained in:
Markus Doits 2011-01-20 18:38:15 +00:00
parent 1af5a985b5
commit 392969629c

View File

@ -150,13 +150,13 @@ public class ApgService extends Service {
* fingerprint or user id to search for * fingerprint or user id to search for
* @return master key if found, or 0 * @return master key if found, or 0
*/ */
private static long get_master_key(String search_key) { private static long get_master_key(String search_key, Bundle pReturn) {
if (search_key == null || search_key.length() != 8) { if (search_key == null || search_key.length() != 8) {
return 0; return 0;
} }
ArrayList<String> tmp = new ArrayList<String>(); ArrayList<String> tmp = new ArrayList<String>();
tmp.add(search_key); tmp.add(search_key);
long[] _keys = get_master_key(tmp); long[] _keys = get_master_key(tmp, pReturn);
if (_keys.length > 0) if (_keys.length > 0)
return _keys[0]; return _keys[0];
else else
@ -171,7 +171,7 @@ public class ApgService extends Service {
* database * database
* @return an array of master keys * @return an array of master keys
*/ */
private static long[] get_master_key(ArrayList<String> search_keys) { private static long[] get_master_key(ArrayList<String> search_keys, Bundle pReturn) {
SQLiteQueryBuilder qb = new SQLiteQueryBuilder(); SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
qb.setTables(KeyRings.TABLE_NAME + " INNER JOIN " + Keys.TABLE_NAME + " ON " + "(" + KeyRings.TABLE_NAME + "." + KeyRings._ID + " = " + Keys.TABLE_NAME qb.setTables(KeyRings.TABLE_NAME + " INNER JOIN " + Keys.TABLE_NAME + " ON " + "(" + KeyRings.TABLE_NAME + "." + KeyRings._ID + " = " + Keys.TABLE_NAME
@ -220,11 +220,13 @@ public class ApgService extends Service {
} }
if (i == 0) { if (i == 0) {
Log.e(TAG, "Found no public key to encrypt with, APG will error out"); Log.w(TAG, "Found not one public key");
pReturn.getStringArrayList(ret.WARNINGS.name()).add("Searched for public key(s) but found not one");
} }
for (String _key : search_keys) { for (String _key : search_keys) {
Log.w(TAG, "Cannot encrypt with key "+_key+": cannot find it in APG"); Log.w(TAG, "Searched for key " + _key + " but cannot find it in APG");
pReturn.getStringArrayList(ret.WARNINGS.name()).add("Searched for key " + _key + " but cannot find it in APG");
} }
return _master_longs; return _master_longs;
@ -372,7 +374,7 @@ public class ApgService extends Service {
while (_iter.hasNext()) { while (_iter.hasNext()) {
_pub_keys.add(_iter.next()); _pub_keys.add(_iter.next());
} }
_pub_master_keys = get_master_key(_pub_keys); _pub_master_keys = get_master_key(_pub_keys, pReturn);
} }
InputStream _inStream = new ByteArrayInputStream(pArgs.getString(arg.MESSAGE.name()).getBytes()); InputStream _inStream = new ByteArrayInputStream(pArgs.getString(arg.MESSAGE.name()).getBytes());
@ -385,7 +387,7 @@ public class ApgService extends Service {
_out, // output stream _out, // output stream
pArgs.getBoolean(arg.ARMORED_OUTPUT.name()), // ARMORED_OUTPUT pArgs.getBoolean(arg.ARMORED_OUTPUT.name()), // ARMORED_OUTPUT
_pub_master_keys, // encryption keys _pub_master_keys, // encryption keys
get_master_key(pArgs.getString(arg.SIGNATURE_KEY.name())), // signature key get_master_key(pArgs.getString(arg.SIGNATURE_KEY.name()), pReturn), // signature key
pArgs.getString(arg.PRIVATE_KEY_PASSPHRASE.name()), // signature passphrase pArgs.getString(arg.PRIVATE_KEY_PASSPHRASE.name()), // signature passphrase
null, // progress null, // progress
pArgs.getInt(arg.ENCRYPTION_ALGORYTHM.name()), // encryption pArgs.getInt(arg.ENCRYPTION_ALGORYTHM.name()), // encryption