# HG changeset patch # User Nikita Kozlov # Date 1320533370 -3600 # Node ID 6b30719f4de64f67d79b1d361007cb13ce77a9e6 # Parent bdaaf0226e93918bbd9d92874baa44f164d8fa68# Parent 319ce14e48265353356141196db550903e75a6e0 merge otr repo with trunk diff -r 319ce14e4826 -r 6b30719f4de6 .hgignore diff -r 319ce14e4826 -r 6b30719f4de6 .hgtags --- a/.hgtags Sat Nov 05 22:27:58 2011 +0100 +++ b/.hgtags Sat Nov 05 23:49:30 2011 +0100 @@ -9,3 +9,4 @@ 7b54215139deae5ba9307b7a165f24d65f926938 0.1.5_rc1 8d19f91dd64c7f29f137b3236fb38c2cbcf98a36 0.1.5 3b5e81bf741ae4fd47e239f889fb66ae6732dbd6 0.1.6_rc1 +18b31fdfb292b1405c5783f1d11be8cef9302087 0.1.6 diff -r 319ce14e4826 -r 6b30719f4de6 AndroidManifest.xml --- a/AndroidManifest.xml Sat Nov 05 22:27:58 2011 +0100 +++ b/AndroidManifest.xml Sat Nov 05 23:49:30 2011 +0100 @@ -1,7 +1,7 @@ + package="com.beem.project.beem" android:versionCode="9" + android:versionName="0.1.6"> @@ -32,6 +32,8 @@ + + + Accepter un certificat de sécurité invalide ? + Toujours + Une fois + Annuler + + Certificate Verification Erreur lors de l\'authenfitication, mauvais login ou password diff -r 319ce14e4826 -r 6b30719f4de6 res/values-ru/strings.xml --- a/res/values-ru/strings.xml Sat Nov 05 22:27:58 2011 +0100 +++ b/res/values-ru/strings.xml Sat Nov 05 23:49:30 2011 +0100 @@ -1,4 +1,4 @@ - + Beem @@ -7,7 +7,7 @@ Отмена Разрешить Отказать -JID +Jabber ID Пароль Продолжить @@ -15,10 +15,10 @@ Ручная конфигурация -JID +Jabber ID -Соединяемся... +Соединение... Использовать сервис Beem @@ -38,9 +38,9 @@ Группа Добавить Контакт добавлен -При добавлении контакта возникла ошибка -При выполнении входа возникла ошибка - +Ошибка добавления контакта +Ошибка входа + Контакт уже добавлен @@ -53,10 +53,16 @@ О проекте Beem Создать аккаунт Изменить аккаунт -Обновляем статус... -Ничего не поменялось +Обновление статуса... +Ничего не изменилось +Мой аватар +Выберите свой аватар +Снять фото +Выбрать фото +Нет аватара +Нельзя выбрать фото - + Имя пользователя Пароль Прокси @@ -79,27 +85,25 @@ Установить метку данного клиента Установить приоритет данного клиента Список контактов -A set of display options for your buddy list - +Опции отображения контактов Скрывать группы Отметьте для того, чтобы спрятать группы Скрывать оффлайн-контакты -Check this option to hide unconnected buddies - +Отметьте, чтобы спрятать контакты, которые не в сети Имя пользователя - + Пароль Сервер Порт - + Расширенные настройки Сервер - + Порт Требовать SSL/TLS - + По умолчанию 5222 - + Соединяться через прокси Выберите тип проси Сервер @@ -107,8 +111,8 @@ По умолчанию 1080 Имя пользователя Пароль -Включить Auto-away -Устанавливать статус "Отошел" при отключении экрана +Включать автоматически \"Отошел\" +Устанавливать статус \"Отошел\" при отключении экрана Сообщение об отсутствии Напишите сообщение об отсутствии Я отошел, экран телефона выключен @@ -117,9 +121,21 @@ Вибрировать при новых сообщениях Сигнал сообщений Установить сигнал для пришедшего сообщения - +Компактный диалог +Сделать окно диалога компактным +История +Пометьте для сохранения разговоров на SD карте +Для сохранения истории необходима установленная SD карта с разрешённой записью +Разрешить сохранение истории +Диалог +История, размер диалога... +Путь к истории +Путь к сохраняемым диалогам на SD карте +Разрешить отладку XMPP +Использовать мой полный JID как имя пользователя +Необходимо для некоторых серверов, например для Google Talk - + Контакт авторизован Ошибка авторизации Авторизация отклонена @@ -130,20 +146,20 @@ Пришло новое сообщение -BEEM: Соединение разорвано +Beem: Соединение разорвано %s добавил(а) вас в свой контакт-лист. Авторизовать %s. - + Настройки - + Создать аккаунт - + Контакты - + Информация о пользователе @@ -159,67 +175,62 @@ Настройки О программе Beem %s - О программе - -Beem is an EPITECH Innovative Project. Visit us at -http://www.beem-project.com ! - + Закрыть Настройки Войти -Соединяемся, подождите немного... -Unfortunately, an error occured.\n\nError -detail:\n%s +Соединение. Пожалуйста, подождите... +К сожалению, произошла ошибка.\n\nПодробности:\n%s Войти Интернет соединение не найдено - +Настройки в меню -Соединение ... -Аутентификация ... -Вошли в сеть -Не удалось войти в сеть +Соединение... +Аутентификация... +Вход выполнен +Не удалось войти Создать аккаунт Настроить списки приватности Настройки успешно сохранены - - Общие настройки -Настройки пользователя (обязательно) -Расширенные настройки пользователя (необязательно) +Настройки пользователя (обязательные) +Расширенные настройки пользователя (дополнительные) Настройки сети Настройки прокси Настройки прокси +История +Вид диалога - - + + Аккаунт - + XMPP - + Прокси - -Добро пожаловать в BEEM.\n\nВы ещё не настроили аккаунт XMPP (Jabber).\nВыберите один из следующих вариантов : - +Добро пожаловать в Beem.\n\nВы ещё не настроили аккаунт XMPP (Jabber).\nВыберите один из следующих вариантов : + Использовать существующий аккаунт Создать новый аккаунт - - -Изменить настройки +Создание учётной записи - Инструкция +Создание учётной записи - Ошибка +Изменить мои настройки Закрыть Аккаунт %s успешно создан Неправильный JID Пароли не совпадают Имя пользователя Пароль -Ещё раз +Повторите пароль Добавить контакт @@ -227,7 +238,7 @@ Настройки Отключиться Все контакты - +Без группы Псевдоним @@ -235,15 +246,14 @@ Выслать приглашение ещё раз Заблокировать Удалить - -Are you sure you want to delete this contact ? - + +Вы уверены, что хотите удалить этот контакт? Да Нет - +Вы уверены, что хотите повторно послать приглашение? Чат -Печатать сообщение +Введите сообщение тут Я Ошибка Отправить @@ -258,9 +268,9 @@ занимается чем-то другим Онлайн -Поболтает +Доступен для разговора Занят -Отошёл +Отошел Недоступен Оффлайн @@ -284,27 +294,27 @@ Ошибка: неверно указан логин или пароль Ошибка сервера - - - - - - - - - - - - - - +Ошибочный запрос + + + +Возможность нереализована + +Неверный JID + + + + + + + Сервер не найден Сервер не отвечает Ошибка сервера - - - - - - - + + + + + + + \ No newline at end of file diff -r 319ce14e4826 -r 6b30719f4de6 res/values-zh-rCN/strings.xml diff -r 319ce14e4826 -r 6b30719f4de6 res/values-zh-rTW/strings.xml diff -r 319ce14e4826 -r 6b30719f4de6 res/values/arrays.xml diff -r 319ce14e4826 -r 6b30719f4de6 res/values/colors.xml diff -r 319ce14e4826 -r 6b30719f4de6 res/values/strings.xml --- a/res/values/strings.xml Sat Nov 05 22:27:58 2011 +0100 +++ b/res/values/strings.xml Sat Nov 05 23:49:30 2011 +0100 @@ -313,7 +313,15 @@ No Update - + + + Accept Unknown Certificate? + Always + Once + Abort + + Certificate Verification + Error during authentication, bad login or password. diff -r 319ce14e4826 -r 6b30719f4de6 res/values/styles.xml diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/BeemApplication.java --- a/src/com/beem/project/beem/BeemApplication.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/BeemApplication.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem; @@ -49,14 +49,15 @@ import android.preference.PreferenceManager; /** - * This class contains informations that needs to be global in the application. Theses informations must be necessary - * for the activities and the service. + * This class contains informations that needs to be global in the application. + * Theses informations must be necessary for the activities and the service. * @author Da Risk */ public class BeemApplication extends Application { - /* - * Constants for PREFERENCE_KEY The format of the Preference key is : $name_KEY = "$name" + /* Constants for PREFERENCE_KEY + * The format of the Preference key is : + * $name_KEY = "$name" */ /** Preference key for account username. */ public static final String ACCOUNT_USERNAME_KEY = "account_username"; @@ -159,6 +160,7 @@ /** * Enable Pep in the application context. + * * @param enabled true to enable pep */ public void setPepEnabled(boolean enabled) { @@ -167,6 +169,7 @@ /** * Check if Pep is enabled. + * * @return true if enabled */ public boolean isPepEnabled() { @@ -185,7 +188,7 @@ } @Override - public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { + public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (BeemApplication.ACCOUNT_USERNAME_KEY.equals(key) || BeemApplication.ACCOUNT_PASSWORD_KEY.equals(key)) { String login = mSettings.getString(BeemApplication.ACCOUNT_USERNAME_KEY, ""); String password = mSettings.getString(BeemApplication.ACCOUNT_PASSWORD_KEY, ""); diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/BeemService.java --- a/src/com/beem/project/beem/BeemService.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/BeemService.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem; import org.jivesoftware.smack.ConnectionConfiguration; @@ -78,6 +78,9 @@ import android.provider.Settings; import android.util.Log; +import java.security.GeneralSecurityException; +import javax.net.ssl.SSLContext; + import com.beem.project.beem.service.XmppConnectionAdapter; import com.beem.project.beem.service.XmppFacade; import com.beem.project.beem.service.aidl.IXmppFacade; @@ -88,9 +91,13 @@ import com.beem.project.beem.smack.avatar.AvatarProvider; import com.beem.project.beem.smack.caps.CapsProvider; +import de.duenndns.ssl.MemorizingTrustManager; + /** - * This class is for the Beem service. It must contains every global informations needed to maintain the background - * service. The connection to the xmpp server will be made asynchronously when the service will start. + * This class is for the Beem service. + * It must contains every global informations needed to maintain the background service. + * The connection to the xmpp server will be made asynchronously when the service + * will start. * @author darisk */ public class BeemService extends Service { @@ -132,7 +139,7 @@ */ private void initConnectionConfig() { // TODO add an option for this ? - // SmackConfiguration.setPacketReplyTimeout(30000); +// SmackConfiguration.setPacketReplyTimeout(30000); mUseProxy = mSettings.getBoolean(BeemApplication.PROXY_USE_KEY, false); if (mUseProxy) { String stype = mSettings.getString(BeemApplication.PROXY_TYPE_KEY, "HTTP"); @@ -160,6 +167,7 @@ // maybe not the universal path, but it works on most devices (Samsung Galaxy, Google Nexus One) mConnectionConfiguration.setTruststoreType("BKS"); mConnectionConfiguration.setTruststorePath("/system/etc/security/cacerts.bks"); + installMemorizingTrustManager(mConnectionConfiguration); } /** @@ -180,6 +188,7 @@ return true; } + /** * {@inheritDoc} */ @@ -209,8 +218,8 @@ if (!"".equals(tmpPort)) mPort = Integer.parseInt(tmpPort); } - if (mSettings.getBoolean(BeemApplication.FULL_JID_LOGIN_KEY, false) || "gmail.com".equals(mService) - || "googlemail.com".equals(mService)) { + if (mSettings.getBoolean(BeemApplication.FULL_JID_LOGIN_KEY, false) || + "gmail.com".equals(mService) || "googlemail.com".equals(mService)) { mLogin = tmpJid; } @@ -263,9 +272,11 @@ public void sendNotification(int id, Notification notif) { if (mSettings.getBoolean(BeemApplication.NOTIFICATION_VIBRATE_KEY, true)) notif.defaults |= Notification.DEFAULT_VIBRATE; + notif.ledARGB = 0xff0000ff; // Blue color + notif.ledOnMS = 1000; + notif.ledOffMS = 1000; notif.defaults |= Notification.DEFAULT_LIGHTS; - String ringtoneStr = mSettings.getString(BeemApplication.NOTIFICATION_SOUND_KEY, - Settings.System.DEFAULT_NOTIFICATION_URI.toString()); + String ringtoneStr = mSettings.getString(BeemApplication.NOTIFICATION_SOUND_KEY, Settings.System.DEFAULT_NOTIFICATION_URI.toString()); notif.sound = Uri.parse(ringtoneStr); mNotificationManager.notify(id, notif); } @@ -319,6 +330,22 @@ } /** + * Install the MemorizingTrustManager in the ConnectionConfiguration of Smack. + * + * @param config the configuration to modify + */ + private void installMemorizingTrustManager(ConnectionConfiguration config) { + try { + SSLContext sc = SSLContext.getInstance("TLS"); + sc.init(null, MemorizingTrustManager.getInstanceList(this), + new java.security.SecureRandom()); + config.setCustomSSLContext(sc); + } catch (GeneralSecurityException e) { + Log.w(TAG, "Unable to use MemorizingTrustManager", e); + } + } + + /** * A sort of patch from this thread: http://www.igniterealtime.org/community/thread/31118. Avoid ClassCastException * by bypassing the classloading shit of Smack. * @param pm The ProviderManager. @@ -343,7 +370,8 @@ // Chat State ChatStateExtension.Provider chatState = new ChatStateExtension.Provider(); pm.addExtensionProvider("active", "http://jabber.org/protocol/chatstates", chatState); - pm.addExtensionProvider("composing", "http://jabber.org/protocol/chatstates", chatState); + pm.addExtensionProvider("composing", "http://jabber.org/protocol/chatstates", + chatState); pm.addExtensionProvider("paused", "http://jabber.org/protocol/chatstates", chatState); pm.addExtensionProvider("inactive", "http://jabber.org/protocol/chatstates", chatState); pm.addExtensionProvider("gone", "http://jabber.org/protocol/chatstates", chatState); @@ -360,51 +388,81 @@ pm.addExtensionProvider("event", "http://jabber.org/protocol/pubsub#event", new EventProvider()); //TODO rajouter les manquants pour du full pubsub + //PEP avatar pm.addExtensionProvider("metadata", "urn:xmpp:avatar:metadata", new AvatarMetadataProvider()); pm.addExtensionProvider("data", "urn:xmpp:avatar:data", new AvatarProvider()); - // PEPProvider pep = new PEPProvider(); - // AvatarMetadataProvider avaMeta = new AvatarMetadataProvider(); - // pep.registerPEPParserExtension("urn:xmpp:avatar:metadata", avaMeta); - // pm.addExtensionProvider("event", "http://jabber.org/protocol/pubsub#event", pep); +// PEPProvider pep = new PEPProvider(); +// AvatarMetadataProvider avaMeta = new AvatarMetadataProvider(); +// pep.registerPEPParserExtension("urn:xmpp:avatar:metadata", avaMeta); +// pm.addExtensionProvider("event", "http://jabber.org/protocol/pubsub#event", pep); /* - * // Private Data Storage pm.addIQProvider("query", "jabber:iq:private", new - * PrivateDataManager.PrivateDataIQProvider()); // Time try { pm.addIQProvider("query", "jabber:iq:time", - * Class.forName("org.jivesoftware.smackx.packet.Time")); } catch (ClassNotFoundException e) { - * Log.w("TestClient", "Can't load class for org.jivesoftware.smackx.packet.Time"); } // Roster Exchange - * pm.addExtensionProvider("x", "jabber:x:roster", new RosterExchangeProvider()); // Message Events - * pm.addExtensionProvider("x", "jabber:x:event", new MessageEventProvider()); // XHTML - * pm.addExtensionProvider("html", "http://jabber.org/protocol/xhtml-im", new XHTMLExtensionProvider()); // - * Group Chat Invitations pm.addExtensionProvider("x", "jabber:x:conference", new - * GroupChatInvitation.Provider()); // Data Forms pm.addExtensionProvider("x", "jabber:x:data", new - * DataFormProvider()); // MUC User pm.addExtensionProvider("x", "http://jabber.org/protocol/muc#user", new - * MUCUserProvider()); // MUC Admin pm.addIQProvider("query", "http://jabber.org/protocol/muc#admin", new - * MUCAdminProvider()); // MUC Owner pm.addIQProvider("query", "http://jabber.org/protocol/muc#owner", new - * MUCOwnerProvider()); // Version try { pm.addIQProvider("query", "jabber:iq:version", - * Class.forName("org.jivesoftware.smackx.packet.Version")); } catch (ClassNotFoundException e) { // Not sure - * what's happening here. Log.w("TestClient", "Can't load class for org.jivesoftware.smackx.packet.Version"); } - * // VCard pm.addIQProvider("vCard", "vcard-temp", new VCardProvider()); // Offline Message Requests - * pm.addIQProvider("offline", "http://jabber.org/protocol/offline", new OfflineMessageRequest.Provider()); // - * Offline Message Indicator pm.addExtensionProvider("offline", "http://jabber.org/protocol/offline", new - * OfflineMessageInfo.Provider()); // Last Activity pm.addIQProvider("query", "jabber:iq:last", new - * LastActivity.Provider()); // User Search pm.addIQProvider("query", "jabber:iq:search", new - * UserSearch.Provider()); // SharedGroupsInfo pm.addIQProvider("sharedgroup", - * "http://www.jivesoftware.org/protocol/sharedgroup", new SharedGroupsInfo.Provider()); // JEP-33: Extended - * Stanza Addressing pm.addExtensionProvider("addresses", "http://jabber.org/protocol/address", new - * MultipleAddressesProvider()); // FileTransfer pm.addIQProvider("si", "http://jabber.org/protocol/si", new - * StreamInitiationProvider()); pm.addIQProvider("query", "http://jabber.org/protocol/bytestreams", new - * BytestreamsProvider()); pm.addIQProvider("open", "http://jabber.org/protocol/ibb", new IBBProviders.Open()); - * pm.addIQProvider("close", "http://jabber.org/protocol/ibb", new IBBProviders.Close()); - * pm.addExtensionProvider("data", "http://jabber.org/protocol/ibb", new IBBProviders.Data()); - * pm.addIQProvider("command", COMMAND_NAMESPACE, new AdHocCommandDataProvider()); - * pm.addExtensionProvider("malformed-action", COMMAND_NAMESPACE, new - * AdHocCommandDataProvider.MalformedActionError()); pm.addExtensionProvider("bad-locale", COMMAND_NAMESPACE, - * new AdHocCommandDataProvider.BadLocaleError()); pm.addExtensionProvider("bad-payload", COMMAND_NAMESPACE, new - * AdHocCommandDataProvider.BadPayloadError()); pm.addExtensionProvider("bad-sessionid", COMMAND_NAMESPACE, new - * AdHocCommandDataProvider.BadSessionIDError()); pm.addExtensionProvider("session-expired", COMMAND_NAMESPACE, - * new AdHocCommandDataProvider.SessionExpiredError()); + // Private Data Storage + pm.addIQProvider("query", "jabber:iq:private", new PrivateDataManager.PrivateDataIQProvider()); + // Time + try { + pm.addIQProvider("query", "jabber:iq:time", Class.forName("org.jivesoftware.smackx.packet.Time")); + } catch (ClassNotFoundException e) { + Log.w("TestClient", "Can't load class for org.jivesoftware.smackx.packet.Time"); + } + // Roster Exchange + pm.addExtensionProvider("x", "jabber:x:roster", new RosterExchangeProvider()); + // Message Events + pm.addExtensionProvider("x", "jabber:x:event", new MessageEventProvider()); + // XHTML + pm.addExtensionProvider("html", "http://jabber.org/protocol/xhtml-im", new XHTMLExtensionProvider()); + // Group Chat Invitations + pm.addExtensionProvider("x", "jabber:x:conference", new GroupChatInvitation.Provider()); + // Data Forms + pm.addExtensionProvider("x", "jabber:x:data", new DataFormProvider()); + // MUC User + pm.addExtensionProvider("x", "http://jabber.org/protocol/muc#user", new MUCUserProvider()); + // MUC Admin + pm.addIQProvider("query", "http://jabber.org/protocol/muc#admin", new MUCAdminProvider()); + // MUC Owner + pm.addIQProvider("query", "http://jabber.org/protocol/muc#owner", new MUCOwnerProvider()); + // Version + try { + pm.addIQProvider("query", "jabber:iq:version", Class.forName("org.jivesoftware.smackx.packet.Version")); + } catch (ClassNotFoundException e) { + // Not sure what's happening here. + Log.w("TestClient", "Can't load class for org.jivesoftware.smackx.packet.Version"); + } + // VCard + pm.addIQProvider("vCard", "vcard-temp", new VCardProvider()); + // Offline Message Requests + pm.addIQProvider("offline", "http://jabber.org/protocol/offline", new OfflineMessageRequest.Provider()); + // Offline Message Indicator + pm.addExtensionProvider("offline", "http://jabber.org/protocol/offline", new OfflineMessageInfo.Provider()); + // Last Activity + pm.addIQProvider("query", "jabber:iq:last", new LastActivity.Provider()); + // User Search + pm.addIQProvider("query", "jabber:iq:search", new UserSearch.Provider()); + // SharedGroupsInfo + pm.addIQProvider("sharedgroup", "http://www.jivesoftware.org/protocol/sharedgroup", + new SharedGroupsInfo.Provider()); + // JEP-33: Extended Stanza Addressing + pm.addExtensionProvider("addresses", "http://jabber.org/protocol/address", new MultipleAddressesProvider()); + // FileTransfer + pm.addIQProvider("si", "http://jabber.org/protocol/si", new StreamInitiationProvider()); + pm.addIQProvider("query", "http://jabber.org/protocol/bytestreams", new BytestreamsProvider()); + pm.addIQProvider("open", "http://jabber.org/protocol/ibb", new IBBProviders.Open()); + pm.addIQProvider("close", "http://jabber.org/protocol/ibb", new IBBProviders.Close()); + pm.addExtensionProvider("data", "http://jabber.org/protocol/ibb", new IBBProviders.Data()); + + pm.addIQProvider("command", COMMAND_NAMESPACE, new AdHocCommandDataProvider()); + pm.addExtensionProvider("malformed-action", COMMAND_NAMESPACE, + new AdHocCommandDataProvider.MalformedActionError()); + pm.addExtensionProvider("bad-locale", COMMAND_NAMESPACE, + new AdHocCommandDataProvider.BadLocaleError()); + pm.addExtensionProvider("bad-payload", COMMAND_NAMESPACE, + new AdHocCommandDataProvider.BadPayloadError()); + pm.addExtensionProvider("bad-sessionid", COMMAND_NAMESPACE, + new AdHocCommandDataProvider.BadSessionIDError()); + pm.addExtensionProvider("session-expired", COMMAND_NAMESPACE, + new AdHocCommandDataProvider.SessionExpiredError()); */ } @@ -456,7 +514,7 @@ mOldStatus = mConnection.getPreviousStatus(); if (mConnection.isAuthentificated()) mConnection.changeStatus(Status.CONTACT_STATUS_AWAY, - mSettings.getString(BeemApplication.AUTO_AWAY_MSG_KEY, "Away")); + mSettings.getString(BeemApplication.AUTO_AWAY_MSG_KEY, "Away")); } else if (intentAction.equals(Intent.ACTION_SCREEN_ON)) { if (mConnection.isAuthentificated()) mConnection.changeStatus(mOldMode, mOldStatus); @@ -464,3 +522,4 @@ } } } + diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/package-info.java --- a/src/com/beem/project/beem/package-info.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/package-info.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ /** * This package contains BEEM's entry points. diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/providers/AvatarProvider.java --- a/src/com/beem/project/beem/providers/AvatarProvider.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/providers/AvatarProvider.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.providers; import android.content.ContentProvider; @@ -58,11 +58,13 @@ /** * A simple content provider we expose the differents avatar downloaded. + * */ public class AvatarProvider extends ContentProvider { /** The content uri of this provider. */ - public static final Uri CONTENT_URI = Uri.parse("content://com.beem.project.beem.providers.avatarprovider"); + public static final Uri CONTENT_URI = + Uri.parse("content://com.beem.project.beem.providers.avatarprovider"); private static final String TAG = AvatarProvider.class.getSimpleName(); private static final String AUTHORITY = "com.beem.project.beem.providers.avatarprovider"; @@ -76,16 +78,17 @@ String ID = "_id"; } - private static String[] columnNames = new String[] { Columns.ID }; + private static String[] columnNames = new String[] {Columns.ID }; private static final int AVATAR = 1; private static final int AVATAR_ID = 2; private static final UriMatcher URIMATCHER = new UriMatcher(AVATAR); - static { - URIMATCHER.addURI(AUTHORITY, "*", AVATAR_ID); + static + { + URIMATCHER.addURI(AUTHORITY, "*", AVATAR_ID); // should not be needed if we pass AVATAR on the constructor but it does not work - URIMATCHER.addURI(AUTHORITY, null, AVATAR); + URIMATCHER.addURI(AUTHORITY, null, AVATAR); } private String mDataPath; @@ -98,6 +101,7 @@ /** * Translate the mode passed to {@link #openFile} into mode passed to {@link ParcelFileDescriptor#open}. + * * @param uri the uri to open * @param mode the mode * @return the mode @@ -108,18 +112,23 @@ if ("r".equals(mode)) { modeBits = ParcelFileDescriptor.MODE_READ_ONLY; } else if ("w".equals(mode) || "wt".equals(mode)) { - modeBits = ParcelFileDescriptor.MODE_WRITE_ONLY | ParcelFileDescriptor.MODE_CREATE + modeBits = ParcelFileDescriptor.MODE_WRITE_ONLY + | ParcelFileDescriptor.MODE_CREATE | ParcelFileDescriptor.MODE_TRUNCATE; } else if ("wa".equals(mode)) { - modeBits = ParcelFileDescriptor.MODE_WRITE_ONLY | ParcelFileDescriptor.MODE_CREATE + modeBits = ParcelFileDescriptor.MODE_WRITE_ONLY + | ParcelFileDescriptor.MODE_CREATE | ParcelFileDescriptor.MODE_APPEND; } else if ("rw".equals(mode)) { - modeBits = ParcelFileDescriptor.MODE_READ_WRITE | ParcelFileDescriptor.MODE_CREATE; + modeBits = ParcelFileDescriptor.MODE_READ_WRITE + | ParcelFileDescriptor.MODE_CREATE; } else if ("rwt".equals(mode)) { - modeBits = ParcelFileDescriptor.MODE_READ_WRITE | ParcelFileDescriptor.MODE_CREATE + modeBits = ParcelFileDescriptor.MODE_READ_WRITE + | ParcelFileDescriptor.MODE_CREATE | ParcelFileDescriptor.MODE_TRUNCATE; } else { - throw new FileNotFoundException("Bad mode for " + uri + ": " + mode); + throw new FileNotFoundException("Bad mode for " + uri + ": " + + mode); } return modeBits; } @@ -134,7 +143,8 @@ } @Override - public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException { + public ParcelFileDescriptor openFile(Uri uri, String mode) + throws FileNotFoundException { String id = uri.getPath(); File data = new File(mDataPath, id); int modeBits = AvatarProvider.modeToMode(uri, mode); @@ -158,7 +168,7 @@ String id = uri.getPathSegments().get(0); File f = new File(mDataPath, id); if (f.exists()) - c.newRow().add(f.getName()); + c.newRow().add(f.getName()); break; default: Log.w(TAG, "Unsupported uri for query match = " + match); diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/providers/package-info.java --- a/src/com/beem/project/beem/providers/package-info.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/providers/package-info.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,10 +40,10 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ + /** * ContentProviders for Beem. */ package com.beem.project.beem.providers; - diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/BeemAvatarCache.java --- a/src/com/beem/project/beem/service/BeemAvatarCache.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/service/BeemAvatarCache.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.service; import android.content.ContentResolver; @@ -72,6 +72,7 @@ /** * Create a BeemAvatarCache. + * * @param ctx The android context of the cache. */ public BeemAvatarCache(final Context ctx) { @@ -79,6 +80,7 @@ mContentResolver = mContext.getContentResolver(); } + @Override public void put(String key, byte[] data) throws IOException { Uri uri = AvatarProvider.CONTENT_URI.buildUpon().appendPath(key).build(); @@ -98,7 +100,7 @@ byte[] data = new byte[1024]; int nbread; while ((nbread = in.read(data)) != -1) - os.write(data, 0, nbread); + os.write(data, 0, nbread); } finally { in.close(); os.close(); diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/BeemAvatarManager.java --- a/src/com/beem/project/beem/service/BeemAvatarManager.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/service/BeemAvatarManager.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.service; @@ -61,7 +61,8 @@ import org.jivesoftware.smack.Connection; /** - * An AvatarManager for Beem. It allows to publish avatar on the Android platform. + * An AvatarManager for Beem. + * It allows to publish avatar on the Android platform. */ public class BeemAvatarManager extends AvatarManager { private static final String TAG = BeemAvatarManager.class.getSimpleName(); @@ -71,6 +72,7 @@ /** * Create a BeemAvatarManager. + * * @param ctx the Android context * @param con the connection * @param pepMgr the PepSubManager of the connection @@ -78,13 +80,14 @@ * @param autoDownload tre to enable auto download of avatars */ public BeemAvatarManager(final Context ctx, final Connection con, final PepSubManager pepMgr, - final AvatarCache cache, final boolean autoDownload) { + final AvatarCache cache, final boolean autoDownload) { super(con, pepMgr, cache, autoDownload); mContext = ctx; } /** * Publish an avatar. + * * @param avatarUri the uri of the avatar * @return true if the avatar was successfully published */ @@ -99,7 +102,9 @@ } /** - * Publish an avatar. This will send the XMPP stanza to enable the publication of an avatar. + * Publish an avatar. + * This will send the XMPP stanza to enable the publication of an avatar. + * * @param bitmap the avatar to publish * @return true on success false otherwise */ @@ -122,6 +127,7 @@ /** * Send this bitmap to the avatar data node of the pep server. + * * @param bmp the avatar bitmap * @param format the image format to publish this data * @param quality the compression quality use for JPEG compression @@ -147,6 +153,7 @@ /** * Convert the bitmap to a byte array. + * * @param bitmap the avatar bitmap * @param format the resulting image format * @param quality the compression quality use for JPEG compression diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/BeemCapsManager.java --- a/src/com/beem/project/beem/service/BeemCapsManager.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/service/BeemCapsManager.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.service; import org.jivesoftware.smack.Connection; @@ -79,6 +79,7 @@ /** * Create a BeemCapsManager. + * * @param sdm the ServiceDiscoveryManager to use * @param conn the connection to use * @param context the Android context to use to store data @@ -89,9 +90,10 @@ initCacheDirectory(); } + @Override protected DiscoverInfo load(String ver) { - File fver = new File(mCacheDir, ver); + File fver = new File(mCacheDir, sanitizeName(ver)); try { Reader fr = new BufferedReader(new FileReader(fver)); try { @@ -99,7 +101,7 @@ mParser = makeParser(); mParser.setInput(fr); return (DiscoverInfo) PacketParserUtils.parsePacketExtension("query", - "http://jabber.org/protocol/disco#info", mParser); + "http://jabber.org/protocol/disco#info", mParser); } finally { fr.close(); @@ -113,11 +115,12 @@ @Override protected void store(String ver, DiscoverInfo info) { - File fver = new File(mCacheDir, ver); + + File fver = new File(mCacheDir, sanitizeName(ver)); try { Writer fw = new BufferedWriter(new FileWriter(fver)); try { - String data = info.toXML(); + String data = info.toXML(); fw.write(data, 0, data.length()); } finally { fw.close(); @@ -131,7 +134,7 @@ protected boolean isInCache(String ver) { boolean result = super.isInCache(ver); if (!result) { - File fver = new File(mCacheDir, ver); + File fver = new File(mCacheDir, sanitizeName(ver)); result = fver.exists(); } return result; @@ -148,6 +151,7 @@ /** * Make an Xml parser. + * * @return the created xml parser. * @throws XmlPullParserException if an error occurs while creating the parser. */ @@ -156,4 +160,13 @@ fact.setNamespaceAware(true); return fact.newPullParser(); } + + /** + * Sanitize the base64 ver attribute in order to use it as a filename. + * @param ver the base64 ver attribute + * @return a sanitize filename for the ver attribute + */ + private String sanitizeName(String ver) { + return ver.replaceAll("/", "."); + } } diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/BeemChatManager.java --- a/src/com/beem/project/beem/service/BeemChatManager.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/service/BeemChatManager.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.service; import java.io.File; @@ -89,7 +89,8 @@ private final ChatManager mAdaptee; private final Map mChats = new HashMap(); private final ChatListener mChatListener = new ChatListener(); - private final RemoteCallbackList mRemoteChatCreationListeners = new RemoteCallbackList(); + private final RemoteCallbackList mRemoteChatCreationListeners = + new RemoteCallbackList(); private final BeemService mService; private final ChatRosterListener mChatRosterListn = new ChatRosterListener(); @@ -188,8 +189,7 @@ BeemApplication.ACCOUNT_USERNAME_KEY, ""); String historyPath = PreferenceManager.getDefaultSharedPreferences(mService.getBaseContext()).getString( BeemApplication.CHAT_HISTORY_KEY, ""); - if ("".equals(historyPath)) - historyPath = "/Android/data/com.beem.project.beem/chat/"; + if ("".equals(historyPath)) historyPath = "/Android/data/com.beem.project.beem/chat/"; res.setHistory(history); res.setAccountUser(accountUser); res.listenOtrSession(); @@ -298,9 +298,9 @@ try { CharSequence tickerText = mService.getBind().getRoster().getContact(chat.getParticipant().getJID()) .getName(); - Notification notification = new Notification(android.R.drawable.stat_notify_chat, tickerText, - System.currentTimeMillis()); - notification.flags = Notification.FLAG_AUTO_CANCEL; + Notification notification = new Notification(android.R.drawable.stat_notify_chat, tickerText, System + .currentTimeMillis()); + notification.flags = Notification.FLAG_AUTO_CANCEL | Notification.FLAG_SHOW_LIGHTS; notification.setLatestEventInfo(mService, tickerText, msgBody, makeChatIntent(chat)); mService.sendNotification(chat.getParticipant().getJID().hashCode(), notification); } catch (RemoteException e) { diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/ChatAdapter.java --- a/src/com/beem/project/beem/service/ChatAdapter.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/service/ChatAdapter.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.service; import java.io.File; diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/Contact.aidl diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/Contact.java --- a/src/com/beem/project/beem/service/Contact.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/service/Contact.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.service; import java.util.ArrayList; @@ -141,6 +141,7 @@ /** * Make an xmpp uri for a spcific jid. + * * @param jid the jid to represent as an uri * @return an uri representing this jid. */ @@ -284,6 +285,7 @@ /** * Get the avatar id of the contact. + * * @return the avatar id or null if there is not */ public String getAvatarId() { @@ -320,6 +322,7 @@ /** * Set the avatar id of the contact. + * * @param avatarId the avatar id */ public void setAvatarId(String avatarId) { diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/LoginAsyncTask.java --- a/src/com/beem/project/beem/service/LoginAsyncTask.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/service/LoginAsyncTask.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.service; import android.os.AsyncTask; diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/Message.aidl diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/Message.java --- a/src/com/beem/project/beem/service/Message.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/service/Message.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.service; import org.jivesoftware.smack.packet.XMPPError; @@ -69,9 +69,6 @@ /** Error message type. */ public static final int MSG_TYPE_ERROR = 400; - /** Informational message type. */ - public static final int MSG_TYPE_INFO = 500; - /** Parcelable.Creator needs by Android. */ public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { @@ -294,6 +291,7 @@ /** * Set the Date of the message. + * * @param date date of the message. */ public void setTimestamp(Date date) { @@ -302,6 +300,7 @@ /** * Get the Date of the message. + * * @return if it is a delayed message get the date the message was sended. */ public Date getTimestamp() { diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/PresenceAdapter.aidl diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/PresenceAdapter.java --- a/src/com/beem/project/beem/service/PresenceAdapter.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/service/PresenceAdapter.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.service; import org.jivesoftware.smack.packet.Presence; @@ -101,8 +101,7 @@ mStatusText = presence.getStatus(); } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see android.os.Parcelable#describeContents() */ @Override @@ -191,8 +190,7 @@ this.mType = type; } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see android.os.Parcelable#writeToParcel(android.os.Parcel, int) */ @Override diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/PrivacyListItem.aidl diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/PrivacyListItem.java --- a/src/com/beem/project/beem/service/PrivacyListItem.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/service/PrivacyListItem.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.service; import android.os.Parcel; diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/PrivacyListManagerAdapter.java --- a/src/com/beem/project/beem/service/PrivacyListManagerAdapter.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/service/PrivacyListManagerAdapter.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.service; import java.util.ArrayList; @@ -71,7 +71,8 @@ private final PrivacyListManager mPrivacyListManager; - private final RemoteCallbackList mPrivacyListListeners = new RemoteCallbackList(); + private final RemoteCallbackList mPrivacyListListeners = + new RemoteCallbackList(); private final PrivacyListListenerAdapter mPrivacyListListener = new PrivacyListListenerAdapter(); /** @@ -83,16 +84,14 @@ mPrivacyListManager.addListener(mPrivacyListListener); } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see com.beem.project.beem.service.aidl.IPrivacyListManager#blockUser(java.lang.String, java.lang.String) */ @Override public void blockUser(String listName, String jid) throws RemoteException { } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see com.beem.project.beem.service.aidl.IPrivacyListManager#createPrivacyList(java.lang.String, java.util.List) */ @Override @@ -112,8 +111,7 @@ Log.d(TAG, "END createPrivacyList."); } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see com.beem.project.beem.service.aidl.IPrivacyListManager#declineActivePrivacyList() */ @Override @@ -125,8 +123,7 @@ } } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see com.beem.project.beem.service.aidl.IPrivacyListManager#declineDefaultPrivacyList() */ @Override @@ -138,8 +135,7 @@ } } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see com.beem.project.beem.service.aidl.IPrivacyListManager#editPrivacyList(java.lang.String, java.util.List) */ @Override @@ -153,8 +149,7 @@ Log.d(TAG, "END editPrivacyList."); } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see com.beem.project.beem.service.aidl.IPrivacyListManager#getActivePrivacyList() */ @Override @@ -168,8 +163,7 @@ return null; } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see com.beem.project.beem.service.aidl.IPrivacyListManager#getBlockedGroupsByList(java.lang.String) */ @Override @@ -187,8 +181,7 @@ return blockedGroups; } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see com.beem.project.beem.service.aidl.IPrivacyListManager#getBlockedUsersByList(java.lang.String) */ @Override @@ -206,8 +199,7 @@ return blockedUsers; } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see com.beem.project.beem.service.aidl.IPrivacyListManager#getDefaultPrivacyList() */ @Override @@ -221,8 +213,7 @@ return null; } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see com.beem.project.beem.service.aidl.IPrivacyListManager#removePrivacyList(java.lang.String) */ @Override @@ -234,8 +225,7 @@ } } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see com.beem.project.beem.service.aidl.IPrivacyListManager#setActivePrivacyList(java.lang.String) */ @Override @@ -247,8 +237,7 @@ } } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see com.beem.project.beem.service.aidl.IPrivacyListManager#setDefaultPrivacyList(java.lang.String) */ @Override @@ -298,8 +287,7 @@ /** * Constructor. */ - public PrivacyListListenerAdapter() { - } + public PrivacyListListenerAdapter() { } @Override public void setPrivacyList(final String listName, final List listItem) { @@ -345,8 +333,7 @@ mPrivacyListListeners.unregister(listener); } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see com.beem.project.beem.service.aidl.IPrivacyListManager#getPrivacyLists() */ @Override diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/RosterAdapter.java --- a/src/com/beem/project/beem/service/RosterAdapter.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/service/RosterAdapter.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.service; import java.util.ArrayList; @@ -77,7 +77,8 @@ private static final String TAG = "RosterAdapter"; private final Roster mAdaptee; - private final RemoteCallbackList mRemoteRosListeners = new RemoteCallbackList(); + private final RemoteCallbackList mRemoteRosListeners = + new RemoteCallbackList(); private final Map mDefaultStatusMessages; private final RosterListenerAdapter mRosterListener = new RosterListenerAdapter(); private Map mAvatarIdmap = new HashMap(); @@ -109,6 +110,7 @@ mAvatarManager.addAvatarListener(new AvatarEventListener()); } + /** * {@inheritDoc} */ @@ -210,8 +212,7 @@ mAdaptee.getEntry(jid).setName(name); } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see com.beem.project.beem.service.aidl.IRoster#getPresence(java.lang.String) */ @Override @@ -219,8 +220,7 @@ return new PresenceAdapter(mAdaptee.getPresence(jid)); } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see com.beem.project.beem.service.aidl.IRoster#addContactToGroup(java.lang.String, java.lang.String) */ @Override @@ -234,8 +234,7 @@ } } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see com.beem.project.beem.service.aidl.IRoster#removeContactFromGroup(java.lang.String, java.lang.String) */ @Override @@ -284,14 +283,14 @@ */ private Map createDefaultStatusMessagesMap(Context context) { Map defaultStatusMessages = new HashMap(); - defaultStatusMessages.put(Status.CONTACT_STATUS_AVAILABLE, - context.getString(R.string.contact_status_msg_available)); - defaultStatusMessages.put(Status.CONTACT_STATUS_AVAILABLE_FOR_CHAT, - context.getString(R.string.contact_status_msg_available_chat)); + defaultStatusMessages.put(Status.CONTACT_STATUS_AVAILABLE, context + .getString(R.string.contact_status_msg_available)); + defaultStatusMessages.put(Status.CONTACT_STATUS_AVAILABLE_FOR_CHAT, context + .getString(R.string.contact_status_msg_available_chat)); defaultStatusMessages.put(Status.CONTACT_STATUS_AWAY, context.getString(R.string.contact_status_msg_away)); defaultStatusMessages.put(Status.CONTACT_STATUS_BUSY, context.getString(R.string.contact_status_msg_dnd)); - defaultStatusMessages.put(Status.CONTACT_STATUS_DISCONNECT, - context.getString(R.string.contact_status_msg_offline)); + defaultStatusMessages.put(Status.CONTACT_STATUS_DISCONNECT, context + .getString(R.string.contact_status_msg_offline)); defaultStatusMessages.put(Status.CONTACT_STATUS_UNAVAILABLE, context.getString(R.string.contact_status_msg_xa)); return defaultStatusMessages; @@ -394,14 +393,14 @@ /** * Listener on avatar metadata event. + * */ private class AvatarEventListener implements AvatarListener { /** * Constructor. */ - public AvatarEventListener() { - } + public AvatarEventListener() { } @Override public void onAvatarChange(String from, String avatarId, List avatarInfos) { diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/UserInfo.java --- a/src/com/beem/project/beem/service/UserInfo.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/service/UserInfo.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,14 +40,16 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.service; import android.os.Parcel; import android.os.Parcelable; /** - * This class contains information about the user of the connection. These informations are sent by the connection. + * This class contains information about the user of the connection. + * These informations are sent by the connection. + * */ public class UserInfo implements Parcelable { @@ -99,6 +101,7 @@ /** * Get the avatar id of the user. + * * @return the avatar id */ public String getAvatarId() { @@ -107,6 +110,7 @@ /** * Set the avater id of the user. + * * @param avatarId the avatar id */ public void setAvatarId(String avatarId) { @@ -115,6 +119,7 @@ /** * Get the full jid of the user. + * * @return the jid */ public String getJid() { diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/XmppConnectionAdapter.java --- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.service; import org.jivesoftware.smack.ConnectionConfiguration; @@ -116,7 +116,8 @@ private BeemAvatarManager mAvatarManager; private PepSubManager mPepManager; private SharedPreferences mPref; - private final RemoteCallbackList mRemoteConnListeners = new RemoteCallbackList(); + private final RemoteCallbackList mRemoteConnListeners = + new RemoteCallbackList(); private final SubscribePacketListener mSubscribePacketListener = new SubscribePacketListener(); private final ConnexionListenerAdapter mConListener = new ConnexionListenerAdapter(); @@ -131,8 +132,8 @@ * @param password password to use on connect * @param service the background service associated with the connection. */ - public XmppConnectionAdapter(final ConnectionConfiguration config, final String login, final String password, - final BeemService service) { + public XmppConnectionAdapter(final ConnectionConfiguration config, + final String login, final String password, final BeemService service) { this(new XMPPConnection(config), login, password, service); } @@ -143,8 +144,8 @@ * @param password password to use on connect * @param service the background service associated with the connection. */ - public XmppConnectionAdapter(final String serviceName, final String login, final String password, - final BeemService service) { + public XmppConnectionAdapter(final String serviceName, + final String login, final String password, final BeemService service) { this(new XMPPConnection(serviceName), login, password, service); } @@ -155,8 +156,8 @@ * @param password The password to use * @param service the background service associated with the connection. */ - public XmppConnectionAdapter(final XMPPConnection con, final String login, final String password, - final BeemService service) { + public XmppConnectionAdapter(final XMPPConnection con, + final String login, final String password, final BeemService service) { mAdaptee = con; PrivacyListManager.getInstanceFor(mAdaptee); mLogin = login; @@ -198,8 +199,8 @@ try { //TODO NIKITA DOES SOME SHIT !!! Fix this monstruosity String str = mService.getResources().getString( - mService.getResources().getIdentifier(e.getXMPPError().getCondition().replace("-", "_"), - "string", "com.beem.project.beem")); + mService.getResources().getIdentifier( + e.getXMPPError().getCondition().replace("-", "_"), "string", "com.beem.project.beem")); mErrorMsg = str; } catch (NullPointerException e2) { if (!"".equals(e.getMessage())) @@ -243,7 +244,7 @@ mChatManager = new BeemChatManager(mAdaptee.getChatManager(), mService, mAdaptee.getRoster()); //nikita: I commented this line because of the logs provided in http://www.beem-project.com/issues/321 - //Also, since the privacylistmanager isn't finished and used, it will be safer to not initialise it + //Also, since the privacylistmanager isn't finished and used, it will be safer to not initialize it //mPrivacyListManager = new PrivacyListManagerAdapter(PrivacyListManager.getInstanceFor(mAdaptee)); mService.initJingle(mAdaptee); discoverServerFeatures(); @@ -333,6 +334,7 @@ /** * Get the AvatarManager of this connection. + * * @return the AvatarManager or null if there is not */ public BeemAvatarManager getAvatarManager() { @@ -361,13 +363,13 @@ */ private void updateNotification(String text) { Notification mStatusNotification; - mStatusNotification = new Notification(com.beem.project.beem.R.drawable.beem_status_icon, text, - System.currentTimeMillis()); + mStatusNotification = new Notification(com.beem.project.beem.R.drawable.beem_status_icon, text, System + .currentTimeMillis()); mStatusNotification.defaults = Notification.DEFAULT_LIGHTS; mStatusNotification.flags = Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT; - mStatusNotification.setLatestEventInfo(mService, "Beem Status", text, - PendingIntent.getActivity(mService, 0, new Intent(mService, ChangeStatus.class), 0)); + mStatusNotification.setLatestEventInfo(mService, "Beem Status", text, PendingIntent.getActivity(mService, 0, + new Intent(mService, ChangeStatus.class), 0)); // bypass the preferences for notification mService.getNotificationManager().notify(BeemService.NOTIFICATION_STATUS_ID, mStatusNotification); } @@ -414,7 +416,8 @@ /** * Get the user informations. - * @return the user infos + * + * @return the user infos or null if not logged */ public UserInfo getUserInfo() { return mUserInfo; @@ -667,10 +670,11 @@ R.string.AcceptContactRequest, from), System.currentTimeMillis()); notif.flags = Notification.FLAG_AUTO_CANCEL; Intent intent = new Intent(mService, Subscription.class); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK).putExtra("from", from); - notif.setLatestEventInfo(mService, from, - mService.getString(R.string.AcceptContactRequestFrom, from), - PendingIntent.getActivity(mService, 0, intent, PendingIntent.FLAG_ONE_SHOT)); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + .putExtra("from", from); + notif.setLatestEventInfo(mService, from, mService + .getString(R.string.AcceptContactRequestFrom, from), PendingIntent.getActivity(mService, 0, + intent, PendingIntent.FLAG_ONE_SHOT)); int id = packet.hashCode(); mService.sendNotification(id, notif); } @@ -718,9 +722,9 @@ notification.flags = Notification.FLAG_AUTO_CANCEL; Intent intent = new Intent(mService, Subscription.class); intent.setData(Contact.makeXmppUri(from)); - notification.setLatestEventInfo(mService, from, - mService.getString(R.string.AcceptContactRequestFrom, from), - PendingIntent.getActivity(mService, 0, intent, PendingIntent.FLAG_ONE_SHOT)); + notification.setLatestEventInfo(mService, from, mService + .getString(R.string.AcceptContactRequestFrom, from), PendingIntent.getActivity(mService, 0, + intent, PendingIntent.FLAG_ONE_SHOT)); int id = p.hashCode(); mService.sendNotification(id, notification); } diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/XmppFacade.java --- a/src/com/beem/project/beem/service/XmppFacade.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/service/XmppFacade.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.service; import org.jivesoftware.smack.packet.Presence; @@ -142,8 +142,7 @@ mConnexion.getAdaptee().sendPacket(presence2); } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see com.beem.project.beem.service.aidl.IXmppFacade#call(java.lang.String) */ @Override diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/aidl/IBeemConnectionListener.aidl diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/aidl/IBeemRosterListener.aidl diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/aidl/IChat.aidl diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/aidl/IChatManager.aidl diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/aidl/IChatManagerListener.aidl diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/aidl/IContact.aidl diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/aidl/IMessageListener.aidl diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/aidl/IPrivacyListListener.aidl diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/aidl/IPrivacyListManager.aidl diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/aidl/IRoster.aidl diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/aidl/IXmppConnection.aidl diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/aidl/IXmppFacade.aidl --- a/src/com/beem/project/beem/service/aidl/IXmppFacade.aidl Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/service/aidl/IXmppFacade.aidl Sat Nov 05 23:49:30 2011 +0100 @@ -103,6 +103,10 @@ void disableAvatarPublishing(); + /** + * Get the user informations. + * @return null if not connected + */ UserInfo getUserInfo(); IPrivacyListManager getPrivacyListManager(); diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/service/package-info.java --- a/src/com/beem/project/beem/service/package-info.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/service/package-info.java Sat Nov 05 23:49:30 2011 +0100 @@ -39,7 +39,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ /** * This package contains all the class use by the service. */ diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/smack/avatar/AvatarCache.java --- a/src/com/beem/project/beem/smack/avatar/AvatarCache.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/smack/avatar/AvatarCache.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,19 +40,22 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.smack.avatar; import java.io.IOException; import java.io.InputStream; /** - * Interface for an AvatarCache. This can be improved to a generic cache. + * Interface for an AvatarCache. + * This can be improved to a generic cache. + * */ public interface AvatarCache { /** * Put some datas in cache. + * * @param id the key id of the data * @param data the datato cache * @throws IOException if an IO error occurs while caching the data @@ -61,6 +64,7 @@ /** * Put some datas in cache. + * * @param id the key id of the data * @param data an InputStream to the data to cache * @throws IOException if an IO error occurs while caching the data @@ -69,14 +73,16 @@ /** * Get some data from the cache. + * * @param id the id of the data to get * @return the cached data - * @throws IOException if an IO error occurs while geting the data + * @throws IOException if an IO error occurs while geting the data */ byte[] get(String id) throws IOException; /** * Test if a data is in cache. + * * @param id the id of the data * @return true if data is in cache false otherwise */ diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/smack/avatar/AvatarExtension.java --- a/src/com/beem/project/beem/smack/avatar/AvatarExtension.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/smack/avatar/AvatarExtension.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,14 +40,16 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.smack.avatar; import org.jivesoftware.smack.util.Base64; import org.jivesoftware.smack.packet.PacketExtension; /** - * PacketExtension to represent the Avatar data. XML namespace urn:xmpp:avatar:data + * PacketExtension to represent the Avatar data. + * XML namespace urn:xmpp:avatar:data + * */ public class AvatarExtension implements PacketExtension { @@ -71,6 +73,7 @@ /** * Get the avatar data as a Base64 string. + * * @return a base64 string. */ public String getBase64() { @@ -79,6 +82,7 @@ /** * Get the avatar data. + * * @return the decoded data */ public byte[] getData() { diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/smack/avatar/AvatarListener.java --- a/src/com/beem/project/beem/smack/avatar/AvatarListener.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/smack/avatar/AvatarListener.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.smack.avatar; import java.util.List; @@ -48,11 +48,13 @@ /** * A listener for avatar changes event. + * */ public interface AvatarListener { /** * Event which is fired when a contact change avatar. + * * @param from the contact who change his avatar * @param avatarId the new avatar id, may be null if the contact set no avatar * @param avatarInfos the metadata infos of the avatar, may be empty if the contact set no avatar diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/smack/avatar/AvatarManager.java --- a/src/com/beem/project/beem/smack/avatar/AvatarManager.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/smack/avatar/AvatarManager.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.smack.avatar; import com.beem.project.beem.smack.avatar.AvatarMetadataExtension.Info; @@ -62,13 +62,15 @@ import org.jivesoftware.smack.util.StringUtils; /** - * This class deals with the avatar data. It can be configured to auto retrieve the avatar and put it in cache. + * This class deals with the avatar data. + * It can be configured to auto retrieve the avatar and put it in cache. + * */ public class AvatarManager { - /** The pubsub node for avatar data. */ + /** The pubsub node for avatar data. */ public static final String AVATARDATA_NODE = "urn:xmpp:avatar:data"; - /** The pubsub node for avatar metadata. */ + /** The pubsub node for avatar metadata. */ public static final String AVATARMETADATA_NODE = "urn:xmpp:avatar:metadata"; private PepSubManager mPep; @@ -79,13 +81,14 @@ /** * Create an AvatarManager. + * * @param con the connection * @param pepMgr the PepSubManager of the Connection * @param cache the cache which will store the avatars * @param autoDownload true to enable auto download of avatars */ - public AvatarManager(final Connection con, final PepSubManager pepMgr, final AvatarCache cache, - final boolean autoDownload) { + public AvatarManager(final Connection con, final PepSubManager pepMgr, + final AvatarCache cache, final boolean autoDownload) { mCon = con; mPep = pepMgr; mAutoDownload = autoDownload; @@ -95,6 +98,7 @@ /** * Create an AvatarManager. + * * @param con the connection * @param pepMgr the PepSubManager of the Connection * @param autoDownload true to enable auto download of avatars @@ -109,6 +113,7 @@ /** * Get an avatar from the cache. + * * @param avatarId the id of the avatar * @return the avatar or null if it cannot be retrieved from the cache */ @@ -124,6 +129,7 @@ /** * Add an AvatarListener. + * * @param listener the AvatarListener to add */ public void addAvatarListener(AvatarListener listener) { @@ -133,6 +139,7 @@ /** * Remove an AvatarListener. + * * @param listener the AvatarListener to remove */ public void removeAvatarListener(AvatarListener listener) { @@ -141,6 +148,7 @@ /** * Download an avatar. + * * @param from The jid of the user * @param avatarId the id of the avatar * @param info the metadata information of the avatar to download @@ -150,7 +158,7 @@ try { AvatarRetriever retriever = AvatarRetrieverFactory.getRetriever(mCon, from, info); byte[] avatar = retriever.getAvatar(); - // TODO check the hash before store + // TODO check the hash before store mCache.put(avatarId, avatar); return true; } catch (IOException e) { @@ -170,6 +178,7 @@ /** * Send an avatar image to the pep server. + * * @param data the image data. * @return true if the image where successfully sent. false otherwise */ @@ -185,7 +194,9 @@ } /** - * Send the metadata of the avatar you want to publish. By sending this metadata, you publish an avatar. + * Send the metadata of the avatar you want to publish. + * By sending this metadata, you publish an avatar. + * * @param id the id of the metadata item * @param metadata the metadata to publish */ @@ -196,8 +207,10 @@ } /** - * Select the avatar to download. Subclass should override this method to take control over the selection process. + * Select the avatar to download. + * Subclass should override this method to take control over the selection process. * This implementation select the first element. + * * @param available list of the avatar metadata information * @return the metadata of the avatar to download */ @@ -205,8 +218,10 @@ return available.get(0); } + /** * Get the id corresponding to this avatar data. + * * @param data the avatar data * @return the id * @throws NoSuchAlgorithmException if the sha-1 algorithm is unavailable @@ -219,6 +234,7 @@ /** * Publish an avatar data. + * * @param id the id of the avatar data * @param data the data of the avatar */ @@ -231,6 +247,7 @@ /** * Fire the listeners for avatar change. + * * @param from the jid of the contact * @param avatarId the new avatar id * @param avatarInfos the metadata infos of the avatar @@ -240,6 +257,7 @@ l.onAvatarChange(from, avatarId, avatarInfos); } + /** * A listener to PEPEevent. */ diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/smack/avatar/AvatarMetadataExtension.java --- a/src/com/beem/project/beem/smack/avatar/AvatarMetadataExtension.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/smack/avatar/AvatarMetadataExtension.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.smack.avatar; import java.util.LinkedList; @@ -49,7 +49,9 @@ import org.jivesoftware.smack.packet.PacketExtension; /** - * PacketExtension to represent the Avatar metadata. XML namespace urn:xmpp:avatar:metadata + * PacketExtension to represent the Avatar metadata. + * XML namespace urn:xmpp:avatar:metadata + * */ public class AvatarMetadataExtension implements PacketExtension { private List mInfos = new LinkedList(); @@ -62,6 +64,7 @@ /** * Get the metadata informations. + * * @return a list of informations */ public List getInfos() { @@ -70,6 +73,7 @@ /** * Add a metadate information. + * * @param info the metadata information to add */ public void addInfo(Info info) { @@ -110,6 +114,7 @@ /** * Create an Info. + * * @param id the id of the info * @param type the MIME type of the avatar * @param bytes the size of the avatar in bytes @@ -122,6 +127,7 @@ /** * Set the size of the avatar in bytes. + * * @param bytes the size */ public void setBytes(int bytes) { @@ -130,6 +136,7 @@ /** * Set the size of the avatar in bytes. + * * @return the size */ public int getBytes() { @@ -138,6 +145,7 @@ /** * Set the height. + * * @param height the height */ public void setHeight(int height) { @@ -146,6 +154,7 @@ /** * Get the height. + * * @return the height */ public int getHeight() { @@ -154,6 +163,7 @@ /** * Set the width. + * * @param width the width */ public void setWidth(int width) { @@ -162,6 +172,7 @@ /** * Get the width. + * * @return the width */ public int getWidth() { @@ -170,6 +181,7 @@ /** * Set the url. + * * @param url the url */ public void setUrl(String url) { @@ -178,6 +190,7 @@ /** * Get the url. + * * @return the url, null if no url is present */ public String getUrl() { @@ -186,6 +199,7 @@ /** * Get the id. + * * @return the id */ public String getId() { @@ -194,6 +208,7 @@ /** * Set the id. + * * @param id the id */ public void setId(String id) { @@ -202,6 +217,7 @@ /** * Set the MIME type of the avatar. + * * @param type the type */ public void setType(String type) { @@ -210,6 +226,7 @@ /** * Get the MIME type of the avatar. + * * @return the type, null if no type is present */ public String getType() { @@ -218,6 +235,7 @@ /** * Return this information as an xml element. + * * @return an xml element representing this information */ public String toXML() { diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/smack/avatar/AvatarMetadataProvider.java --- a/src/com/beem/project/beem/smack/avatar/AvatarMetadataProvider.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/smack/avatar/AvatarMetadataProvider.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.smack.avatar; import org.jivesoftware.smack.packet.PacketExtension; @@ -48,19 +48,21 @@ import org.xmlpull.v1.XmlPullParser; /** - * A PacketExtensionProvider to parse the Avatar metadata. XML namespace urn:xmpp:avatar:metadata + * A PacketExtensionProvider to parse the Avatar metadata. + * XML namespace urn:xmpp:avatar:metadata */ public class AvatarMetadataProvider implements PacketExtensionProvider { /** - * Creates a new AvatarMetadataProvider. ProviderManager requires that every PacketExtensionProvider has a public, - * no-argument constructor + * Creates a new AvatarMetadataProvider. + * ProviderManager requires that every PacketExtensionProvider has a public, no-argument constructor */ public AvatarMetadataProvider() { } @Override - public PacketExtension parseExtension(XmlPullParser parser) throws Exception { + public PacketExtension parseExtension(XmlPullParser parser) + throws Exception { AvatarMetadataExtension metadata = new AvatarMetadataExtension(); boolean done = false; StringBuilder buffer = new StringBuilder(); @@ -78,12 +80,10 @@ try { if (sbytes != null) bytes = Integer.parseInt(sbytes); - } catch (NumberFormatException e) { - } + } catch (NumberFormatException e) { } if (bytes != 0 && id != null && type != null) info = new AvatarMetadataExtension.Info(id, type, bytes); - else - // invalid info + else // invalid info continue; String url = parser.getAttributeValue(null, "url"); @@ -97,8 +97,7 @@ width = Integer.parseInt(parser.getAttributeValue(null, "width")); info.setHeight(height); info.setWidth(width); - } catch (NumberFormatException e) { - } + } catch (NumberFormatException e) { } metadata.addInfo(info); } } else if (eventType == XmlPullParser.END_TAG) { diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/smack/avatar/AvatarProvider.java --- a/src/com/beem/project/beem/smack/avatar/AvatarProvider.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/smack/avatar/AvatarProvider.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.smack.avatar; import org.jivesoftware.smack.packet.PacketExtension; @@ -48,19 +48,21 @@ import org.xmlpull.v1.XmlPullParser; /** - * A PacketExtensionProvider to parse the Avatar data. XML namespace urn:xmpp:avatar:data + * A PacketExtensionProvider to parse the Avatar data. + * XML namespace urn:xmpp:avatar:data */ public class AvatarProvider implements PacketExtensionProvider { /** - * Creates a new AvatarProvider. ProviderManager requires that every PacketExtensionProvider has a public, - * no-argument constructor + * Creates a new AvatarProvider. + * ProviderManager requires that every PacketExtensionProvider has a public, no-argument constructor */ public AvatarProvider() { } @Override - public PacketExtension parseExtension(XmlPullParser parser) throws Exception { + public PacketExtension parseExtension(XmlPullParser parser) + throws Exception { AvatarMetadataExtension metadata = new AvatarMetadataExtension(); boolean done = false; StringBuilder buffer = new StringBuilder(); diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/smack/avatar/AvatarRetriever.java --- a/src/com/beem/project/beem/smack/avatar/AvatarRetriever.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/smack/avatar/AvatarRetriever.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.smack.avatar; import java.io.IOException; @@ -52,6 +52,7 @@ /** * Retrieve the avatar. + * * @return the avatar * @throws IOException if an IO error occurs while retrieving the avatar */ diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/smack/avatar/AvatarRetrieverFactory.java --- a/src/com/beem/project/beem/smack/avatar/AvatarRetrieverFactory.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/smack/avatar/AvatarRetrieverFactory.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.smack.avatar; import com.beem.project.beem.smack.avatar.AvatarMetadataExtension.Info; @@ -62,6 +62,7 @@ /** * Get a AvatarRetriever to retrieve this avatar. + * * @param con the connection * @param from the user which own the avatar * @param info the metadata information of the avatar to retrieve diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/smack/avatar/FileAvatarCache.java --- a/src/com/beem/project/beem/smack/avatar/FileAvatarCache.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/smack/avatar/FileAvatarCache.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.smack.avatar; import java.io.BufferedInputStream; @@ -62,6 +62,7 @@ /** * Create a FileAvatarCache. + * * @param storedir The directory used to store the data. */ public FileAvatarCache(final File storedir) { @@ -90,7 +91,7 @@ byte[] data = new byte[1024]; int nbread; while ((nbread = in.read(data)) != -1) - os.write(data, 0, nbread); + os.write(data, 0, nbread); } finally { in.close(); os.close(); diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/smack/avatar/HttpAvatarRetriever.java --- a/src/com/beem/project/beem/smack/avatar/HttpAvatarRetriever.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/smack/avatar/HttpAvatarRetriever.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.smack.avatar; import java.io.InputStream; @@ -51,13 +51,14 @@ /** * An AvatarRetriever which retrieve the avatar over HTTP. */ -public class HttpAvatarRetriever implements AvatarRetriever { +public class HttpAvatarRetriever implements AvatarRetriever { private URL mUrl; private String mUrlString; /** * Create a HttpAvatarRetriever. + * * @param url the url of the avatar to download. */ public HttpAvatarRetriever(final URL url) { @@ -66,6 +67,7 @@ /** * Create a HttpAvatarRetriever. + * * @param url the url of the avatar to download. */ public HttpAvatarRetriever(final String url) { diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/smack/avatar/HttpClientAvatarRetriever.java --- a/src/com/beem/project/beem/smack/avatar/HttpClientAvatarRetriever.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/smack/avatar/HttpClientAvatarRetriever.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.smack.avatar; import java.io.InputStream; @@ -56,13 +56,14 @@ /** * An AvatarRetriever which retrieve the avatar over HTTP using the Apache HttpClient. */ -public class HttpClientAvatarRetriever implements AvatarRetriever { +public class HttpClientAvatarRetriever implements AvatarRetriever { private String mUrl; private HttpClient mClient; /** * Create a HttpAvatarRetriever. + * * @param client the custom HttpClient to use to downlowad * @param url the url of the avatar to download. */ @@ -73,6 +74,7 @@ /** * Create a HttpAvatarRetriever. + * * @param url the url of the avatar to download. */ public HttpClientAvatarRetriever(final String url) { diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/smack/avatar/XmppAvatarRetriever.java --- a/src/com/beem/project/beem/smack/avatar/XmppAvatarRetriever.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/smack/avatar/XmppAvatarRetriever.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.smack.avatar; import java.util.List; @@ -65,6 +65,7 @@ /** * Create an XmppAvatarRetriever. + * * @param con the xmpp connection * @param from the contact from which we retrieve the avatar * @param id the id of the avatar to retrieve diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/smack/avatar/package-info.java --- a/src/com/beem/project/beem/smack/avatar/package-info.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/smack/avatar/package-info.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,10 +40,9 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ /** * This package contains implementation of XEP-0084 User Avatar. */ package com.beem.project.beem.smack.avatar; - diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/smack/caps/CapsExtension.java --- a/src/com/beem/project/beem/smack/caps/CapsExtension.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/smack/caps/CapsExtension.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.smack.caps; @@ -48,6 +48,7 @@ /** * This extension represents a capability of XEP-0115. + * */ public class CapsExtension implements PacketExtension { @@ -56,8 +57,10 @@ private String mNode; private String mExt; + /** * Create a CapsExtension. + * * @param hash The value of the hash attribute. * @param node the value of the node attribute * @param ver the value of the ver attribute. @@ -70,6 +73,7 @@ /** * Get the ver attribute value. + * * @return the value of the ver attribute. */ public String getVer() { @@ -78,6 +82,7 @@ /** * Get the hash attribute value. + * * @return the value of the hash attribute. */ public String getHash() { @@ -86,6 +91,7 @@ /** * Get the node attribute value. + * * @return the value of the node attribute. */ public String getNode() { @@ -94,6 +100,7 @@ /** * Get the ext attribute value. + * * @return the value of the ext attribute. */ public String getExt() { @@ -102,6 +109,7 @@ /** * Set the hash attribute. + * * @param hash the value of hash */ public void setHash(String hash) { @@ -110,6 +118,7 @@ /** * Set the ver attribute. + * * @param ver the value of ver */ public void setVer(String ver) { @@ -118,6 +127,7 @@ /** * Set the node attribute. + * * @param node the value of node */ public void setNode(String node) { @@ -126,6 +136,7 @@ /** * Set the ext attribute. + * * @param ext the value of ext */ public void setExt(String ext) { diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/smack/caps/CapsManager.java --- a/src/com/beem/project/beem/smack/caps/CapsManager.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/smack/caps/CapsManager.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.smack.caps; import org.jivesoftware.smack.Connection; @@ -69,7 +69,9 @@ import org.jivesoftware.smack.util.StringUtils; /** - * Capabilities manager to implements XEP-0115. The DiscoverInfo are cached in memory. + * Capabilities manager to implements XEP-0115. + * The DiscoverInfo are cached in memory. + * */ public class CapsManager { // the verCache should be stored on disk @@ -83,6 +85,7 @@ /** * Create a CapsManager. + * * @param sdm The service discovery manager to use. * @param conn The connection to manage. */ @@ -94,6 +97,7 @@ /** * Get the discover info associated with a ver attribute. + * * @param ver the ver attribute. * @return the discover info or null if it was not cached. */ @@ -103,6 +107,7 @@ /** * Get the discover info of a contact. + * * @param jid the jid of the contact. * @param ver the ver attribute of the contact capability. * @return The info of the client null if the info was not cached. @@ -118,7 +123,9 @@ } /** - * Set the node attribute to send in your capability. This is usually an uri to identify the client. + * Set the node attribute to send in your capability. + * This is usually an uri to identify the client. + * * @param node the node attribute to set. */ public void setNode(String node) { @@ -126,7 +133,9 @@ } /** - * Load a persistent DiscoverInfo. The default implementation does nothing and always return null. + * Load a persistent DiscoverInfo. + * The default implementation does nothing and always return null. + * * @param ver the ver hash of the discoverInfo. * @return The discover info or null if not present. */ @@ -135,7 +144,9 @@ } /** - * Store a DiscoverInfo for persistence. The default implementation does nothing. + * Store a DiscoverInfo for persistence. + * The default implementation does nothing. + * * @param ver the ver hash of the DiscoverInfo * @param info the DiscoverInfo to store */ @@ -143,8 +154,10 @@ } /** - * Check if the discover info correspondig to the ver hash is in cache. This implementation checks the memory cache. + * Check if the discover info correspondig to the ver hash is in cache. + * This implementation checks the memory cache. * If the info is not in cache it is necessary to request it from the network. + * * @param ver the ver hash * @return true if it is in cache false otherwise */ @@ -189,6 +202,7 @@ /** * Validate the ver attribute of a received capability. + * * @param jid the jid of the sender of the capability. * @param node the node attribute of the capability. * @param ver the ver attribute of the capability. @@ -219,6 +233,7 @@ /** * Calculate the ver attribute. + * * @param info The discover info to calculate the ver. * @param hashMethod the hash algorithm to use. * @return the value of the ver attribute @@ -236,9 +251,9 @@ s.append(c); s.append('/'); // Should add lang but it is not available - // c = identity.getType(); - // if (c != null) - // S.append(c); +// c = identity.getType(); +// if (c != null) +// S.append(c); s.append('/'); c = identity.getName(); if (c != null) @@ -256,6 +271,7 @@ /** * Get the identities sorted correctly to calculate the ver attribute. + * * @param info the DiscoverInfo containing the identities * @return the sorted list of identities. */ @@ -270,20 +286,16 @@ public int compare(DiscoverInfo.Identity o1, DiscoverInfo.Identity o2) { String cat1 = o1.getCategory(); - if (cat1 == null) - cat1 = ""; + if (cat1 == null) cat1 = ""; String cat2 = o2.getCategory(); - if (cat2 == null) - cat2 = ""; + if (cat2 == null) cat2 = ""; int res = cat1.compareTo(cat2); if (res != 0) return res; String type1 = o1.getType(); - if (type1 == null) - type1 = ""; + if (type1 == null) type1 = ""; String type2 = o2.getCategory(); - if (type2 == null) - type2 = ""; + if (type2 == null) type2 = ""; res = type1.compareTo(type2); if (res != 0) return res; @@ -296,6 +308,7 @@ /** * Get the features sorted correctly to calculate the ver attribute. + * * @param info the DiscoverInfo containing the features * @return the sorted list of features. */ @@ -312,6 +325,7 @@ /** * Get the Discover Information send by your own connection. + * * @return your own DiscoverInfo */ private DiscoverInfo getOwnInformation() { @@ -328,6 +342,7 @@ /** * Calculate a Hash (digest). + * * @param algo the algorithm to use * @param data the data to compute * @return the resulting hash @@ -343,7 +358,7 @@ */ private void initSupportedAlgorithm() { // sort by ""preference" - String[] algo = new String[] { "sha-1", "md2", "md5", "sha-224", "sha-256", "sha-384", "sha-512" }; + String[] algo = new String[] {"sha-1", "md2", "md5", "sha-224", "sha-256", "sha-384", "sha-512" }; for (String a : algo) { try { MessageDigest md = MessageDigest.getInstance(a); diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/smack/caps/CapsProvider.java --- a/src/com/beem/project/beem/smack/caps/CapsProvider.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/smack/caps/CapsProvider.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.smack.caps; import org.xmlpull.v1.XmlPullParser; @@ -48,16 +48,17 @@ import org.jivesoftware.smack.packet.PacketExtension; /** - * PacketExtensionProvider for XEP-0115. This provider parse c element of namespace http://jabber.org/protocol/caps - * which represents a capability of XEP-0115 + * PacketExtensionProvider for XEP-0115. + * This provider parse c element of namespace + * http://jabber.org/protocol/caps which represents a capability of XEP-0115 + * */ public class CapsProvider implements PacketExtensionProvider { /** * Constructor. */ - public CapsProvider() { - } + public CapsProvider() { } @Override public PacketExtension parseExtension(XmlPullParser parser) { diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/smack/caps/package-info.java --- a/src/com/beem/project/beem/smack/caps/package-info.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/smack/caps/package-info.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,10 +40,9 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ /** * This package contains implementation of XEP-0115. */ package com.beem.project.beem.smack.caps; - diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/smack/pep/PEPListener.java --- a/src/com/beem/project/beem/smack/pep/PEPListener.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/smack/pep/PEPListener.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.smack.pep; import org.jivesoftware.smackx.pubsub.Item; @@ -52,7 +52,8 @@ public interface PEPListener { /** - * Called when PEP events are received. + * Called when PEP events are received. + * * @param from the JID of the user who send the event * @param node the node of the items in the event * @param items the different items of the event diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/smack/pep/PepSubManager.java --- a/src/com/beem/project/beem/smack/pep/PepSubManager.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/smack/pep/PepSubManager.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.smack.pep; import java.util.ArrayList; @@ -60,6 +60,7 @@ /** * Little extension of {@link PubSubManager} which allows to add {@link PEPListener}. + * */ public class PepSubManager extends PubSubManager { private List mPepListeners = new ArrayList(); @@ -67,6 +68,7 @@ /** * Create a PepSubManager. + * * @param connection the connection */ public PepSubManager(final Connection connection) { @@ -75,8 +77,9 @@ } /** - * Create a PepSubManager associated to the specified connection where the pubsub requests require a specific to - * address for packets. + * Create a PepSubManager associated to the specified connection where the pubsub + * requests require a specific to address for packets. + * * @param connection the connection * @param toAddress The pubsub specific to address (required for some servers) */ @@ -87,6 +90,7 @@ /** * Add a listener to PEP event. + * * @param listener the listener */ public void addPEPListener(PEPListener listener) { @@ -96,6 +100,7 @@ /** * Remove a listener to PEP event. + * * @param listener the listener */ public void removePEPListener(PEPListener listener) { @@ -103,7 +108,9 @@ } /** - * Get a PepNode. This node is obtain without checking its existence as PEP should auto create it. + * Get a PepNode. + * This node is obtain without checking its existence as PEP should auto create it. + * * @param nodeName the node name * @return the node */ @@ -115,6 +122,7 @@ /** * Initialize the PepSubManager. + * * @param con the connection */ private void init(Connection con) { @@ -137,6 +145,7 @@ /** * Fire the PEP listeners. + * * @param from the JID of the user who send the event * @param node the node of the items in the event * @param items the different items of the event diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/smack/pep/package-info.java --- a/src/com/beem/project/beem/smack/pep/package-info.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/smack/pep/package-info.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ /** * This package contains an implementation of XEP-0163 Personnal Eventing Protocol based on the pubsub implementation. diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/ui/AddContact.java --- a/src/com/beem/project/beem/ui/AddContact.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/ui/AddContact.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.ui; import java.util.ArrayList; @@ -103,8 +103,7 @@ this.registerReceiver(mReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CLOSED)); } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see android.app.Activity#onStart() */ @Override @@ -130,8 +129,7 @@ unbindService(mServConn); } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see android.app.Activity#onDestroy() */ @Override @@ -180,8 +178,7 @@ /** * Constructor. */ - public OkListener() { - } + public OkListener() { } @Override public void onClick(View v) { diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/ui/ChangeStatus.java --- a/src/com/beem/project/beem/ui/ChangeStatus.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/ui/ChangeStatus.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.ui; @@ -115,7 +115,8 @@ private static final int CAMERA_WITH_DATA = 0; private static final int PHOTO_PICKED_WITH_DATA = 1; - private static final File PHOTO_DIR = new File(Environment.getExternalStorageDirectory() + "/DCIM/Camera"); + private static final File PHOTO_DIR = new File( + Environment.getExternalStorageDirectory() + "/DCIM/Camera"); private static final String KEY_CURRENT_PHOTO_FILE = "currentphotofile"; @@ -173,6 +174,7 @@ avatarPanel.setVisibility(View.GONE); } + mSettings = PreferenceManager.getDefaultSharedPreferences(this); mStatusMessageEditText = (EditText) findViewById(R.id.ChangeStatusMessage); mStatusMessageEditText.setText(mSettings.getString(BeemApplication.STATUS_TEXT_KEY, "")); @@ -211,8 +213,7 @@ unbindService(mServConn); } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see android.app.Activity#onDestroy() */ @Override @@ -226,21 +227,23 @@ */ @Override protected void onSaveInstanceState(Bundle outState) { - if (mCurrentPhotoFile != null) { - outState.putString(KEY_CURRENT_PHOTO_FILE, mCurrentPhotoFile.toString()); - } - super.onSaveInstanceState(outState); + if (mCurrentPhotoFile != null) { + outState.putString(KEY_CURRENT_PHOTO_FILE, mCurrentPhotoFile.toString()); + } + super.onSaveInstanceState(outState); } @Override protected void onRestoreInstanceState(Bundle savedInstanceState) { - String fileName = savedInstanceState.getString(KEY_CURRENT_PHOTO_FILE); - if (fileName != null) { - mCurrentPhotoFile = new File(fileName); - } - super.onRestoreInstanceState(savedInstanceState); + String fileName = savedInstanceState.getString(KEY_CURRENT_PHOTO_FILE); + if (fileName != null) { + mCurrentPhotoFile = new File(fileName); + } + super.onRestoreInstanceState(savedInstanceState); } + + @Override protected Dialog onCreateDialog(int id) { if (id == SELECT_PHOTO_DLG) @@ -250,12 +253,11 @@ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { - // Ignore failed requests - if (resultCode != RESULT_OK) - return; + // Ignore failed requests + if (resultCode != RESULT_OK) return; - switch (requestCode) { - case PHOTO_PICKED_WITH_DATA: + switch (requestCode) { + case PHOTO_PICKED_WITH_DATA: mAvatarUri = Uri.parse(data.getAction()); Log.d(TAG, "selected avatar uri " + mAvatarUri); if (mAvatarUri != null) { @@ -263,14 +265,15 @@ mDisableAvatar = false; mShowCurrentAvatar = false; } - break; + break; - case CAMERA_WITH_DATA: - doCropPhoto(mCurrentPhotoFile); - break; + case CAMERA_WITH_DATA: + doCropPhoto(mCurrentPhotoFile); + break; default: Log.w(TAG, "onActivityResult : invalid request code"); - } + + } } /** @@ -325,6 +328,7 @@ /** * ClickListener for the avatarButton. + * * @param button the avatar button */ private void onAvatarButton(View button) { @@ -351,8 +355,10 @@ private void displayCurrentAvatar() { try { UserInfo ui = mXmppFacade.getUserInfo(); + if (ui == null) + return; String avatarId = ui.getAvatarId(); - Log.d(TAG, "User info ; avatar id " + avatarId); + Log.d(TAG, "User info : avatar id " + avatarId); if (avatarId != null) { Uri uri = AvatarProvider.CONTENT_URI.buildUpon().appendPath(avatarId).build(); mAvatar.setImageURI(uri); @@ -364,7 +370,8 @@ } /* - * Some codes from AOSP (platform/packages/apps/Contacts) to select and crop an image. + * Some codes from AOSP (platform/packages/apps/Contacts) + * to select and crop an image. */ /** @@ -372,34 +379,36 @@ * @return the dialog */ private Dialog createPickPhotoDialog() { - // Wrap our context to inflate list items using correct theme - final Context dialogContext = new ContextThemeWrapper(this, android.R.style.Theme_Light); + // Wrap our context to inflate list items using correct theme + final Context dialogContext = new ContextThemeWrapper(this, + android.R.style.Theme_Light); - final ListAdapter adapter = ArrayAdapter.createFromResource(dialogContext, R.array.pick_photo_items, - android.R.layout.simple_list_item_1); + final ListAdapter adapter = ArrayAdapter.createFromResource(dialogContext, + R.array.pick_photo_items, + android.R.layout.simple_list_item_1); - final AlertDialog.Builder builder = new AlertDialog.Builder(dialogContext); - builder.setTitle(R.string.select_avatar); - builder.setSingleChoiceItems(adapter, -1, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - dialog.dismiss(); - switch (which) { - case 0: - doTakePhoto(); - break; - case 1: - doPickPhotoFromGallery(); - break; - case 2: + final AlertDialog.Builder builder = new AlertDialog.Builder(dialogContext); + builder.setTitle(R.string.select_avatar); + builder.setSingleChoiceItems(adapter, -1, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + switch(which) { + case 0: + doTakePhoto(); + break; + case 1: + doPickPhotoFromGallery(); + break; + case 2: mDisableAvatar = true; mAvatar.setImageURI(null); break; default: Log.w(TAG, "DialogInterface onClick : invalid which code"); - } - } - }); - return builder.create(); + } + } + }); + return builder.create(); } /** @@ -407,24 +416,24 @@ * @return the filename */ private String getPhotoFileName() { - Date date = new Date(System.currentTimeMillis()); - SimpleDateFormat dateFormat = new SimpleDateFormat("'IMG'_yyyyMMdd_HHmmss"); - return dateFormat.format(date) + ".jpg"; + Date date = new Date(System.currentTimeMillis()); + SimpleDateFormat dateFormat = new SimpleDateFormat("'IMG'_yyyyMMdd_HHmmss"); + return dateFormat.format(date) + ".jpg"; } /** * Launches Camera to take a picture and store it in a file. */ protected void doTakePhoto() { - try { - // Launch camera to take photo for selected contact - PHOTO_DIR.mkdirs(); - mCurrentPhotoFile = new File(PHOTO_DIR, getPhotoFileName()); - final Intent intent = getTakePickIntent(mCurrentPhotoFile); - startActivityForResult(intent, CAMERA_WITH_DATA); - } catch (ActivityNotFoundException e) { - Toast.makeText(this, R.string.photoPickerNotFoundText, Toast.LENGTH_LONG).show(); - } + try { + // Launch camera to take photo for selected contact + PHOTO_DIR.mkdirs(); + mCurrentPhotoFile = new File(PHOTO_DIR, getPhotoFileName()); + final Intent intent = getTakePickIntent(mCurrentPhotoFile); + startActivityForResult(intent, CAMERA_WITH_DATA); + } catch (ActivityNotFoundException e) { + Toast.makeText(this, R.string.photoPickerNotFoundText, Toast.LENGTH_LONG).show(); + } } /** @@ -433,9 +442,9 @@ * @return the intent */ public static Intent getTakePickIntent(File f) { - Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE, null); - intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f)); - return intent; + Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE, null); + intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f)); + return intent; } /** @@ -443,22 +452,25 @@ * @param f the image file to crop */ protected void doCropPhoto(final File f) { - try { + try { - // Add the image to the media store + // Add the image to the media store // level 8 /* - * MediaScannerConnection.scanFile( this, new String[] { f.getAbsolutePath() }, new String[] { null }, - * null); - */ + MediaScannerConnection.scanFile( + this, + new String[] { f.getAbsolutePath() }, + new String[] { null }, + null); + */ - // Launch gallery to crop the photo - final Intent intent = getCropImageIntent(Uri.fromFile(f)); - startActivityForResult(intent, PHOTO_PICKED_WITH_DATA); - } catch (ActivityNotFoundException e) { - Log.e(TAG, "Cannot crop image", e); - Toast.makeText(this, R.string.photoPickerNotFoundText, Toast.LENGTH_LONG).show(); - } + // Launch gallery to crop the photo + final Intent intent = getCropImageIntent(Uri.fromFile(f)); + startActivityForResult(intent, PHOTO_PICKED_WITH_DATA); + } catch (ActivityNotFoundException e) { + Log.e(TAG, "Cannot crop image", e); + Toast.makeText(this, R.string.photoPickerNotFoundText, Toast.LENGTH_LONG).show(); + } } /** @@ -467,28 +479,28 @@ * @return the intent */ public static Intent getCropImageIntent(Uri photoUri) { - Intent intent = new Intent("com.android.camera.action.CROP"); - intent.setDataAndType(photoUri, "image/*"); - intent.putExtra("crop", "true"); - intent.putExtra("aspectX", 1); - intent.putExtra("aspectY", 1); - intent.putExtra("outputX", ICON_SIZE); - intent.putExtra("outputY", ICON_SIZE); + Intent intent = new Intent("com.android.camera.action.CROP"); + intent.setDataAndType(photoUri, "image/*"); + intent.putExtra("crop", "true"); + intent.putExtra("aspectX", 1); + intent.putExtra("aspectY", 1); + intent.putExtra("outputX", ICON_SIZE); + intent.putExtra("outputY", ICON_SIZE); intent.putExtra(MediaStore.EXTRA_OUTPUT, MY_AVATAR_URI); - return intent; + return intent; } /** * Launches Gallery to pick a photo. */ protected void doPickPhotoFromGallery() { - try { - // Launch picker to choose photo for selected contact - final Intent intent = getPhotoPickIntent(); - startActivityForResult(intent, PHOTO_PICKED_WITH_DATA); - } catch (ActivityNotFoundException e) { - Toast.makeText(this, R.string.photoPickerNotFoundText, Toast.LENGTH_LONG).show(); - } + try { + // Launch picker to choose photo for selected contact + final Intent intent = getPhotoPickIntent(); + startActivityForResult(intent, PHOTO_PICKED_WITH_DATA); + } catch (ActivityNotFoundException e) { + Toast.makeText(this, R.string.photoPickerNotFoundText, Toast.LENGTH_LONG).show(); + } } /** @@ -496,19 +508,21 @@ * @return the intent */ public static Intent getPhotoPickIntent() { - Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null); - intent.setType("image/*"); - intent.putExtra("crop", "true"); - intent.putExtra("aspectX", 1); - intent.putExtra("aspectY", 1); - intent.putExtra("outputX", ICON_SIZE); - intent.putExtra("outputY", ICON_SIZE); + Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null); + intent.setType("image/*"); + intent.putExtra("crop", "true"); + intent.putExtra("aspectX", 1); + intent.putExtra("aspectY", 1); + intent.putExtra("outputX", ICON_SIZE); + intent.putExtra("outputY", ICON_SIZE); intent.putExtra(MediaStore.EXTRA_OUTPUT, MY_AVATAR_URI); // use this to get the bitmap in the intent - // intent.putExtra("return-data", true); - return intent; +// intent.putExtra("return-data", true); + return intent; } + + /** * connection to service. * @author nikita diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/ui/Chat.java --- a/src/com/beem/project/beem/ui/Chat.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/ui/Chat.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.ui; import java.io.IOException; diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/ui/ContactList.java --- a/src/com/beem/project/beem/ui/ContactList.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/ui/ContactList.java Sat Nov 05 23:49:30 2011 +0100 @@ -39,7 +39,7 @@ Flavien Astraud, November 26, 2009 - */ +*/ package com.beem.project.beem.ui; import java.util.ArrayList; @@ -121,16 +121,16 @@ private final BeemContactList mAdapterContactList = new BeemContactList(); private final List mListGroup = new ArrayList(); - /** - * Map containing a list of the different contacts of a given group. Each list is a @{link SortedList} so there is - * no need to sort it again. - */ + /** Map containing a list of the different contacts of a given group. + * Each list is a @{link SortedList} so there is no need to sort it again. + * */ private final Map> mContactOnGroup = new HashMap>(); private final BeemContactListOnClick mOnContactClick = new BeemContactListOnClick(); private final Handler mHandler = new Handler(); private final ServiceConnection mServConn = new BeemServiceConnection(); private final BeemBroadcastReceiver mReceiver = new BeemBroadcastReceiver(); - private final ComparatorContactListByStatusAndName mComparator = new ComparatorContactListByStatusAndName(); + private final ComparatorContactListByStatusAndName mComparator = + new ComparatorContactListByStatusAndName(); private final BeemRosterListener mBeemRosterListener = new BeemRosterListener(); private List mListContact; private String mSelectedGroup; @@ -253,8 +253,8 @@ result = true; break; case R.id.contact_list_context_menu_userinfo_subscription: - Dialog subscription = new ResendSubscription(ContactList.this, mXmppFacade, mSelectedContact) - .create(); + Dialog subscription = new ResendSubscription(ContactList.this, + mXmppFacade, mSelectedContact).create(); subscription.show(); result = true; break; @@ -377,10 +377,12 @@ } /** - * {@inheritDoc} Simple stategy to handle the onEntriesAdded event. if contact has to be shown : + * {@inheritDoc} + * Simple stategy to handle the onEntriesAdded event. + * if contact has to be shown : *
    - *
  • add him to his groups
  • - *
  • add him to the specials groups + *
  • add him to his groups
  • + *
  • add him to the specials groups *
*/ @Override @@ -412,9 +414,10 @@ } /** - * {@inheritDoc} Simple stategy to handle the onEntriesDeleted event. + * {@inheritDoc} + * Simple stategy to handle the onEntriesDeleted event. *
    - *
  • Remove the contact from all groups
  • + *
  • Remove the contact from all groups
  • *
*/ @Override @@ -445,11 +448,12 @@ } /** - * {@inheritDoc} Simple stategy to handle the onEntriesUpdated event. + * {@inheritDoc} + * Simple stategy to handle the onEntriesUpdated event. *
    - *
  • Remove the contact from all groups
  • - *
  • if contact has to be shown add it to his groups
  • - *
  • if contact has to be shown add it to the specials groups
  • + *
  • Remove the contact from all groups
  • + *
  • if contact has to be shown add it to his groups
  • + *
  • if contact has to be shown add it to the specials groups
  • *
*/ @Override @@ -470,7 +474,8 @@ for (String group : groups) { if (!mListGroup.contains(group)) { mListGroup.add(mListGroup.size() - 1, group); - List tmplist = new SortedList(new LinkedList(), mComparator); + List tmplist = new SortedList( + new LinkedList(), mComparator); mContactOnGroup.put(group, tmplist); } mContactOnGroup.get(group).remove(contact); @@ -488,11 +493,12 @@ } /** - * {@inheritDoc} Simple stategy to handle the onPresenceChanged event. + * {@inheritDoc} + * Simple stategy to handle the onPresenceChanged event. *
    - *
  • Remove the contact from all groups
  • - *
  • if contact has to be shown add it to his groups
  • - *
  • if contact has to be shown add it to the specials groups
  • + *
  • Remove the contact from all groups
  • + *
  • if contact has to be shown add it to his groups
  • + *
  • if contact has to be shown add it to the specials groups
  • *
*/ @Override @@ -521,8 +527,10 @@ } /** - * Add a contact to the special list No Group and All contacts. The contact will be added if the list is not the - * current list otherwise the list must be modified in a Handler. + * Add a contact to the special list No Group and All contacts. + * The contact will be added if the list is not the current list otherwise + * the list must be modified in a Handler. + * * @param contact the contact to add. */ private void addToSpecialList(Contact contact) { @@ -539,6 +547,7 @@ /** * Update the current list with the status of contact. + * * @param listName name of the current list * @param contact contact to update */ @@ -547,11 +556,12 @@ final List groups = contact.getGroups(); String noGroup = getString(R.string.contact_list_no_group); String allGroup = getString(R.string.contact_list_all_contact); - final boolean add = ((!hideDisconnected || Status.statusOnline(contact.getStatus())) && // must show and - ((listName.equals(noGroup) && groups.isEmpty()) || // in no group - groups.contains(listName) || // or in current - listName.equals(allGroup) // or in all - )); + final boolean add = ((!hideDisconnected || Status.statusOnline(contact.getStatus())) && // must show and + ( + (listName.equals(noGroup) && groups.isEmpty()) || // in no group + groups.contains(listName) || // or in current + listName.equals(allGroup) // or in all + )); mHandler.post(new Runnable() { public void run() { mListContact.remove(contact); @@ -614,6 +624,7 @@ return mListContact.get(position).hashCode(); } + /** * {@inheritDoc} */ @@ -661,8 +672,8 @@ } /** - * Get a LayerDrawable containing the avatar and the status icon. The status icon will change with the level of - * the drawable. + * Get a LayerDrawable containing the avatar and the status icon. + * The status icon will change with the level of the drawable. * @param avatarId the avatar id to retrieve or null to get default * @return a LayerDrawable */ @@ -699,8 +710,7 @@ /** * Create a ContactFilter. */ - public ContactFilter() { - } + public ContactFilter() { } @Override protected Filter.FilterResults performFiltering(CharSequence constraint) { @@ -720,7 +730,7 @@ } @Override - protected void publishResults(CharSequence constraint, Filter.FilterResults results) { + protected void publishResults(CharSequence constraint, Filter.FilterResults results) { Log.d(TAG, "publishResults"); List contacts = (List) results.values; mListContact = contacts; @@ -829,7 +839,9 @@ } /** - * Assign the differents contact to their groups. This methods will fill the mContactOnGroup map. + * Assign the differents contact to their groups. + * This methods will fill the mContactOnGroup map. + * * @param contacts list of contacts * @param groupNames list of existing groups */ @@ -862,6 +874,7 @@ /** * Make the List of the map became Insertion sorted list. + * * @param map the map to convert. */ private void makeSortedList(Map> map) { @@ -872,6 +885,9 @@ } } + + + /** * Comparator Contact by status and name. */ diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/ui/CreateAccount.java --- a/src/com/beem/project/beem/ui/CreateAccount.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/ui/CreateAccount.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.ui; import java.util.regex.Pattern; @@ -122,8 +122,8 @@ xmppConnection.connect(); AccountManager accountManager = new AccountManager(xmppConnection); accountManager.createAccount(username, password); - Toast toast = Toast.makeText(getApplicationContext(), - String.format(getString(R.string.create_account_successfull_after), username), NOTIFICATION_DURATION); + Toast toast = Toast.makeText(getApplicationContext(), String.format( + getString(R.string.create_account_successfull_after), username), NOTIFICATION_DURATION); toast.show(); } catch (XMPPException e) { createErrorDialog(e.getMessage()); @@ -139,7 +139,9 @@ */ private void createErrorDialog(String errMsg) { AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setTitle(R.string.create_account_err_dialog_title).setMessage(errMsg).setCancelable(false) + builder.setTitle(R.string.create_account_err_dialog_title) + .setMessage(errMsg) + .setCancelable(false) .setIcon(android.R.drawable.ic_dialog_alert); builder.setNeutralButton(R.string.create_account_close_dialog_button, new DialogInterface.OnClickListener() { diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/ui/GroupList.java --- a/src/com/beem/project/beem/ui/GroupList.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/ui/GroupList.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.ui; import java.util.ArrayList; @@ -80,7 +80,7 @@ private static final Intent SERVICE_INTENT = new Intent(); private final ServiceConnection mServConn = new BeemServiceConnection(); - private final BeemBroadcastReceiver mReceiver = new BeemBroadcastReceiver(); + private final BeemBroadcastReceiver mReceiver = new BeemBroadcastReceiver(); private IXmppFacade mXmppFacade; private IRoster mRoster; private String mJID; @@ -99,8 +99,7 @@ public GroupList() { } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see android.app.Activity#onCreate(android.os.Bundle) */ @Override @@ -138,8 +137,7 @@ unbindService(mServConn); } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see android.app.Activity#onDestroy() */ @Override diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/ui/Login.java --- a/src/com/beem/project/beem/ui/Login.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/ui/Login.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.ui; import android.app.Activity; diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/ui/LoginAnim.java --- a/src/com/beem/project/beem/ui/LoginAnim.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/ui/LoginAnim.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,12 +40,16 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.ui; import android.app.Activity; +import android.app.PendingIntent; +import android.content.BroadcastReceiver; +import android.content.Context; import android.content.ComponentName; import android.content.Intent; +import android.content.IntentFilter; import android.content.ServiceConnection; import android.os.AsyncTask; import android.os.Bundle; @@ -64,6 +68,8 @@ import com.beem.project.beem.service.LoginAsyncTask; import com.beem.project.beem.service.aidl.IXmppFacade; +import de.duenndns.ssl.MemorizingTrustManager; + /** * This class is an activity which display an animation during the connection with the server. * @author Da Risk @@ -72,6 +78,7 @@ private static final String TAG = "LoginAnim"; private static final Intent SERVICE_INTENT = new Intent(); + private static final int RECEIVER_PRIORITY = 50; static { SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService")); } @@ -83,6 +90,7 @@ private Button mCancelBt; private TextView mLoginState; private boolean mBinded; + private BroadcastReceiver mSslReceiver; /** * Constructor. @@ -90,8 +98,7 @@ public LoginAnim() { } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see android.app.Activity#onCreate(android.os.Bundle) */ @Override @@ -103,10 +110,21 @@ mRotateAnim = AnimationUtils.loadAnimation(this, R.anim.rotate_and_scale); mCancelBt = (Button) findViewById(R.id.loginanim_cancel_button); mCancelBt.setOnClickListener(new ClickListener()); + mSslReceiver = new BroadcastReceiver() { + public void onReceive(Context ctx, Intent i) { + try { + Log.i(TAG, "Interception the SSL notification"); + PendingIntent pi = i.getParcelableExtra(MemorizingTrustManager.INTERCEPT_DECISION_INTENT_LAUNCH); + pi.send(); + abortBroadcast(); + } catch (PendingIntent.CanceledException e) { + Log.e(TAG, "Error while displaying the SSL dialog", e); + } + } + }; } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see android.app.Activity#onStart() */ @Override @@ -117,10 +135,14 @@ mTask = new LoginTask(); if (!mBinded) mBinded = bindService(LoginAnim.SERVICE_INTENT, mServConn, BIND_AUTO_CREATE); + IntentFilter filter = new IntentFilter(MemorizingTrustManager.INTERCEPT_DECISION_INTENT + + "/" + getPackageName()); + filter.setPriority(RECEIVER_PRIORITY); + registerReceiver(mSslReceiver, filter); + } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see android.app.Activity#onPause() */ @Override @@ -129,11 +151,12 @@ if (mBinded && mTask.getStatus() != AsyncTask.Status.RUNNING) { unbindService(mServConn); mXmppFacade = null; + mBinded = false; } + unregisterReceiver(mSslReceiver); } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see android.app.Activity#onKeyDown(int, android.view.KeyEvent) */ @Override @@ -182,8 +205,7 @@ LoginTask() { } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see android.os.AsyncTask#onPostExecute(java.lang.Object) */ @Override @@ -206,12 +228,11 @@ } @Override - protected void onProgressUpdate(Integer... values) { + protected void onProgressUpdate(Integer ... values) { mLoginState.setText(getResources().getStringArray(R.array.loganim_state)[values[0]]); } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see android.os.AsyncTask#onCancelled() */ @Override diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/ui/PrivacyList.java --- a/src/com/beem/project/beem/ui/PrivacyList.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/ui/PrivacyList.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.ui; import java.util.ArrayList; diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/ui/Settings.java --- a/src/com/beem/project/beem/ui/Settings.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/ui/Settings.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.ui; import android.content.ComponentName; diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/ui/Subscription.java --- a/src/com/beem/project/beem/ui/Subscription.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/ui/Subscription.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.ui; import org.jivesoftware.smack.packet.Presence; @@ -91,8 +91,7 @@ public Subscription() { } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see android.app.Activity#onCreate(android.os.Bundle) */ @Override @@ -109,8 +108,7 @@ this.registerReceiver(mReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CLOSED)); } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see android.app.Activity#onResume() */ @Override @@ -119,8 +117,7 @@ bindService(new Intent(this, BeemService.class), mServConn, BIND_AUTO_CREATE); } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see android.app.Activity#onPause() */ @Override @@ -129,8 +126,7 @@ unbindService(mServConn); } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see android.app.Activity#onDestroy() */ @Override @@ -141,6 +137,7 @@ /** * Send the presence stanza. + * * @param p presence stanza */ private void sendPresence(Presence p) { @@ -169,7 +166,8 @@ switch (v.getId()) { case R.id.SubscriptionAccept: presence = new Presence(Type.subscribed); - Toast.makeText(Subscription.this, getString(R.string.SubscriptAccept), Toast.LENGTH_SHORT).show(); + Toast.makeText(Subscription.this, getString(R.string.SubscriptAccept), Toast.LENGTH_SHORT) + .show(); break; case R.id.SubscriptionRefuse: presence = new Presence(Type.unsubscribed); diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/ui/dialogs/builders/Alias.java --- a/src/com/beem/project/beem/ui/dialogs/builders/Alias.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/ui/dialogs/builders/Alias.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.ui.dialogs.builders; import android.app.AlertDialog; @@ -80,10 +80,12 @@ mContact = contact; LayoutInflater factory = LayoutInflater.from(context); - final View textEntryView = factory.inflate(R.layout.contactdialogaliasdialog, null); + final View textEntryView = factory.inflate( + R.layout.contactdialogaliasdialog, null); setTitle(mContact.getJID()); setView(textEntryView); - mEditTextAlias = (EditText) textEntryView.findViewById(R.id.CDAliasDialogName); + mEditTextAlias = (EditText) textEntryView.findViewById( + R.id.CDAliasDialogName); mEditTextAlias.setText(mContact.getName()); setPositiveButton(R.string.OkButton, new DialogClickListener()); setNegativeButton(R.string.CancelButton, new DialogClickListener()); @@ -100,6 +102,7 @@ public DialogClickListener() { } + @Override public void onClick(final DialogInterface dialog, final int which) { if (which == DialogInterface.BUTTON_POSITIVE) { diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/ui/dialogs/builders/ChatList.java --- a/src/com/beem/project/beem/ui/dialogs/builders/ChatList.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/ui/dialogs/builders/ChatList.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.ui.dialogs.builders; import java.util.List; diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/ui/dialogs/builders/CreatePrivacyList.java --- a/src/com/beem/project/beem/ui/dialogs/builders/CreatePrivacyList.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/ui/dialogs/builders/CreatePrivacyList.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.ui.dialogs.builders; import java.util.ArrayList; diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/ui/dialogs/builders/DeleteContact.java --- a/src/com/beem/project/beem/ui/dialogs/builders/DeleteContact.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/ui/dialogs/builders/DeleteContact.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.ui.dialogs.builders; import android.app.AlertDialog; diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/ui/dialogs/builders/DeletePrivacyList.java --- a/src/com/beem/project/beem/ui/dialogs/builders/DeletePrivacyList.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/ui/dialogs/builders/DeletePrivacyList.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.ui.dialogs.builders; import android.app.AlertDialog; diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/ui/dialogs/builders/ResendSubscription.java --- a/src/com/beem/project/beem/ui/dialogs/builders/ResendSubscription.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/ui/dialogs/builders/ResendSubscription.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.ui.dialogs.builders; import org.jivesoftware.smack.packet.Presence; diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/ui/dialogs/builders/package-info.java --- a/src/com/beem/project/beem/ui/dialogs/builders/package-info.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/ui/dialogs/builders/package-info.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ /** * This package contains Beem dialog builder's. */ diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/ui/package-info.java --- a/src/com/beem/project/beem/ui/package-info.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/ui/package-info.java Sat Nov 05 23:49:30 2011 +0100 @@ -39,7 +39,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ /** * This package contains the different activity displayed by BEEM and other class useful to make the UI. */ diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/ui/wizard/Account.java --- a/src/com/beem/project/beem/ui/wizard/Account.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/ui/wizard/Account.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.ui.wizard; import android.app.Activity; @@ -56,6 +56,7 @@ /** * The first activity of an user friendly wizard to configure a XMPP account. + * * @author Da Risk */ public class Account extends Activity implements OnClickListener, RadioGroup.OnCheckedChangeListener { @@ -97,7 +98,7 @@ } @Override - public void onCheckedChanged(RadioGroup group, int checkedId) { + public void onCheckedChanged(RadioGroup group, int checkedId) { if (checkedId == -1) mNextButton.setEnabled(false); else diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/ui/wizard/AccountConfigure.java --- a/src/com/beem/project/beem/ui/wizard/AccountConfigure.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/ui/wizard/AccountConfigure.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.ui.wizard; import android.app.Activity; @@ -67,6 +67,7 @@ /** * Activity to enter the information required in order to configure a XMPP account. + * * @author Da Risk */ public class AccountConfigure extends Activity implements OnClickListener { @@ -98,6 +99,7 @@ mAccountJID = (EditText) findViewById(R.id.account_username); mAccountPassword = (EditText) findViewById(R.id.account_password); + InputFilter[] orgFilters = mAccountJID.getFilters(); InputFilter[] newFilters = new InputFilter[orgFilters.length + 1]; int i; @@ -193,11 +195,11 @@ } @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { + public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { + public void onTextChanged(CharSequence s, int start, int before, int count) { } } @@ -219,11 +221,11 @@ } @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { + public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { + public void onTextChanged(CharSequence s, int start, int before, int count) { } } } diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/ui/wizard/package-info.java --- a/src/com/beem/project/beem/ui/wizard/package-info.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/ui/wizard/package-info.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ /** * This package contains some configuration wizards. diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/utils/BeemBroadcastReceiver.java --- a/src/com/beem/project/beem/utils/BeemBroadcastReceiver.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/utils/BeemBroadcastReceiver.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.utils; import android.app.Activity; @@ -84,9 +84,8 @@ } } else if (intentAction.equals(ConnectivityManager.CONNECTIVITY_ACTION)) { if (intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false)) { - Toast - .makeText(context, context.getString(R.string.BeemBroadcastReceiverDisconnect), Toast.LENGTH_SHORT) - .show(); + Toast.makeText(context, context.getString(R.string.BeemBroadcastReceiverDisconnect), + Toast.LENGTH_SHORT).show(); context.stopService(new Intent(context, BeemService.class)); } } diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/utils/BeemConnectivity.java --- a/src/com/beem/project/beem/utils/BeemConnectivity.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/utils/BeemConnectivity.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.utils; import android.content.Context; @@ -59,8 +59,7 @@ /** * Private constructor to forbid instantiation. */ - private BeemConnectivity() { - } + private BeemConnectivity() { } /** * Checks if is connected. @@ -68,7 +67,8 @@ * @return true, if is connected */ public static boolean isConnected(final Context ctx) { - ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE); + ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService( + Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getActiveNetworkInfo(); return ni != null && ni.isConnected(); } @@ -79,11 +79,14 @@ * @return true, if is wifi */ public static boolean isWifi(final Context ctx) { - WifiManager wm = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE); + WifiManager wm = (WifiManager) ctx.getSystemService( + Context.WIFI_SERVICE); WifiInfo wi = wm.getConnectionInfo(); if (wi != null - && (WifiInfo.getDetailedStateOf(wi.getSupplicantState()) == DetailedState.OBTAINING_IPADDR || WifiInfo - .getDetailedStateOf(wi.getSupplicantState()) == DetailedState.CONNECTED)) { + && (WifiInfo.getDetailedStateOf(wi.getSupplicantState()) + == DetailedState.OBTAINING_IPADDR + || WifiInfo.getDetailedStateOf(wi.getSupplicantState()) + == DetailedState.CONNECTED)) { return false; } return false; @@ -95,7 +98,8 @@ * @return true, if is umts */ public static boolean isUmts(final Context ctx) { - TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); + TelephonyManager tm = (TelephonyManager) ctx.getSystemService( + Context.TELEPHONY_SERVICE); return tm.getNetworkType() >= TelephonyManager.NETWORK_TYPE_UMTS; } @@ -105,7 +109,8 @@ * @return true, if is edge */ public static boolean isEdge(final Context ctx) { - TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); + TelephonyManager tm = (TelephonyManager) ctx.getSystemService( + Context.TELEPHONY_SERVICE); return tm.getNetworkType() == TelephonyManager.NETWORK_TYPE_EDGE; } diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/utils/FreePort.java --- a/src/com/beem/project/beem/utils/FreePort.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/utils/FreePort.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.utils; import java.io.IOException; diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/utils/PresenceType.java --- a/src/com/beem/project/beem/utils/PresenceType.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/utils/PresenceType.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.utils; import org.jivesoftware.smack.packet.Presence; diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/utils/SortedList.java --- a/src/com/beem/project/beem/utils/SortedList.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/utils/SortedList.java Sat Nov 05 23:49:30 2011 +0100 @@ -26,7 +26,7 @@ Please send bug reports with examples or suggestions to contact@beem-project.com or http://dev.beem-project.com/ - */ +*/ package com.beem.project.beem.utils; import java.util.List; @@ -37,8 +37,10 @@ import java.util.Collections; /** - * This class add a sort by insertion to a List. All methods which allow you to insert an object at a specific index + * This class add a sort by insertion to a List. + * All methods which allow you to insert an object at a specific index * will throw an UnsupportedOperationException. + * * @author Da Risk * @param the type of elements maintained by this list */ @@ -49,6 +51,7 @@ /** * Create a SortedList. The existing elements will be sorted. + * * @param list list to sort * @param mComparator mComparator to use. */ @@ -126,7 +129,9 @@ } /** - * Add all the elements in the specified collection. The index param is ignored. + * Add all the elements in the specified collection. + * The index param is ignored. + * * @param index ignored * @param c collection containing elements to be added to this list * @return true if this list changed as a result of the call @@ -137,7 +142,9 @@ } /** - * Add all the elements in the specified collection. The index param is ignored. + * Add all the elements in the specified collection. + * The index param is ignored. + * * @param l collection containing elements to be added to this list * @return true if this list changed as a result of the call * @see addAll(Collection) @@ -241,7 +248,8 @@ } /** - * A SortedList.iterator don't allow list modification. It use the mBackend iterator for the other operations. + * A SortedList.iterator don't allow list modification. + * It use the mBackend iterator for the other operations. */ private class SortedListIterator implements ListIterator { @@ -249,6 +257,7 @@ /** * Construct SortedList.Iterator. + * * @param iterator the iterator of the backend list */ SortedListIterator(final ListIterator iterator) { diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/utils/Status.java --- a/src/com/beem/project/beem/utils/Status.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/utils/Status.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.utils; import org.jivesoftware.smack.packet.Presence; diff -r 319ce14e4826 -r 6b30719f4de6 src/com/beem/project/beem/utils/package-info.java --- a/src/com/beem/project/beem/utils/package-info.java Sat Nov 05 22:27:58 2011 +0100 +++ b/src/com/beem/project/beem/utils/package-info.java Sat Nov 05 23:49:30 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ /** * This package contains utility class to deal with various aspect of BEEM. */ diff -r 319ce14e4826 -r 6b30719f4de6 src/de/duenndns/ssl/MTMDecision.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/de/duenndns/ssl/MTMDecision.java Sat Nov 05 23:49:30 2011 +0100 @@ -0,0 +1,33 @@ +/* MemorizingTrustManager - a TrustManager which asks the user about invalid + * certificates and memorizes their decision. + * + * Copyright (c) 2010 Georg Lukas + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package de.duenndns.ssl; + +class MTMDecision { + public final static int DECISION_INVALID = 0; + public final static int DECISION_ABORT = 1; + public final static int DECISION_ONCE = 2; + public final static int DECISION_ALWAYS = 3; + + int state = DECISION_INVALID; +} diff -r 319ce14e4826 -r 6b30719f4de6 src/de/duenndns/ssl/MemorizingActivity.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/de/duenndns/ssl/MemorizingActivity.java Sat Nov 05 23:49:30 2011 +0100 @@ -0,0 +1,97 @@ +/* MemorizingTrustManager - a TrustManager which asks the user about invalid + * certificates and memorizes their decision. + * + * Copyright (c) 2010 Georg Lukas + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package de.duenndns.ssl; + + +import android.app.Activity; +import android.app.AlertDialog; +import android.content.DialogInterface; +import android.content.DialogInterface.*; +import android.content.Intent; +import android.os.Bundle; +import android.util.Log; + +import com.beem.project.beem.R; + +public class MemorizingActivity extends Activity + implements OnClickListener,OnCancelListener { + final static String TAG = "MemorizingActivity"; + + int decisionId; + String app; + + @Override + public void onCreate(Bundle savedInstanceState) { + Log.d(TAG, "onCreate"); + super.onCreate(savedInstanceState); + } + + @Override + public void onResume() { + super.onResume(); + Intent i = getIntent(); + app = i.getStringExtra(MemorizingTrustManager.DECISION_INTENT_APP); + decisionId = i.getIntExtra(MemorizingTrustManager.DECISION_INTENT_ID, MTMDecision.DECISION_INVALID); + String cert = i.getStringExtra(MemorizingTrustManager.DECISION_INTENT_CERT); + Log.d(TAG, "onResume with " + i.getExtras() + " decId=" + decisionId); + Log.d(TAG, "data: " + i.getData()); + new AlertDialog.Builder(this).setTitle(R.string.mtm_accept_cert) + .setMessage(cert) + .setPositiveButton(R.string.mtm_decision_always, this) + .setNeutralButton(R.string.mtm_decision_once, this) + .setNegativeButton(R.string.mtm_decision_abort, this) + .setOnCancelListener(this) + .create().show(); + } + + void sendDecision(int decision) { + Log.d(TAG, "Sending decision to " + app + ": " + decision); + Intent i = new Intent(MemorizingTrustManager.DECISION_INTENT + "/" + app); + i.putExtra(MemorizingTrustManager.DECISION_INTENT_ID, decisionId); + i.putExtra(MemorizingTrustManager.DECISION_INTENT_CHOICE, decision); + sendBroadcast(i); + finish(); + } + + // react on AlertDialog button press + public void onClick(DialogInterface dialog, int btnId) { + int decision; + dialog.dismiss(); + switch (btnId) { + case DialogInterface.BUTTON_POSITIVE: + decision = MTMDecision.DECISION_ALWAYS; + break; + case DialogInterface.BUTTON_NEUTRAL: + decision = MTMDecision.DECISION_ONCE; + break; + default: + decision = MTMDecision.DECISION_ABORT; + } + sendDecision(decision); + } + + public void onCancel(DialogInterface dialog) { + sendDecision(MTMDecision.DECISION_ABORT); + } +} diff -r 319ce14e4826 -r 6b30719f4de6 src/de/duenndns/ssl/MemorizingTrustManager.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/de/duenndns/ssl/MemorizingTrustManager.java Sat Nov 05 23:49:30 2011 +0100 @@ -0,0 +1,390 @@ +/* MemorizingTrustManager - a TrustManager which asks the user about invalid + * certificates and memorizes their decision. + * + * Copyright (c) 2010 Georg Lukas + * + * MemorizingTrustManager.java contains the actual trust manager and interface + * code to create a MemorizingActivity and obtain the results. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package de.duenndns.ssl; + +import android.app.Activity; +import android.app.Application; +import android.app.Notification; +import android.app.NotificationManager; +import android.app.Service; +import android.app.AlertDialog; +import android.app.PendingIntent; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.DialogInterface; +import android.content.DialogInterface.OnClickListener; +import android.content.Intent; +import android.content.IntentFilter; +import android.net.Uri; +import android.util.Log; +import android.os.Handler; + +import java.io.File; +import java.security.cert.*; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.HashMap; +import javax.net.ssl.TrustManager; +import javax.net.ssl.TrustManagerFactory; +import javax.net.ssl.X509TrustManager; + +import com.beem.project.beem.R; + +/** + * A X509 trust manager implementation which asks the user about invalid + * certificates and memorizes their decision. + *

+ * The certificate validity is checked using the system default X509 + * TrustManager, creating a query Dialog if the check fails. + *

+ * WARNING: This only works if a dedicated thread is used for + * opening sockets! + */ +public class MemorizingTrustManager implements X509TrustManager { + final static String TAG = "MemorizingTrustManager"; + public final static String INTERCEPT_DECISION_INTENT = "de.duenndns.ssl.INTERCEPT_DECISION"; + public final static String INTERCEPT_DECISION_INTENT_LAUNCH = INTERCEPT_DECISION_INTENT + ".launch_intent"; + final static String DECISION_INTENT = "de.duenndns.ssl.DECISION"; + final static String DECISION_INTENT_APP = DECISION_INTENT + ".app"; + final static String DECISION_INTENT_ID = DECISION_INTENT + ".decisionId"; + final static String DECISION_INTENT_CERT = DECISION_INTENT + ".cert"; + final static String DECISION_INTENT_CHOICE = DECISION_INTENT + ".decisionChoice"; + private final static int NOTIFICATION_ID = 100509; + + static String KEYSTORE_DIR = "KeyStore"; + static String KEYSTORE_FILE = "KeyStore.bks"; + + Context master; + NotificationManager notificationManager; + private static int decisionId = 0; + private static HashMap openDecisions = new HashMap(); + + Handler masterHandler; + private File keyStoreFile; + private KeyStore appKeyStore; + private X509TrustManager defaultTrustManager; + private X509TrustManager appTrustManager; + + /** Creates an instance of the MemorizingTrustManager class. + * + * @param m Activity or Service to show the Dialog / Notification + */ + private MemorizingTrustManager(Context m) { + master = m; + masterHandler = new Handler(); + notificationManager = (NotificationManager)master.getSystemService(Context.NOTIFICATION_SERVICE); + + Application app; + if (m instanceof Service) { + app = ((Service)m).getApplication(); + } else if (m instanceof Activity) { + app = ((Activity)m).getApplication(); + } else throw new ClassCastException("MemorizingTrustManager context must be either Activity or Service!"); + + File dir = app.getDir(KEYSTORE_DIR, Context.MODE_PRIVATE); + keyStoreFile = new File(dir + File.separator + KEYSTORE_FILE); + + appKeyStore = loadAppKeyStore(); + defaultTrustManager = getTrustManager(null); + appTrustManager = getTrustManager(appKeyStore); + } + + /** + * Returns a X509TrustManager list containing a new instance of + * TrustManagerFactory. + * + * This function is meant for convenience only. You can use it + * as follows to integrate TrustManagerFactory for HTTPS sockets: + * + *

+	 *     SSLContext sc = SSLContext.getInstance("TLS");
+	 *     sc.init(null, MemorizingTrustManager.getInstanceList(this),
+	 *         new java.security.SecureRandom());
+	 *     HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
+	 * 
+ * @param c Activity or Service to show the Dialog / Notification + */ + public static X509TrustManager[] getInstanceList(Context c) { + return new X509TrustManager[] { new MemorizingTrustManager(c) }; + } + + /** + * Changes the path for the KeyStore file. + * + * The actual filename relative to the app's directory will be + * app_dirname/filename. + * + * @param dirname directory to store the KeyStore. + * @param filename file name for the KeyStore. + */ + public static void setKeyStoreFile(String dirname, String filename) { + KEYSTORE_DIR = dirname; + KEYSTORE_FILE = filename; + } + + X509TrustManager getTrustManager(KeyStore ks) { + try { + TrustManagerFactory tmf = TrustManagerFactory.getInstance("X509"); + tmf.init(ks); + for (TrustManager t : tmf.getTrustManagers()) { + if (t instanceof X509TrustManager) { + return (X509TrustManager)t; + } + } + } catch (Exception e) { + // Here, we are covering up errors. It might be more useful + // however to throw them out of the constructor so the + // embedding app knows something went wrong. + Log.e(TAG, "getTrustManager(" + ks + ")", e); + } + return null; + } + + KeyStore loadAppKeyStore() { + KeyStore ks; + try { + ks = KeyStore.getInstance(KeyStore.getDefaultType()); + } catch (KeyStoreException e) { + Log.e(TAG, "getAppKeyStore()", e); + return null; + } + try { + ks.load(null, null); + ks.load(new java.io.FileInputStream(keyStoreFile), "MTM".toCharArray()); + } catch (java.io.FileNotFoundException e) { + Log.i(TAG, "getAppKeyStore(" + keyStoreFile + ") - file does not exist"); + } catch (Exception e) { + Log.e(TAG, "getAppKeyStore(" + keyStoreFile + ")", e); + } + return ks; + } + + void storeCert(X509Certificate[] chain) { + // add all certs from chain to appKeyStore + try { + for (X509Certificate c : chain) + appKeyStore.setCertificateEntry(c.getSubjectDN().toString(), c); + } catch (KeyStoreException e) { + Log.e(TAG, "storeCert(" + chain + ")", e); + return; + } + + // reload appTrustManager + appTrustManager = getTrustManager(appKeyStore); + + // store KeyStore to file + try { + java.io.FileOutputStream fos = new java.io.FileOutputStream(keyStoreFile); + appKeyStore.store(fos, "MTM".toCharArray()); + fos.close(); + } catch (Exception e) { + Log.e(TAG, "storeCert(" + keyStoreFile + ")", e); + } + } + + private boolean isExpiredException(Throwable e) { + do { + if (e instanceof CertificateExpiredException) + return true; + e = e.getCause(); + } while (e != null); + return false; + } + + public void checkCertTrusted(X509Certificate[] chain, String authType, boolean isServer) + throws CertificateException + { + Log.d(TAG, "checkCertTrusted(" + chain + ", " + authType + ", " + isServer + ")"); + try { + Log.d(TAG, "checkCertTrusted: trying appTrustManager"); + if (isServer) + appTrustManager.checkServerTrusted(chain, authType); + else + appTrustManager.checkClientTrusted(chain, authType); + } catch (CertificateException ae) { + // if the cert is stored in our appTrustManager, we ignore expiredness + ae.printStackTrace(); + if (isExpiredException(ae)) { + Log.i(TAG, "checkCertTrusted: accepting expired certificate from keystore"); + return; + } + try { + Log.d(TAG, "checkCertTrusted: trying defaultTrustManager"); + if (isServer) + defaultTrustManager.checkServerTrusted(chain, authType); + else + defaultTrustManager.checkClientTrusted(chain, authType); + } catch (CertificateException e) { + e.printStackTrace(); + interact(chain, authType, e); + } + } + } + + public void checkClientTrusted(X509Certificate[] chain, String authType) + throws CertificateException + { + checkCertTrusted(chain, authType, false); + } + + public void checkServerTrusted(X509Certificate[] chain, String authType) + throws CertificateException + { + checkCertTrusted(chain, authType, true); + } + + public X509Certificate[] getAcceptedIssuers() + { + Log.d(TAG, "getAcceptedIssuers()"); + return defaultTrustManager.getAcceptedIssuers(); + } + + private int createDecisionId(MTMDecision d) { + int myId; + synchronized(openDecisions) { + myId = decisionId; + openDecisions.put(myId, d); + decisionId += 1; + } + return myId; + } + + private String certChainMessage(final X509Certificate[] chain, CertificateException cause) { + Throwable e = cause; + Log.d(TAG, "certChainMessage for " + e); + StringBuffer si = new StringBuffer(); + if (e.getCause() != null) { + e = e.getCause(); + si.append(e.getLocalizedMessage()); + si.append("\n"); + } + for (X509Certificate c : chain) { + si.append("\n"); + si.append(c.getSubjectDN().toString()); + si.append(" ("); + si.append(c.getIssuerDN().toString()); + si.append(")"); + } + return si.toString(); + } + + void startActivityNotification(PendingIntent intent, String certName) { + Notification n = new Notification(android.R.drawable.ic_lock_lock, + master.getString(R.string.mtm_notification), + System.currentTimeMillis()); + n.setLatestEventInfo(master.getApplicationContext(), + master.getString(R.string.mtm_notification), + certName, intent); + n.flags |= Notification.FLAG_AUTO_CANCEL; + + notificationManager.notify(NOTIFICATION_ID, n); + } + + void launchServiceMode(Intent activityIntent, final String certMessage) { + BroadcastReceiver launchNotifReceiver= new BroadcastReceiver() { + public void onReceive(Context ctx, Intent i) { + Log.i(TAG, "Interception not done by the application. Send notification"); + PendingIntent pi = i.getParcelableExtra(INTERCEPT_DECISION_INTENT_LAUNCH); + startActivityNotification(pi, certMessage); + } + }; + master.registerReceiver(launchNotifReceiver, new IntentFilter(INTERCEPT_DECISION_INTENT + "/" + master.getPackageName())); + PendingIntent call = PendingIntent.getActivity(master, 0, activityIntent, 0); + Intent ni = new Intent(INTERCEPT_DECISION_INTENT + "/" + master.getPackageName()); + ni.putExtra(INTERCEPT_DECISION_INTENT_LAUNCH, call); + master.sendOrderedBroadcast(ni, null); + + } + + void interact(final X509Certificate[] chain, String authType, CertificateException cause) + throws CertificateException + { + /* prepare the MTMDecision blocker object */ + MTMDecision choice = new MTMDecision(); + final int myId = createDecisionId(choice); + final String certTitle = chain[0].getSubjectDN().toString(); + final String certMessage = certChainMessage(chain, cause); + + BroadcastReceiver decisionReceiver = new BroadcastReceiver() { + public void onReceive(Context ctx, Intent i) { interactResult(i); } + }; + master.registerReceiver(decisionReceiver, new IntentFilter(DECISION_INTENT + "/" + master.getPackageName())); + masterHandler.post(new Runnable() { + public void run() { + Intent ni = new Intent(master, MemorizingActivity.class); + ni.setData(Uri.parse(MemorizingTrustManager.class.getName() + "/" + myId)); + ni.putExtra(DECISION_INTENT_APP, master.getPackageName()); + ni.putExtra(DECISION_INTENT_ID, myId); + ni.putExtra(DECISION_INTENT_CERT, certMessage); + + try { + master.startActivity(ni); + } catch (Exception e) { + Log.e(TAG, "startActivity: " + e); + launchServiceMode(ni, certMessage); + } + } + }); + + Log.d(TAG, "openDecisions: " + openDecisions); + Log.d(TAG, "waiting on " + myId); + try { + synchronized(choice) { choice.wait(); } + } catch (InterruptedException e) { + e.printStackTrace(); + } + master.unregisterReceiver(decisionReceiver); + Log.d(TAG, "finished wait on " + myId + ": " + choice.state); + switch (choice.state) { + case MTMDecision.DECISION_ALWAYS: + storeCert(chain); + case MTMDecision.DECISION_ONCE: + break; + default: + throw (cause); + } + } + + public static void interactResult(Intent i) { + int decisionId = i.getIntExtra(DECISION_INTENT_ID, MTMDecision.DECISION_INVALID); + int choice = i.getIntExtra(DECISION_INTENT_CHOICE, MTMDecision.DECISION_INVALID); + Log.d(TAG, "interactResult: " + decisionId + " chose " + choice); + Log.d(TAG, "openDecisions: " + openDecisions); + + MTMDecision d; + synchronized(openDecisions) { + d = openDecisions.get(decisionId); + openDecisions.remove(decisionId); + } + synchronized(d) { + d.state = choice; + d.notify(); + } + } + +} diff -r 319ce14e4826 -r 6b30719f4de6 src/de/duenndns/ssl/package-info.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/de/duenndns/ssl/package-info.java Sat Nov 05 23:49:30 2011 +0100 @@ -0,0 +1,7 @@ +/** + * This package contains the MemorizingTrustManager library made by Georg. + * It is a "plugin" for Android Java to allow asking the user about SSL certificates + * https://github.com/ge0rg/MemorizingTrustManager + */ +package de.duenndns.ssl; + diff -r 319ce14e4826 -r 6b30719f4de6 tools/JavaHeaderCheck.regex diff -r 319ce14e4826 -r 6b30719f4de6 tools/LicenseHeader.txt diff -r 319ce14e4826 -r 6b30719f4de6 tools/README diff -r 319ce14e4826 -r 6b30719f4de6 tools/checkstyle.xml diff -r 319ce14e4826 -r 6b30719f4de6 tools/eclipse_formatter.xml