Move the app into an app submodule which respect the default gradle layout
authorDa Risk <da_risk@beem-project.com>
Sun, 15 Mar 2015 18:03:03 +0100
changeset 1040 197a85a35cba
parent 1039 7d6f2526244a
child 1041 e5a970600066
Move the app into an app submodule which respect the default gradle layout
AndroidManifest.xml
app/build.gradle
app/libs/README.txt
app/libs/android-support-v13.jar
app/libs/asmack-android-16-beem.jar
app/libs/lcrypto-jdk16-146-20110415.jar
app/proguard-rules.pro
app/src/main/AndroidManifest.xml
app/src/main/aidl/com/beem/project/beem/service/Contact.aidl
app/src/main/aidl/com/beem/project/beem/service/Message.aidl
app/src/main/aidl/com/beem/project/beem/service/PresenceAdapter.aidl
app/src/main/aidl/com/beem/project/beem/service/PrivacyListItem.aidl
app/src/main/aidl/com/beem/project/beem/service/UserInfo.aidl
app/src/main/aidl/com/beem/project/beem/service/aidl/IBeemConnectionListener.aidl
app/src/main/aidl/com/beem/project/beem/service/aidl/IBeemRosterListener.aidl
app/src/main/aidl/com/beem/project/beem/service/aidl/IChat.aidl
app/src/main/aidl/com/beem/project/beem/service/aidl/IChatManager.aidl
app/src/main/aidl/com/beem/project/beem/service/aidl/IChatManagerListener.aidl
app/src/main/aidl/com/beem/project/beem/service/aidl/IContact.aidl
app/src/main/aidl/com/beem/project/beem/service/aidl/IMessageListener.aidl
app/src/main/aidl/com/beem/project/beem/service/aidl/IPrivacyListListener.aidl
app/src/main/aidl/com/beem/project/beem/service/aidl/IPrivacyListManager.aidl
app/src/main/aidl/com/beem/project/beem/service/aidl/IRoster.aidl
app/src/main/aidl/com/beem/project/beem/service/aidl/IXmppConnection.aidl
app/src/main/aidl/com/beem/project/beem/service/aidl/IXmppFacade.aidl
app/src/main/java/com/android/mms/util/SmileyParser.java
app/src/main/java/com/beem/project/beem/BeemApplication.java
app/src/main/java/com/beem/project/beem/BeemService.java
app/src/main/java/com/beem/project/beem/otr/BeemOtrManager.java
app/src/main/java/com/beem/project/beem/package-info.java
app/src/main/java/com/beem/project/beem/providers/AvatarProvider.java
app/src/main/java/com/beem/project/beem/providers/package-info.java
app/src/main/java/com/beem/project/beem/service/BeemAvatarCache.java
app/src/main/java/com/beem/project/beem/service/BeemAvatarManager.java
app/src/main/java/com/beem/project/beem/service/BeemChatManager.java
app/src/main/java/com/beem/project/beem/service/ChatAdapter.java
app/src/main/java/com/beem/project/beem/service/Contact.java
app/src/main/java/com/beem/project/beem/service/LoginAsyncTask.java
app/src/main/java/com/beem/project/beem/service/Message.java
app/src/main/java/com/beem/project/beem/service/PresenceAdapter.java
app/src/main/java/com/beem/project/beem/service/PrivacyListItem.java
app/src/main/java/com/beem/project/beem/service/PrivacyListManagerAdapter.java
app/src/main/java/com/beem/project/beem/service/RosterAdapter.java
app/src/main/java/com/beem/project/beem/service/UserInfo.java
app/src/main/java/com/beem/project/beem/service/XmppConnectionAdapter.java
app/src/main/java/com/beem/project/beem/service/XmppFacade.java
app/src/main/java/com/beem/project/beem/service/auth/AccountAuthenticator.java
app/src/main/java/com/beem/project/beem/service/auth/PreferenceAuthenticator.java
app/src/main/java/com/beem/project/beem/service/auth/package-info.java
app/src/main/java/com/beem/project/beem/service/package-info.java
app/src/main/java/com/beem/project/beem/smack/avatar/AvatarCache.java
app/src/main/java/com/beem/project/beem/smack/avatar/AvatarExtension.java
app/src/main/java/com/beem/project/beem/smack/avatar/AvatarListener.java
app/src/main/java/com/beem/project/beem/smack/avatar/AvatarManager.java
app/src/main/java/com/beem/project/beem/smack/avatar/AvatarMetadataExtension.java
app/src/main/java/com/beem/project/beem/smack/avatar/AvatarMetadataProvider.java
app/src/main/java/com/beem/project/beem/smack/avatar/AvatarProvider.java
app/src/main/java/com/beem/project/beem/smack/avatar/AvatarRetriever.java
app/src/main/java/com/beem/project/beem/smack/avatar/AvatarRetrieverFactory.java
app/src/main/java/com/beem/project/beem/smack/avatar/FileAvatarCache.java
app/src/main/java/com/beem/project/beem/smack/avatar/HttpAvatarRetriever.java
app/src/main/java/com/beem/project/beem/smack/avatar/HttpClientAvatarRetriever.java
app/src/main/java/com/beem/project/beem/smack/avatar/MemoryAvatarCache.java
app/src/main/java/com/beem/project/beem/smack/avatar/XmppAvatarRetriever.java
app/src/main/java/com/beem/project/beem/smack/avatar/package-info.java
app/src/main/java/com/beem/project/beem/smack/pep/PEPListener.java
app/src/main/java/com/beem/project/beem/smack/pep/PepSubManager.java
app/src/main/java/com/beem/project/beem/smack/pep/package-info.java
app/src/main/java/com/beem/project/beem/smack/ping/PingExtension.java
app/src/main/java/com/beem/project/beem/smack/ping/package-info.java
app/src/main/java/com/beem/project/beem/smack/sasl/SASLGoogleOAuth2Mechanism.java
app/src/main/java/com/beem/project/beem/smack/sasl/ScramSaslClient.java
app/src/main/java/com/beem/project/beem/smack/sasl/ScramSaslMechanism.java
app/src/main/java/com/beem/project/beem/smack/sasl/package-info.java
app/src/main/java/com/beem/project/beem/ui/AddContact.java
app/src/main/java/com/beem/project/beem/ui/ChangeStatus.java
app/src/main/java/com/beem/project/beem/ui/Chat.java
app/src/main/java/com/beem/project/beem/ui/ContactList.java
app/src/main/java/com/beem/project/beem/ui/ContactListAdapter.java
app/src/main/java/com/beem/project/beem/ui/ContactListFragment.java
app/src/main/java/com/beem/project/beem/ui/GroupList.java
app/src/main/java/com/beem/project/beem/ui/Login.java
app/src/main/java/com/beem/project/beem/ui/LoginAnim.java
app/src/main/java/com/beem/project/beem/ui/PrivacyList.java
app/src/main/java/com/beem/project/beem/ui/Settings.java
app/src/main/java/com/beem/project/beem/ui/Subscription.java
app/src/main/java/com/beem/project/beem/ui/dialogs/builders/Alias.java
app/src/main/java/com/beem/project/beem/ui/dialogs/builders/ChatList.java
app/src/main/java/com/beem/project/beem/ui/dialogs/builders/CreatePrivacyList.java
app/src/main/java/com/beem/project/beem/ui/dialogs/builders/DeleteContact.java
app/src/main/java/com/beem/project/beem/ui/dialogs/builders/DeletePrivacyList.java
app/src/main/java/com/beem/project/beem/ui/dialogs/builders/DisplayOtrFingerprint.java
app/src/main/java/com/beem/project/beem/ui/dialogs/builders/ResendSubscription.java
app/src/main/java/com/beem/project/beem/ui/dialogs/builders/package-info.java
app/src/main/java/com/beem/project/beem/ui/package-info.java
app/src/main/java/com/beem/project/beem/ui/views/package-info.java
app/src/main/java/com/beem/project/beem/ui/wizard/Account.java
app/src/main/java/com/beem/project/beem/ui/wizard/AccountConfigureFragment.java
app/src/main/java/com/beem/project/beem/ui/wizard/CreateAccountFragment.java
app/src/main/java/com/beem/project/beem/ui/wizard/package-info.java
app/src/main/java/com/beem/project/beem/utils/BeemBroadcastReceiver.java
app/src/main/java/com/beem/project/beem/utils/BeemConnectivity.java
app/src/main/java/com/beem/project/beem/utils/FreePort.java
app/src/main/java/com/beem/project/beem/utils/PresenceType.java
app/src/main/java/com/beem/project/beem/utils/SortedList.java
app/src/main/java/com/beem/project/beem/utils/Status.java
app/src/main/java/com/beem/project/beem/utils/package-info.java
app/src/main/java/com/google/android/apps/iosched/util/LogUtils.java
app/src/main/java/com/isode/stroke/base/ByteArray.java
app/src/main/java/com/isode/stroke/sasl/ClientAuthenticator.java
app/src/main/java/com/isode/stroke/sasl/SCRAMSHA1ClientAuthenticator.java
app/src/main/java/com/isode/stroke/stringcodecs/Base64.java
app/src/main/java/com/isode/stroke/stringcodecs/Base64BSD.java
app/src/main/java/com/isode/stroke/stringcodecs/HMACSHA1.java
app/src/main/java/com/isode/stroke/stringcodecs/PBKDF2.java
app/src/main/java/com/isode/stroke/stringcodecs/SHA1.java
app/src/main/java/de/duenndns/ssl/MTMDecision.java
app/src/main/java/de/duenndns/ssl/MemorizingActivity.java
app/src/main/java/de/duenndns/ssl/MemorizingTrustManager.java
app/src/main/java/de/duenndns/ssl/package-info.java
app/src/main/java/net/java/otr4j/OtrEngine.java
app/src/main/java/net/java/otr4j/OtrEngineHost.java
app/src/main/java/net/java/otr4j/OtrEngineImpl.java
app/src/main/java/net/java/otr4j/OtrEngineListener.java
app/src/main/java/net/java/otr4j/OtrException.java
app/src/main/java/net/java/otr4j/OtrKeyManager.java
app/src/main/java/net/java/otr4j/OtrKeyManagerImpl.java
app/src/main/java/net/java/otr4j/OtrKeyManagerListener.java
app/src/main/java/net/java/otr4j/OtrKeyManagerStore.java
app/src/main/java/net/java/otr4j/OtrPolicy.java
app/src/main/java/net/java/otr4j/OtrPolicyImpl.java
app/src/main/java/net/java/otr4j/crypto/OtrCryptoEngine.java
app/src/main/java/net/java/otr4j/crypto/OtrCryptoEngineImpl.java
app/src/main/java/net/java/otr4j/crypto/OtrCryptoException.java
app/src/main/java/net/java/otr4j/io/OtrInputStream.java
app/src/main/java/net/java/otr4j/io/OtrOutputStream.java
app/src/main/java/net/java/otr4j/io/SerializationConstants.java
app/src/main/java/net/java/otr4j/io/SerializationUtils.java
app/src/main/java/net/java/otr4j/io/messages/AbstractEncodedMessage.java
app/src/main/java/net/java/otr4j/io/messages/AbstractMessage.java
app/src/main/java/net/java/otr4j/io/messages/DHCommitMessage.java
app/src/main/java/net/java/otr4j/io/messages/DHKeyMessage.java
app/src/main/java/net/java/otr4j/io/messages/DataMessage.java
app/src/main/java/net/java/otr4j/io/messages/ErrorMessage.java
app/src/main/java/net/java/otr4j/io/messages/MysteriousT.java
app/src/main/java/net/java/otr4j/io/messages/PlainTextMessage.java
app/src/main/java/net/java/otr4j/io/messages/QueryMessage.java
app/src/main/java/net/java/otr4j/io/messages/RevealSignatureMessage.java
app/src/main/java/net/java/otr4j/io/messages/SignatureM.java
app/src/main/java/net/java/otr4j/io/messages/SignatureMessage.java
app/src/main/java/net/java/otr4j/io/messages/SignatureX.java
app/src/main/java/net/java/otr4j/session/AuthContext.java
app/src/main/java/net/java/otr4j/session/AuthContextImpl.java
app/src/main/java/net/java/otr4j/session/Session.java
app/src/main/java/net/java/otr4j/session/SessionID.java
app/src/main/java/net/java/otr4j/session/SessionImpl.java
app/src/main/java/net/java/otr4j/session/SessionKeys.java
app/src/main/java/net/java/otr4j/session/SessionKeysImpl.java
app/src/main/java/net/java/otr4j/session/SessionStatus.java
app/src/main/res/anim/rotate_and_scale.xml
app/src/main/res/drawable-hdpi/beem_icon_launcher_color.png
app/src/main/res/drawable-hdpi/emo_im_angel.png
app/src/main/res/drawable-hdpi/emo_im_cool.png
app/src/main/res/drawable-hdpi/emo_im_crying.png
app/src/main/res/drawable-hdpi/emo_im_embarrassed.png
app/src/main/res/drawable-hdpi/emo_im_foot_in_mouth.png
app/src/main/res/drawable-hdpi/emo_im_happy.png
app/src/main/res/drawable-hdpi/emo_im_heart.png
app/src/main/res/drawable-hdpi/emo_im_kissing.png
app/src/main/res/drawable-hdpi/emo_im_laughing.png
app/src/main/res/drawable-hdpi/emo_im_lips_are_sealed.png
app/src/main/res/drawable-hdpi/emo_im_mad.png
app/src/main/res/drawable-hdpi/emo_im_money_mouth.png
app/src/main/res/drawable-hdpi/emo_im_pokerface.png
app/src/main/res/drawable-hdpi/emo_im_sad.png
app/src/main/res/drawable-hdpi/emo_im_smirk.png
app/src/main/res/drawable-hdpi/emo_im_surprised.png
app/src/main/res/drawable-hdpi/emo_im_tongue_sticking_out.png
app/src/main/res/drawable-hdpi/emo_im_undecided.png
app/src/main/res/drawable-hdpi/emo_im_winking.png
app/src/main/res/drawable-hdpi/emo_im_wtf.png
app/src/main/res/drawable-hdpi/emo_im_yelling.png
app/src/main/res/drawable-ldpi/beem_icon_launcher_color.png
app/src/main/res/drawable-mdpi/beem_icon_launcher_color.png
app/src/main/res/drawable-mdpi/emo_im_angel.png
app/src/main/res/drawable-mdpi/emo_im_cool.png
app/src/main/res/drawable-mdpi/emo_im_crying.png
app/src/main/res/drawable-mdpi/emo_im_embarrassed.png
app/src/main/res/drawable-mdpi/emo_im_foot_in_mouth.png
app/src/main/res/drawable-mdpi/emo_im_happy.png
app/src/main/res/drawable-mdpi/emo_im_heart.png
app/src/main/res/drawable-mdpi/emo_im_kissing.png
app/src/main/res/drawable-mdpi/emo_im_laughing.png
app/src/main/res/drawable-mdpi/emo_im_lips_are_sealed.png
app/src/main/res/drawable-mdpi/emo_im_mad.png
app/src/main/res/drawable-mdpi/emo_im_money_mouth.png
app/src/main/res/drawable-mdpi/emo_im_pokerface.png
app/src/main/res/drawable-mdpi/emo_im_sad.png
app/src/main/res/drawable-mdpi/emo_im_smirk.png
app/src/main/res/drawable-mdpi/emo_im_surprised.png
app/src/main/res/drawable-mdpi/emo_im_tongue_sticking_out.png
app/src/main/res/drawable-mdpi/emo_im_undecided.png
app/src/main/res/drawable-mdpi/emo_im_winking.png
app/src/main/res/drawable-mdpi/emo_im_wtf.png
app/src/main/res/drawable-mdpi/emo_im_yelling.png
app/src/main/res/drawable/avatar_status.xml
app/src/main/res/drawable/beem_launcher_icon_silver.png
app/src/main/res/drawable/beem_status_icon.png
app/src/main/res/drawable/beem_status_icon_available.png
app/src/main/res/drawable/beem_status_icon_away.png
app/src/main/res/drawable/beem_status_icon_busy.png
app/src/main/res/drawable/beem_status_icon_gray.png
app/src/main/res/drawable/bottombar.png
app/src/main/res/drawable/button_indicator_next.png
app/src/main/res/drawable/button_indicator_prev.png
app/src/main/res/drawable/ic_menu_add.png
app/src/main/res/drawable/ic_menu_blocked_user.png
app/src/main/res/drawable/ic_menu_chat_dashboard.png
app/src/main/res/drawable/ic_menu_close_clear_cancel.png
app/src/main/res/drawable/ic_menu_end_conversation.png
app/src/main/res/drawable/ic_menu_friendslist.png
app/src/main/res/drawable/ic_menu_invite.png
app/src/main/res/drawable/ic_menu_login.png
app/src/main/res/drawable/ic_menu_manage.png
app/src/main/res/drawable/icon.png
app/src/main/res/drawable/logo.png
app/src/main/res/drawable/logo_encryption.png
app/src/main/res/drawable/not_in_the_roster.png
app/src/main/res/drawable/scrollbar_vertical_thumb.xml
app/src/main/res/drawable/scrollbar_vertical_track.xml
app/src/main/res/drawable/shape_border_green.xml
app/src/main/res/drawable/status_available.png
app/src/main/res/drawable/status_away.png
app/src/main/res/drawable/status_blocked.png
app/src/main/res/drawable/status_dnd.png
app/src/main/res/drawable/status_error.png
app/src/main/res/drawable/status_icon.xml
app/src/main/res/drawable/status_idle.png
app/src/main/res/drawable/status_invisible.png
app/src/main/res/drawable/status_new_message.png
app/src/main/res/drawable/status_offline.png
app/src/main/res/drawable/status_requested.png
app/src/main/res/drawable/status_typing.png
app/src/main/res/layout-v11/create_account.xml
app/src/main/res/layout-v11/simple_combobox_item.xml
app/src/main/res/layout/addcontact.xml
app/src/main/res/layout/changestatus.xml
app/src/main/res/layout/chat.xml
app/src/main/res/layout/chat_compact.xml
app/src/main/res/layout/chat_msg_row.xml
app/src/main/res/layout/contactdialogaliasdialog.xml
app/src/main/res/layout/contactlist.xml
app/src/main/res/layout/contactlistcontact.xml
app/src/main/res/layout/create_account.xml
app/src/main/res/layout/group_list.xml
app/src/main/res/layout/jingle_call_activity.xml
app/src/main/res/layout/login.xml
app/src/main/res/layout/login_anim.xml
app/src/main/res/layout/privacy_list.xml
app/src/main/res/layout/privacy_list_create_dialog.xml
app/src/main/res/layout/simple_combobox_item.xml
app/src/main/res/layout/subscription.xml
app/src/main/res/layout/wizard_account_configure.xml
app/src/main/res/layout/wizard_account_main_fragment.xml
app/src/main/res/menu/chat.xml
app/src/main/res/menu/contact_list.xml
app/src/main/res/menu/contactlist_context.xml
app/src/main/res/menu/edit_settings.xml
app/src/main/res/menu/login.xml
app/src/main/res/menu/privacy_list.xml
app/src/main/res/menu/privacy_list_context.xml
app/src/main/res/values-cs/strings.xml
app/src/main/res/values-de/smileys.xml
app/src/main/res/values-de/strings.xml
app/src/main/res/values-es/smileys.xml
app/src/main/res/values-es/strings.xml
app/src/main/res/values-eu/strings.xml
app/src/main/res/values-fr/smileys.xml
app/src/main/res/values-fr/strings.xml
app/src/main/res/values-it/smileys.xml
app/src/main/res/values-it/strings.xml
app/src/main/res/values-nb/smileys.xml
app/src/main/res/values-nb/strings.xml
app/src/main/res/values-pt/smileys.xml
app/src/main/res/values-pt/strings.xml
app/src/main/res/values-ru/smileys.xml
app/src/main/res/values-ru/strings.xml
app/src/main/res/values-sv/smileys.xml
app/src/main/res/values-sv/strings.xml
app/src/main/res/values-zh-rCN/smileys.xml
app/src/main/res/values-zh-rCN/strings.xml
app/src/main/res/values-zh-rTW/smileys.xml
app/src/main/res/values-zh-rTW/strings.xml
app/src/main/res/values/arrays.xml
app/src/main/res/values/colors.xml
app/src/main/res/values/smileys.xml
app/src/main/res/values/strings.xml
app/src/main/res/values/styles.xml
app/src/main/res/values/xmpp_server_list.xml
app/src/main/res/xml/preferences.xml
build.gradle
libs/README.txt
libs/android-support-v13.jar
libs/asmack-android-16-beem.jar
libs/lcrypto-jdk16-146-20110415.jar
res/anim/rotate_and_scale.xml
res/drawable-hdpi/beem_icon_launcher_color.png
res/drawable-hdpi/emo_im_angel.png
res/drawable-hdpi/emo_im_cool.png
res/drawable-hdpi/emo_im_crying.png
res/drawable-hdpi/emo_im_embarrassed.png
res/drawable-hdpi/emo_im_foot_in_mouth.png
res/drawable-hdpi/emo_im_happy.png
res/drawable-hdpi/emo_im_heart.png
res/drawable-hdpi/emo_im_kissing.png
res/drawable-hdpi/emo_im_laughing.png
res/drawable-hdpi/emo_im_lips_are_sealed.png
res/drawable-hdpi/emo_im_mad.png
res/drawable-hdpi/emo_im_money_mouth.png
res/drawable-hdpi/emo_im_pokerface.png
res/drawable-hdpi/emo_im_sad.png
res/drawable-hdpi/emo_im_smirk.png
res/drawable-hdpi/emo_im_surprised.png
res/drawable-hdpi/emo_im_tongue_sticking_out.png
res/drawable-hdpi/emo_im_undecided.png
res/drawable-hdpi/emo_im_winking.png
res/drawable-hdpi/emo_im_wtf.png
res/drawable-hdpi/emo_im_yelling.png
res/drawable-ldpi/beem_icon_launcher_color.png
res/drawable-mdpi/beem_icon_launcher_color.png
res/drawable-mdpi/emo_im_angel.png
res/drawable-mdpi/emo_im_cool.png
res/drawable-mdpi/emo_im_crying.png
res/drawable-mdpi/emo_im_embarrassed.png
res/drawable-mdpi/emo_im_foot_in_mouth.png
res/drawable-mdpi/emo_im_happy.png
res/drawable-mdpi/emo_im_heart.png
res/drawable-mdpi/emo_im_kissing.png
res/drawable-mdpi/emo_im_laughing.png
res/drawable-mdpi/emo_im_lips_are_sealed.png
res/drawable-mdpi/emo_im_mad.png
res/drawable-mdpi/emo_im_money_mouth.png
res/drawable-mdpi/emo_im_pokerface.png
res/drawable-mdpi/emo_im_sad.png
res/drawable-mdpi/emo_im_smirk.png
res/drawable-mdpi/emo_im_surprised.png
res/drawable-mdpi/emo_im_tongue_sticking_out.png
res/drawable-mdpi/emo_im_undecided.png
res/drawable-mdpi/emo_im_winking.png
res/drawable-mdpi/emo_im_wtf.png
res/drawable-mdpi/emo_im_yelling.png
res/drawable/avatar_status.xml
res/drawable/beem_launcher_icon_silver.png
res/drawable/beem_status_icon.png
res/drawable/beem_status_icon_available.png
res/drawable/beem_status_icon_away.png
res/drawable/beem_status_icon_busy.png
res/drawable/beem_status_icon_gray.png
res/drawable/bottombar.png
res/drawable/button_indicator_next.png
res/drawable/button_indicator_prev.png
res/drawable/ic_menu_add.png
res/drawable/ic_menu_blocked_user.png
res/drawable/ic_menu_chat_dashboard.png
res/drawable/ic_menu_close_clear_cancel.png
res/drawable/ic_menu_end_conversation.png
res/drawable/ic_menu_friendslist.png
res/drawable/ic_menu_invite.png
res/drawable/ic_menu_login.png
res/drawable/ic_menu_manage.png
res/drawable/icon.png
res/drawable/logo.png
res/drawable/logo_encryption.png
res/drawable/not_in_the_roster.png
res/drawable/scrollbar_vertical_thumb.xml
res/drawable/scrollbar_vertical_track.xml
res/drawable/shape_border_green.xml
res/drawable/status_available.png
res/drawable/status_away.png
res/drawable/status_blocked.png
res/drawable/status_dnd.png
res/drawable/status_error.png
res/drawable/status_icon.xml
res/drawable/status_idle.png
res/drawable/status_invisible.png
res/drawable/status_new_message.png
res/drawable/status_offline.png
res/drawable/status_requested.png
res/drawable/status_typing.png
res/layout-v11/create_account.xml
res/layout-v11/simple_combobox_item.xml
res/layout/addcontact.xml
res/layout/changestatus.xml
res/layout/chat.xml
res/layout/chat_compact.xml
res/layout/chat_msg_row.xml
res/layout/contactdialogaliasdialog.xml
res/layout/contactlist.xml
res/layout/contactlistcontact.xml
res/layout/create_account.xml
res/layout/group_list.xml
res/layout/jingle_call_activity.xml
res/layout/login.xml
res/layout/login_anim.xml
res/layout/privacy_list.xml
res/layout/privacy_list_create_dialog.xml
res/layout/simple_combobox_item.xml
res/layout/subscription.xml
res/layout/wizard_account_configure.xml
res/layout/wizard_account_main_fragment.xml
res/menu/chat.xml
res/menu/contact_list.xml
res/menu/contactlist_context.xml
res/menu/edit_settings.xml
res/menu/login.xml
res/menu/privacy_list.xml
res/menu/privacy_list_context.xml
res/values-cs/strings.xml
res/values-de/smileys.xml
res/values-de/strings.xml
res/values-es/smileys.xml
res/values-es/strings.xml
res/values-eu/strings.xml
res/values-fr/smileys.xml
res/values-fr/strings.xml
res/values-it/smileys.xml
res/values-it/strings.xml
res/values-nb/smileys.xml
res/values-nb/strings.xml
res/values-pt/smileys.xml
res/values-pt/strings.xml
res/values-ru/smileys.xml
res/values-ru/strings.xml
res/values-sv/smileys.xml
res/values-sv/strings.xml
res/values-zh-rCN/smileys.xml
res/values-zh-rCN/strings.xml
res/values-zh-rTW/smileys.xml
res/values-zh-rTW/strings.xml
res/values/arrays.xml
res/values/colors.xml
res/values/smileys.xml
res/values/strings.xml
res/values/styles.xml
res/values/xmpp_server_list.xml
res/xml/preferences.xml
settings.gradle
src/com/android/mms/util/SmileyParser.java
src/com/beem/project/beem/BeemApplication.java
src/com/beem/project/beem/BeemService.java
src/com/beem/project/beem/otr/BeemOtrManager.java
src/com/beem/project/beem/package-info.java
src/com/beem/project/beem/providers/AvatarProvider.java
src/com/beem/project/beem/providers/package-info.java
src/com/beem/project/beem/service/BeemAvatarCache.java
src/com/beem/project/beem/service/BeemAvatarManager.java
src/com/beem/project/beem/service/BeemChatManager.java
src/com/beem/project/beem/service/ChatAdapter.java
src/com/beem/project/beem/service/Contact.aidl
src/com/beem/project/beem/service/Contact.java
src/com/beem/project/beem/service/LoginAsyncTask.java
src/com/beem/project/beem/service/Message.aidl
src/com/beem/project/beem/service/Message.java
src/com/beem/project/beem/service/PresenceAdapter.aidl
src/com/beem/project/beem/service/PresenceAdapter.java
src/com/beem/project/beem/service/PrivacyListItem.aidl
src/com/beem/project/beem/service/PrivacyListItem.java
src/com/beem/project/beem/service/PrivacyListManagerAdapter.java
src/com/beem/project/beem/service/RosterAdapter.java
src/com/beem/project/beem/service/UserInfo.aidl
src/com/beem/project/beem/service/UserInfo.java
src/com/beem/project/beem/service/XmppConnectionAdapter.java
src/com/beem/project/beem/service/XmppFacade.java
src/com/beem/project/beem/service/aidl/IBeemConnectionListener.aidl
src/com/beem/project/beem/service/aidl/IBeemRosterListener.aidl
src/com/beem/project/beem/service/aidl/IChat.aidl
src/com/beem/project/beem/service/aidl/IChatManager.aidl
src/com/beem/project/beem/service/aidl/IChatManagerListener.aidl
src/com/beem/project/beem/service/aidl/IContact.aidl
src/com/beem/project/beem/service/aidl/IMessageListener.aidl
src/com/beem/project/beem/service/aidl/IPrivacyListListener.aidl
src/com/beem/project/beem/service/aidl/IPrivacyListManager.aidl
src/com/beem/project/beem/service/aidl/IRoster.aidl
src/com/beem/project/beem/service/aidl/IXmppConnection.aidl
src/com/beem/project/beem/service/aidl/IXmppFacade.aidl
src/com/beem/project/beem/service/auth/AccountAuthenticator.java
src/com/beem/project/beem/service/auth/PreferenceAuthenticator.java
src/com/beem/project/beem/service/auth/package-info.java
src/com/beem/project/beem/service/package-info.java
src/com/beem/project/beem/smack/avatar/AvatarCache.java
src/com/beem/project/beem/smack/avatar/AvatarExtension.java
src/com/beem/project/beem/smack/avatar/AvatarListener.java
src/com/beem/project/beem/smack/avatar/AvatarManager.java
src/com/beem/project/beem/smack/avatar/AvatarMetadataExtension.java
src/com/beem/project/beem/smack/avatar/AvatarMetadataProvider.java
src/com/beem/project/beem/smack/avatar/AvatarProvider.java
src/com/beem/project/beem/smack/avatar/AvatarRetriever.java
src/com/beem/project/beem/smack/avatar/AvatarRetrieverFactory.java
src/com/beem/project/beem/smack/avatar/FileAvatarCache.java
src/com/beem/project/beem/smack/avatar/HttpAvatarRetriever.java
src/com/beem/project/beem/smack/avatar/HttpClientAvatarRetriever.java
src/com/beem/project/beem/smack/avatar/MemoryAvatarCache.java
src/com/beem/project/beem/smack/avatar/XmppAvatarRetriever.java
src/com/beem/project/beem/smack/avatar/package-info.java
src/com/beem/project/beem/smack/pep/PEPListener.java
src/com/beem/project/beem/smack/pep/PepSubManager.java
src/com/beem/project/beem/smack/pep/package-info.java
src/com/beem/project/beem/smack/ping/PingExtension.java
src/com/beem/project/beem/smack/ping/package-info.java
src/com/beem/project/beem/smack/sasl/SASLGoogleOAuth2Mechanism.java
src/com/beem/project/beem/smack/sasl/ScramSaslClient.java
src/com/beem/project/beem/smack/sasl/ScramSaslMechanism.java
src/com/beem/project/beem/smack/sasl/package-info.java
src/com/beem/project/beem/ui/AddContact.java
src/com/beem/project/beem/ui/ChangeStatus.java
src/com/beem/project/beem/ui/Chat.java
src/com/beem/project/beem/ui/ContactList.java
src/com/beem/project/beem/ui/ContactListAdapter.java
src/com/beem/project/beem/ui/ContactListFragment.java
src/com/beem/project/beem/ui/GroupList.java
src/com/beem/project/beem/ui/Login.java
src/com/beem/project/beem/ui/LoginAnim.java
src/com/beem/project/beem/ui/PrivacyList.java
src/com/beem/project/beem/ui/Settings.java
src/com/beem/project/beem/ui/Subscription.java
src/com/beem/project/beem/ui/dialogs/builders/Alias.java
src/com/beem/project/beem/ui/dialogs/builders/ChatList.java
src/com/beem/project/beem/ui/dialogs/builders/CreatePrivacyList.java
src/com/beem/project/beem/ui/dialogs/builders/DeleteContact.java
src/com/beem/project/beem/ui/dialogs/builders/DeletePrivacyList.java
src/com/beem/project/beem/ui/dialogs/builders/DisplayOtrFingerprint.java
src/com/beem/project/beem/ui/dialogs/builders/ResendSubscription.java
src/com/beem/project/beem/ui/dialogs/builders/package-info.java
src/com/beem/project/beem/ui/package-info.java
src/com/beem/project/beem/ui/views/package-info.java
src/com/beem/project/beem/ui/wizard/Account.java
src/com/beem/project/beem/ui/wizard/AccountConfigureFragment.java
src/com/beem/project/beem/ui/wizard/CreateAccountFragment.java
src/com/beem/project/beem/ui/wizard/package-info.java
src/com/beem/project/beem/utils/BeemBroadcastReceiver.java
src/com/beem/project/beem/utils/BeemConnectivity.java
src/com/beem/project/beem/utils/FreePort.java
src/com/beem/project/beem/utils/PresenceType.java
src/com/beem/project/beem/utils/SortedList.java
src/com/beem/project/beem/utils/Status.java
src/com/beem/project/beem/utils/package-info.java
src/com/google/android/apps/iosched/util/LogUtils.java
src/com/isode/stroke/base/ByteArray.java
src/com/isode/stroke/sasl/ClientAuthenticator.java
src/com/isode/stroke/sasl/SCRAMSHA1ClientAuthenticator.java
src/com/isode/stroke/stringcodecs/Base64.java
src/com/isode/stroke/stringcodecs/Base64BSD.java
src/com/isode/stroke/stringcodecs/HMACSHA1.java
src/com/isode/stroke/stringcodecs/PBKDF2.java
src/com/isode/stroke/stringcodecs/SHA1.java
src/de/duenndns/ssl/MTMDecision.java
src/de/duenndns/ssl/MemorizingActivity.java
src/de/duenndns/ssl/MemorizingTrustManager.java
src/de/duenndns/ssl/package-info.java
src/net/java/otr4j/OtrEngine.java
src/net/java/otr4j/OtrEngineHost.java
src/net/java/otr4j/OtrEngineImpl.java
src/net/java/otr4j/OtrEngineListener.java
src/net/java/otr4j/OtrException.java
src/net/java/otr4j/OtrKeyManager.java
src/net/java/otr4j/OtrKeyManagerImpl.java
src/net/java/otr4j/OtrKeyManagerListener.java
src/net/java/otr4j/OtrKeyManagerStore.java
src/net/java/otr4j/OtrPolicy.java
src/net/java/otr4j/OtrPolicyImpl.java
src/net/java/otr4j/crypto/OtrCryptoEngine.java
src/net/java/otr4j/crypto/OtrCryptoEngineImpl.java
src/net/java/otr4j/crypto/OtrCryptoException.java
src/net/java/otr4j/io/OtrInputStream.java
src/net/java/otr4j/io/OtrOutputStream.java
src/net/java/otr4j/io/SerializationConstants.java
src/net/java/otr4j/io/SerializationUtils.java
src/net/java/otr4j/io/messages/AbstractEncodedMessage.java
src/net/java/otr4j/io/messages/AbstractMessage.java
src/net/java/otr4j/io/messages/DHCommitMessage.java
src/net/java/otr4j/io/messages/DHKeyMessage.java
src/net/java/otr4j/io/messages/DataMessage.java
src/net/java/otr4j/io/messages/ErrorMessage.java
src/net/java/otr4j/io/messages/MysteriousT.java
src/net/java/otr4j/io/messages/PlainTextMessage.java
src/net/java/otr4j/io/messages/QueryMessage.java
src/net/java/otr4j/io/messages/RevealSignatureMessage.java
src/net/java/otr4j/io/messages/SignatureM.java
src/net/java/otr4j/io/messages/SignatureMessage.java
src/net/java/otr4j/io/messages/SignatureX.java
src/net/java/otr4j/session/AuthContext.java
src/net/java/otr4j/session/AuthContextImpl.java
src/net/java/otr4j/session/Session.java
src/net/java/otr4j/session/SessionID.java
src/net/java/otr4j/session/SessionImpl.java
src/net/java/otr4j/session/SessionKeys.java
src/net/java/otr4j/session/SessionKeysImpl.java
src/net/java/otr4j/session/SessionStatus.java
--- a/AndroidManifest.xml	Sun Mar 15 17:28:04 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-	package="com.beem.project.beem"
-	android:versionCode="15"
-	android:versionName="0.1.8"
-	android:installLocation="auto">
-
-	<uses-sdk android:minSdkVersion="6" android:targetSdkVersion="16" />
-	<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
-	
-	<permission android:permissionGroup="android.permission-group.NETWORK"
-		android:label="BeemService" android:description="@string/BeemServiceDescription"
-		android:name="com.beem.project.beem.BEEM_SERVICE"/>
-	<uses-permission android:name="android.permission.INTERNET"/>
-	<uses-permission android:name="android.permission.VIBRATE"/>
-	<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
-	<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
-	<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
-	<uses-permission android:name="android.permission.USE_CREDENTIALS"/>
-	<uses-permission android:name="com.beem.project.beem.BEEM_SERVICE"/>
-	
-	<supports-screens android:largeScreens="true"
-		android:normalScreens="true" android:smallScreens="true" android:anyDensity="true" />
-	    
-	<application android:label="@string/app_name"
-		android:icon="@drawable/beem_launcher_icon_silver"
-		android:name=".BeemApplication"
-		android:allowBackup="true" >
-		
-		<activity android:name=".ui.Login" android:label="@string/app_name"
-			android:launchMode="standard">
-			<intent-filter>
-				<action android:name="android.intent.action.MAIN" />
-				<category android:name="android.intent.category.LAUNCHER" />
-			</intent-filter>
-		</activity>
-		<activity android:name=".ui.wizard.Account" android:label="Account wizard" />
-		<activity android:name=".ui.LoginAnim" android:label="@string/login_login_progress"
-			android:launchMode="singleTop" android:screenOrientation="portrait" />
-		<activity android:name=".ui.Settings" android:label="@string/edit_settings_name" />
-		<activity android:name=".ui.Chat" android:label="@string/chat_name"
-		    android:launchMode="singleTop" />
-		<activity android:name=".ui.ChangeStatus" android:label="@string/ChangeStatusActTitle"
-		    android:launchMode="singleTop"
-		    android:windowSoftInputMode="stateHidden" />
-		<activity android:name=".ui.AddContact" android:label="@string/AddCActTitle" />
-		<activity android:name=".ui.Subscription" android:label="@string/app_name" />
-		
-		<activity android:name=".ui.ContactList" android:label="@string/contact_list_name"
-		    android:launchMode="singleTask" />
-
-		<activity android:name=".ui.GroupList" android:label="GroupList" />
-		<activity android:name=".ui.PrivacyList" android:label="@string/privacy_list_name" />
-
-		<!-- MemorizingTrustManagerActivity -->
-		<activity android:name="de.duenndns.ssl.MemorizingActivity" />
-		<!--
-			Could be interesting if we would launch beem at startup <receiver
-			android:name=".tool.BeemBroadcastReceiver" android:enabled="true">
-			<intent-filter> <action
-			android:name="android.intent.action.BOOT_COMPLETED" />
-			</intent-filter> </receiver>
-		-->
-		<provider android:name=".providers.AvatarProvider"
-		    android:authorities="com.beem.project.beem.providers.avatarprovider"
-		    android:exported="true"
-		    />
-
-		<service android:name="BeemService" android:enabled="true"
-			android:label="Beem Service" android:permission="com.beem.project.beem.BEEM_SERVICE">
-			<intent-filter>
-				<action android:name="com.beem.project.beem.BeemService"></action>
-			</intent-filter>
-		</service>
-	</application>
-	
-</manifest>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/build.gradle	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,30 @@
+apply plugin: 'com.android.application'
+
+android {
+    compileSdkVersion 22
+    buildToolsVersion "22.0.0"
+
+    defaultConfig {
+        applicationId "com.beem.project.beem"
+        minSdkVersion 6
+        targetSdkVersion 22
+        versionCode 15
+        versionName "0.1.8"
+    }
+
+    buildTypes {
+        release {
+            minifyEnabled false
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+        }
+    }
+
+    lintOptions {
+        abortOnError false
+    }
+
+}
+
+dependencies {
+    compile fileTree(dir: 'libs', include: ['*.jar'])
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/libs/README.txt	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,10 @@
+This directory contains the libraries used by BEEM.
+
+The principal one is asmack, a portage of the Smack library for the Android
+platform.
+
+The source of the asmack library can be downloaded at
+http://dev.beem-project.com/attachments/download/51/asmack-android-2.1-source-beem.zip
+
+See the file doc/asmack-beem/README.txt for more informations.
+
Binary file app/libs/android-support-v13.jar has changed
Binary file app/libs/asmack-android-16-beem.jar has changed
Binary file app/libs/lcrypto-jdk16-146-20110415.jar has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/proguard-rules.pro	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,17 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in /opt/android-sdk-update-manager/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/AndroidManifest.xml	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+	package="com.beem.project.beem"
+	android:versionCode="15"
+	android:versionName="0.1.8"
+	android:installLocation="auto">
+
+	<uses-sdk android:minSdkVersion="6" android:targetSdkVersion="16" />
+	<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
+	
+	<permission android:permissionGroup="android.permission-group.NETWORK"
+		android:label="BeemService" android:description="@string/BeemServiceDescription"
+		android:name="com.beem.project.beem.BEEM_SERVICE"/>
+	<uses-permission android:name="android.permission.INTERNET"/>
+	<uses-permission android:name="android.permission.VIBRATE"/>
+	<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+	<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
+	<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
+	<uses-permission android:name="android.permission.USE_CREDENTIALS"/>
+	<uses-permission android:name="com.beem.project.beem.BEEM_SERVICE"/>
+	
+	<supports-screens android:largeScreens="true"
+		android:normalScreens="true" android:smallScreens="true" android:anyDensity="true" />
+	    
+	<application android:label="@string/app_name"
+		android:icon="@drawable/beem_launcher_icon_silver"
+		android:name=".BeemApplication"
+		android:allowBackup="true" >
+		
+		<activity android:name=".ui.Login" android:label="@string/app_name"
+			android:launchMode="standard">
+			<intent-filter>
+				<action android:name="android.intent.action.MAIN" />
+				<category android:name="android.intent.category.LAUNCHER" />
+			</intent-filter>
+		</activity>
+		<activity android:name=".ui.wizard.Account" android:label="Account wizard" />
+		<activity android:name=".ui.LoginAnim" android:label="@string/login_login_progress"
+			android:launchMode="singleTop" android:screenOrientation="portrait" />
+		<activity android:name=".ui.Settings" android:label="@string/edit_settings_name" />
+		<activity android:name=".ui.Chat" android:label="@string/chat_name"
+		    android:launchMode="singleTop" />
+		<activity android:name=".ui.ChangeStatus" android:label="@string/ChangeStatusActTitle"
+		    android:launchMode="singleTop"
+		    android:windowSoftInputMode="stateHidden" />
+		<activity android:name=".ui.AddContact" android:label="@string/AddCActTitle" />
+		<activity android:name=".ui.Subscription" android:label="@string/app_name" />
+		
+		<activity android:name=".ui.ContactList" android:label="@string/contact_list_name"
+		    android:launchMode="singleTask" />
+
+		<activity android:name=".ui.GroupList" android:label="GroupList" />
+		<activity android:name=".ui.PrivacyList" android:label="@string/privacy_list_name" />
+
+		<!-- MemorizingTrustManagerActivity -->
+		<activity android:name="de.duenndns.ssl.MemorizingActivity" />
+		<!--
+			Could be interesting if we would launch beem at startup <receiver
+			android:name=".tool.BeemBroadcastReceiver" android:enabled="true">
+			<intent-filter> <action
+			android:name="android.intent.action.BOOT_COMPLETED" />
+			</intent-filter> </receiver>
+		-->
+		<provider android:name=".providers.AvatarProvider"
+		    android:authorities="com.beem.project.beem.providers.avatarprovider"
+		    android:exported="true"
+		    />
+
+		<service android:name="BeemService" android:enabled="true"
+			android:label="Beem Service" android:permission="com.beem.project.beem.BEEM_SERVICE">
+			<intent-filter>
+				<action android:name="com.beem.project.beem.BeemService"></action>
+			</intent-filter>
+		</service>
+	</application>
+	
+</manifest>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/aidl/com/beem/project/beem/service/Contact.aidl	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,46 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+package com.beem.project.beem.service;
+
+parcelable Contact;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/aidl/com/beem/project/beem/service/Message.aidl	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,46 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+package com.beem.project.beem.service;
+
+parcelable Message;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/aidl/com/beem/project/beem/service/PresenceAdapter.aidl	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,46 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+package com.beem.project.beem.service;
+
+parcelable PresenceAdapter;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/aidl/com/beem/project/beem/service/PrivacyListItem.aidl	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,46 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+package com.beem.project.beem.service;
+
+parcelable PrivacyListItem;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/aidl/com/beem/project/beem/service/UserInfo.aidl	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,46 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+package com.beem.project.beem.service;
+
+parcelable UserInfo;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/aidl/com/beem/project/beem/service/aidl/IBeemConnectionListener.aidl	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,88 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+package com.beem.project.beem.service.aidl;
+
+/**
+ * Interface to listen for connection events
+ * @author Da Risk <barthe_f@epitech.eu>
+ */
+interface IBeemConnectionListener {
+
+    /**
+     *  Callback to call when the connection is closed
+     */
+    void connectionClosed();
+
+    /**
+     *  Callback to call when the connection occurs
+     *  @Deprecated
+     */
+    //void onConnect();
+
+    //void connectionClosedOnError(in Exception e);
+    /**
+     *  Callback to call when the connection is closed on error
+     */
+    void connectionClosedOnError();
+
+    /**
+     * Callback to call when trying to reconnecting
+     */
+    void reconnectingIn(in int seconds);
+
+    /**
+     *  Callback to call when the reconnection has failed
+     */
+    void reconnectionFailed();
+
+    /**
+     *  Callback to call when the reconnection is successfull
+     */
+    void reconnectionSuccessful();
+
+    /**
+     *  Callback to call when the connection Failed
+     */
+    void connectionFailed(in String errorMsg);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/aidl/com/beem/project/beem/service/aidl/IBeemRosterListener.aidl	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,53 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+package com.beem.project.beem.service.aidl;
+
+import com.beem.project.beem.service.PresenceAdapter;
+
+interface IBeemRosterListener {
+    void onEntriesAdded(in List<String> addresses);
+    void onEntriesUpdated(in List<String> addresses);
+    void onEntriesDeleted(in List<String> addresses);
+    void onPresenceChanged(in PresenceAdapter presence);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/aidl/com/beem/project/beem/service/aidl/IChat.aidl	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,121 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+package com.beem.project.beem.service.aidl;
+
+import  com.beem.project.beem.service.Contact;
+import  com.beem.project.beem.service.Message;
+import  com.beem.project.beem.service.aidl.IMessageListener;
+
+/**
+ * An aidl interface for Chat session.
+ */
+interface IChat {
+
+    	/**
+    	 * Send a message.
+    	 * @param message	the message to send
+    	 */
+	void sendMessage(in com.beem.project.beem.service.Message message);
+
+	/**
+	 * Get the participant of the chat
+	 * @return the participant
+	 */
+	Contact getParticipant();
+
+	/**
+	 * Add a message listener.
+	 * @param listener the listener to add.
+	 */
+	void addMessageListener(in IMessageListener listener);
+
+	/**
+	 * Remove a message listener.
+	 * @param listener the listener to remove.
+	 */
+	void removeMessageListener(in IMessageListener listener);
+
+	String getState();
+
+	void setOpen(in boolean isOpen);
+
+	boolean isOpen();
+
+	int getUnreadMessageCount();
+
+	void setState(in String state);
+
+	List<com.beem.project.beem.service.Message> getMessages();
+
+	/**
+	 * Try to start an OTR session.
+	 */
+	void startOtrSession();
+
+	/**
+	 * Stop the OTR session.
+	 */
+	void endOtrSession();
+
+	/**
+	 * get local OTR key fingerprints.
+	 */
+	String getLocalOtrFingerprint();
+
+
+	/**
+	 * get remote OTR key fingerprints.
+	 */
+	String getRemoteOtrFingerprint();
+
+	void verifyRemoteFingerprint(in boolean ok);
+
+
+	/**
+	 * get current OTR status.
+	 */
+	String getOtrStatus();
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/aidl/com/beem/project/beem/service/aidl/IChatManager.aidl	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,99 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+package com.beem.project.beem.service.aidl;
+
+import  com.beem.project.beem.service.Contact;
+import  com.beem.project.beem.service.aidl.IChat;
+import  com.beem.project.beem.service.aidl.IMessageListener;
+import  com.beem.project.beem.service.aidl.IChatManagerListener;
+
+/**
+ * Aidl interface for a chat manager.
+ * The chat manager will manage all the chat sessions.
+ */
+interface IChatManager {
+
+    	/**
+    	 * Create a chat session with a contact.
+    	 * @param contact	the contact to chat with
+    	 * @param listener	the callback to call when a new message comes from this chat session
+    	 * @return 		the chat session
+    	 */
+	IChat createChat(in Contact contact, in IMessageListener listener);
+
+	/**
+	 * Get an existing Chat session with a contact.
+	 * @return null if the chat session does not exist.
+	 */
+	IChat getChat(in Contact contact);
+
+	/**
+    	 * Destroy a chat session with a contact.
+    	 * @param chat	the chat session
+    	 */
+	void destroyChat(in IChat chat);
+
+        /**
+	 * @param chat the chat.
+         */
+	void deleteChatNotification(in IChat chat);
+
+	/**
+	 * Register a callback to call when a new chat session is created.
+	 * @param listener	the callback to add
+	 */
+	void addChatCreationListener(in IChatManagerListener listener);
+
+	/**
+	 * Remove a callback for the creation of new chat session.
+	 * @param listener	the callback to remove.
+	 */
+	void removeChatCreationListener(in IChatManagerListener listener);
+
+	/**
+	 * Get a list of contact which we are currently chatting.
+	 * @return list of contact.
+	 */
+	List<Contact> getOpenedChatList();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/aidl/com/beem/project/beem/service/aidl/IChatManagerListener.aidl	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,61 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+package com.beem.project.beem.service.aidl;
+
+import  com.beem.project.beem.service.aidl.IChat;
+
+/**
+ * Aidl interface for ChatManager listener.
+ * This listener will execute on events like creation of chat session.
+ */
+interface IChatManagerListener {
+
+    	/**
+    	 * Call when a new chat session is created.
+    	 * @param chat		the created chat session
+    	 * @param locally	true if the session is create by a chat manager.
+    	 */
+    	void chatCreated(IChat chat, boolean locally);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/aidl/com/beem/project/beem/service/aidl/IContact.aidl	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,53 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+package com.beem.project.beem.service.aidl;
+
+interface IContact {
+
+	String getJID();
+
+	void setJID(String mjid);
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/aidl/com/beem/project/beem/service/aidl/IMessageListener.aidl	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,69 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+package com.beem.project.beem.service.aidl;
+
+import com.beem.project.beem.service.Message;
+import com.beem.project.beem.service.aidl.IChat;
+
+interface IMessageListener {
+
+	/**
+	 * This method is executed when a chat receive a message.
+	 * @param chat the chat receiving the message.
+	 * @param msg the message received in the chat.
+	 */
+	void processMessage(in IChat chat, in com.beem.project.beem.service.Message msg);
+
+	/**
+	 * This method is executed when a new ChatState is received by the chat.
+	 * You can use IChat.getState() in order to get the new state.
+	 * @param chat the chat changed.
+	 */
+	void stateChanged(in IChat chat);
+	/**
+	 * This method is executed when the otr session status change.
+	 * @param otrState the new state of otr session.
+	 */
+	void otrStateChanged(in String otrState);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/aidl/com/beem/project/beem/service/aidl/IPrivacyListListener.aidl	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,51 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+package com.beem.project.beem.service.aidl;
+
+import  com.beem.project.beem.service.PrivacyListItem;
+
+interface IPrivacyListListener {
+	void updatedPrivacyList(in String listName);
+	void setPrivacyList(in String listName, in List<PrivacyListItem> listItem);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/aidl/com/beem/project/beem/service/aidl/IPrivacyListManager.aidl	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,66 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+package com.beem.project.beem.service.aidl;
+
+import  com.beem.project.beem.service.PrivacyListItem;
+import  com.beem.project.beem.service.aidl.IPrivacyListListener;
+
+interface IPrivacyListManager {
+	void createPrivacyList(in String listName, in List<PrivacyListItem> items);
+	void removePrivacyList(in String listName);
+	void editPrivacyList(in String listName, in List<PrivacyListItem> items);
+	String getActivePrivacyList();
+	String getDefaultPrivacyList();
+	void setActivePrivacyList(in String listName);
+	void setDefaultPrivacyList(in String listName);
+	void declineActivePrivacyList();
+	void declineDefaultPrivacyList();
+	List<String> getPrivacyLists();
+	void blockUser(in String listName, in String jid);
+	List<String> getBlockedUsersByList(in String listName);
+	List<String> getBlockedGroupsByList(in String listName);
+	void addPrivacyListListener(in IPrivacyListListener listener);
+	void removePrivacyListListener(in IPrivacyListListener listener);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/aidl/com/beem/project/beem/service/aidl/IRoster.aidl	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,74 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+package com.beem.project.beem.service.aidl;
+
+import com.beem.project.beem.service.aidl.IBeemRosterListener;
+import com.beem.project.beem.service.Contact;
+import com.beem.project.beem.service.PresenceAdapter;
+
+interface IRoster {
+
+    boolean addContact(in String user, in String name, in String[] groups);
+
+    void deleteContact(in Contact contact);
+
+    Contact getContact(in String jid);
+    void setContactName(in String jid, in String name);
+
+    void createGroup(in String groupname);
+
+    void addContactToGroup(in String groupName, in String jid);
+
+    void removeContactFromGroup(in String groupName, in String jid);
+
+    List<Contact> getContactList();
+
+    List<String> getGroupsNames();
+
+    PresenceAdapter getPresence(in String jid);
+
+    void addRosterListener(in IBeemRosterListener listen);
+    void removeRosterListener(in IBeemRosterListener listen);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/aidl/com/beem/project/beem/service/aidl/IXmppConnection.aidl	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,79 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+package com.beem.project.beem.service.aidl;
+
+import  com.beem.project.beem.service.aidl.IRoster;
+import  com.beem.project.beem.service.aidl.IBeemConnectionListener;
+import  com.beem.project.beem.service.aidl.IChatManager;
+import  com.beem.project.beem.service.aidl.IPrivacyListManager;
+
+interface IXmppConnection {
+
+    boolean connect();
+
+    boolean login();
+
+    boolean connectSync();
+
+    void connectAsync();
+
+    boolean disconnect();
+
+    IRoster getRoster();
+
+    void addConnectionListener(in IBeemConnectionListener listen);
+    void removeConnectionListener(in IBeemConnectionListener listen);
+
+    boolean isAuthentificated();
+
+    IChatManager getChatManager();
+
+    void changeStatusAndPriority(in int status, in String msg, in int priority);
+
+    void changeStatus(in int status, in String msg);
+
+    IPrivacyListManager getPrivacyListManager();
+
+    String getErrorMessage();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/aidl/com/beem/project/beem/service/aidl/IXmppFacade.aidl	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,113 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+package com.beem.project.beem.service.aidl;
+
+import com.beem.project.beem.service.aidl.IXmppConnection;
+import com.beem.project.beem.service.aidl.IRoster;
+import com.beem.project.beem.service.aidl.IChatManager;
+import com.beem.project.beem.service.aidl.IPrivacyListManager;
+import com.beem.project.beem.service.PresenceAdapter;
+import com.beem.project.beem.service.UserInfo;
+
+import android.net.Uri;
+
+interface IXmppFacade {
+
+    /**
+     * Get the XmppConnection of the facade.
+     */
+    IXmppConnection createConnection();
+
+    /**
+     * Get the roster of the user
+     */
+    IRoster getRoster();
+
+    /**
+     * Connect and login synchronously on the server.
+     */
+    void connectSync();
+
+    /**
+     * Connect and login asynchronously on the server.
+     */
+    void connectAsync();
+
+    /**
+     * Disconnect from the server
+     */
+    void disconnect();
+
+    /**
+     * Get the chat manager.
+     */
+    IChatManager getChatManager();
+
+    /**
+     * Change the status of the user.
+     * @param status the status to set
+     * @param msg the message state to set
+     */
+    void changeStatus(in int status, in String msg);
+
+    void sendPresencePacket(in PresenceAdapter presence);
+
+    /**
+     * make a jingle audio call
+     * @param jid the receiver id
+     */
+     void call(in String jid);
+
+    boolean publishAvatar(in Uri avatarUri);
+
+    void disableAvatarPublishing();
+
+    /**
+     * Get the user informations.
+     * @return null if not connected
+     */
+    UserInfo getUserInfo();
+
+     IPrivacyListManager getPrivacyListManager();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/java/com/android/mms/util/SmileyParser.java	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,200 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.mms.util;
+
+import java.util.HashMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import android.content.Context;
+import android.text.Spannable;
+import android.text.SpannableStringBuilder;
+import android.text.style.ImageSpan;
+
+import com.beem.project.beem.R;
+
+/**
+ * A class for annotating a CharSequence with spans to convert textual emoticons
+ * to graphical ones.
+ */
+public class SmileyParser {
+    // Singleton stuff
+    private static SmileyParser sInstance;
+    public static SmileyParser getInstance() { return sInstance; }
+    public static void init(Context context) {
+        sInstance = new SmileyParser(context);
+    }
+
+    private final Context mContext;
+    private final String[] mSmileyTexts;
+    private final Pattern mPattern;
+    private final HashMap<String, Integer> mSmileyToRes;
+
+    private SmileyParser(Context context) {
+        mContext = context;
+        mSmileyTexts = mContext.getResources().getStringArray(DEFAULT_SMILEY_TEXTS);
+        mSmileyToRes = buildSmileyToRes();
+        mPattern = buildPattern();
+    }
+
+    static class Smileys {
+        private static final int[] sIconIds = {
+            R.drawable.emo_im_happy,
+            R.drawable.emo_im_sad,
+            R.drawable.emo_im_winking,
+            R.drawable.emo_im_tongue_sticking_out,
+            R.drawable.emo_im_surprised,
+            R.drawable.emo_im_kissing,
+            R.drawable.emo_im_yelling,
+            R.drawable.emo_im_cool,
+            R.drawable.emo_im_money_mouth,
+            R.drawable.emo_im_foot_in_mouth,
+            R.drawable.emo_im_embarrassed,
+            R.drawable.emo_im_angel,
+            R.drawable.emo_im_undecided,
+            R.drawable.emo_im_crying,
+            R.drawable.emo_im_lips_are_sealed,
+            R.drawable.emo_im_laughing,
+            R.drawable.emo_im_wtf,
+            R.drawable.emo_im_heart,
+            R.drawable.emo_im_mad,
+            R.drawable.emo_im_smirk,
+            R.drawable.emo_im_pokerface
+        };
+
+        public static int HAPPY = 0;
+        public static int SAD = 1;
+        public static int WINKING = 2;
+        public static int TONGUE_STICKING_OUT = 3;
+        public static int SURPRISED = 4;
+        public static int KISSING = 5;
+        public static int YELLING = 6;
+        public static int COOL = 7;
+        public static int MONEY_MOUTH = 8;
+        public static int FOOT_IN_MOUTH = 9;
+        public static int EMBARRASSED = 10;
+        public static int ANGEL = 11;
+        public static int UNDECIDED = 12;
+        public static int CRYING = 13;
+        public static int LIPS_ARE_SEALED = 14;
+        public static int LAUGHING = 15;
+        public static int WTF = 16;
+        public static int MAD = 17;
+        public static int HEART = 18;
+        public static int SMIRK = 19;
+        public static int POKERFACE = 20;
+
+        public static int getSmileyResource(int which) {
+            return sIconIds[which];
+        }
+    }
+
+    // NOTE: if you change anything about this array, you must make the corresponding change
+    // to the string arrays: default_smiley_texts and default_smiley_names in res/values/arrays.xml
+    public static final int[] DEFAULT_SMILEY_RES_IDS = {
+        Smileys.getSmileyResource(Smileys.HAPPY),                //  0
+        Smileys.getSmileyResource(Smileys.SAD),                  //  1
+        Smileys.getSmileyResource(Smileys.WINKING),              //  2
+        Smileys.getSmileyResource(Smileys.TONGUE_STICKING_OUT),  //  3
+        Smileys.getSmileyResource(Smileys.SURPRISED),            //  4
+        Smileys.getSmileyResource(Smileys.KISSING),              //  5
+        Smileys.getSmileyResource(Smileys.YELLING),              //  6
+        Smileys.getSmileyResource(Smileys.COOL),                 //  7
+        Smileys.getSmileyResource(Smileys.MONEY_MOUTH),          //  8
+        Smileys.getSmileyResource(Smileys.FOOT_IN_MOUTH),        //  9
+        Smileys.getSmileyResource(Smileys.EMBARRASSED),          //  10
+        Smileys.getSmileyResource(Smileys.ANGEL),                //  11
+        Smileys.getSmileyResource(Smileys.UNDECIDED),            //  12
+        Smileys.getSmileyResource(Smileys.CRYING),               //  13
+        Smileys.getSmileyResource(Smileys.LIPS_ARE_SEALED),      //  14
+        Smileys.getSmileyResource(Smileys.LAUGHING),             //  15
+        Smileys.getSmileyResource(Smileys.WTF),                  //  16
+        Smileys.getSmileyResource(Smileys.MAD),                  //  17
+        Smileys.getSmileyResource(Smileys.HEART),                //  18
+        Smileys.getSmileyResource(Smileys.SMIRK),                //  19
+        Smileys.getSmileyResource(Smileys.POKERFACE),            //  20
+    };
+
+    public static final int DEFAULT_SMILEY_TEXTS = R.array.default_smiley_texts;
+    public static final int DEFAULT_SMILEY_NAMES = R.array.default_smiley_names;
+
+    /**
+     * Builds the hashtable we use for mapping the string version
+     * of a smiley (e.g. ":-)") to a resource ID for the icon version.
+     */
+    private HashMap<String, Integer> buildSmileyToRes() {
+        if (DEFAULT_SMILEY_RES_IDS.length != mSmileyTexts.length) {
+            // Throw an exception if someone updated DEFAULT_SMILEY_RES_IDS
+            // and failed to update arrays.xml
+            throw new IllegalStateException("Smiley resource ID/text mismatch");
+        }
+
+        HashMap<String, Integer> smileyToRes =
+                            new HashMap<String, Integer>(mSmileyTexts.length);
+        for (int i = 0; i < mSmileyTexts.length; i++) {
+            smileyToRes.put(mSmileyTexts[i], DEFAULT_SMILEY_RES_IDS[i]);
+        }
+
+        return smileyToRes;
+    }
+
+    /**
+     * Builds the regular expression we use to find smileys in {@link #addSmileySpans}.
+     */
+    private Pattern buildPattern() {
+        // Set the StringBuilder capacity with the assumption that the average
+        // smiley is 3 characters long.
+        StringBuilder patternString = new StringBuilder(mSmileyTexts.length * 3);
+
+        // Build a regex that looks like (:-)|:-(|...), but escaping the smilies
+        // properly so they will be interpreted literally by the regex matcher.
+        patternString.append('(');
+        for (String s : mSmileyTexts) {
+            patternString.append(Pattern.quote(s));
+            patternString.append('|');
+        }
+        // Replace the extra '|' with a ')'
+        patternString.replace(patternString.length() - 1, patternString.length(), ")");
+
+        return Pattern.compile(patternString.toString());
+    }
+
+
+    /**
+     * Adds ImageSpans to a CharSequence that replace textual emoticons such
+     * as :-) with a graphical version.
+     *
+     * @param text A CharSequence possibly containing emoticons
+     * @return A CharSequence annotated with ImageSpans covering any
+     *         recognized emoticons.
+     */
+    public CharSequence addSmileySpans(CharSequence text) {
+        SpannableStringBuilder builder = new SpannableStringBuilder(text);
+
+        Matcher matcher = mPattern.matcher(text);
+        while (matcher.find()) {
+            int resId = mSmileyToRes.get(matcher.group());
+            builder.setSpan(new ImageSpan(mContext, resId),
+                            matcher.start(), matcher.end(),
+                            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+        }
+
+        return builder;
+    }
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/java/com/beem/project/beem/BeemApplication.java	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,222 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+
+package com.beem.project.beem;
+
+import android.app.Application;
+import android.content.SharedPreferences;
+import android.preference.PreferenceManager;
+import android.text.TextUtils;
+
+import com.android.mms.util.SmileyParser;
+
+/**
+ * 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 <darisk972@gmail.com>
+ */
+public class BeemApplication extends Application {
+
+    /* 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";
+    /** Preference key for account password. */
+    public static final String ACCOUNT_PASSWORD_KEY = "account_password";
+    /** Preference key set to true if using an Android account . */
+    public static final String USE_SYSTEM_ACCOUNT_KEY = "use_system_account";
+
+    /** Preference key for Android account type . */
+    public static final String ACCOUNT_SYSTEM_TYPE_KEY = "account_system_type";
+
+    /** Preference key set to true if using specific server details. */
+    public static final String ACCOUNT_SPECIFIC_SERVER_KEY = "account_specific_server";
+
+    /** Preference key for specific server hostname. */
+    public static final String ACCOUNT_SPECIFIC_SERVER_HOST_KEY = "account_specific_server_host";
+
+    /** Preference key for specific server port. */
+    public static final String ACCOUNT_SPECIFIC_SERVER_PORT_KEY = "account_specific_server_port";
+
+    /** Preference key for status (available, busy, away, ...). */
+    public static final String STATUS_KEY = "status";
+    /** Preference key for status message. */
+    public static final String STATUS_TEXT_KEY = "status_text";
+    /** Preference key for connection resource . */
+    public static final String CONNECTION_RESOURCE_KEY = "connection_resource";
+    /** Preference key for connection priority. */
+    public static final String CONNECTION_PRIORITY_KEY = "connection_priority";
+    /** Preference key for the use of a proxy. */
+    public static final String PROXY_USE_KEY = "proxy_use";
+    /** Preference key for the type of proxy. */
+    public static final String PROXY_TYPE_KEY = "proxy_type";
+    /** Preference key for the proxy server. */
+    public static final String PROXY_SERVER_KEY = "proxy_server";
+    /** Preference key for the proxy port. */
+    public static final String PROXY_PORT_KEY = "proxy_port";
+    /** Preference key for the proxy username. */
+    public static final String PROXY_USERNAME_KEY = "proxy_username";
+    /** Preference key for the proxy password. */
+    public static final String PROXY_PASSWORD_KEY = "proxy_password";
+    /** Preference key for vibrate on notification. */
+    public static final String NOTIFICATION_VIBRATE_KEY = "notification_vibrate";
+    /** Preference key for notification sound. */
+    public static final String NOTIFICATION_SOUND_KEY = "notification_sound";
+    /** Preference key for smack debugging. */
+    public static final String SMACK_DEBUG_KEY = "smack_debug";
+    /** Preference key for full Jid for login. */
+    public static final String FULL_JID_LOGIN_KEY = "full_jid_login";
+    /** Preference key for display offline contact. */
+    public static final String SHOW_OFFLINE_CONTACTS_KEY = "show_offline_contacts";
+    /** Preference key for hide the groups. */
+    public static final String HIDE_GROUPS_KEY = "hide_groups";
+    /** Preference key for auto away enable. */
+    public static final String USE_AUTO_AWAY_KEY = "use_auto_away";
+    /** Preference key for auto away message. */
+    public static final String AUTO_AWAY_MSG_KEY = "auto_away_msg";
+    /** Preference key for compact chat ui. */
+    public static final String USE_COMPACT_CHAT_UI_KEY = "use_compact_chat_ui";
+    /** Preference key for history path on the SDCard. */
+    public static final String CHAT_HISTORY_KEY = "settings_chat_history_path";
+    /** Preference key to show the jid in the contact list. */
+    public static final String SHOW_JID = "show_jid";
+
+    //TODO add the other one
+
+    private boolean mIsConnected;
+    private boolean mIsAccountConfigured;
+    private boolean mPepEnabled;
+    private SharedPreferences mSettings;
+    private final PreferenceListener mPreferenceListener = new PreferenceListener();
+
+    /**
+     * Constructor.
+     */
+    public BeemApplication() {
+    }
+
+    @Override
+    public void onCreate() {
+	super.onCreate();
+	mSettings = PreferenceManager.getDefaultSharedPreferences(this);
+	String login = mSettings.getString(BeemApplication.ACCOUNT_USERNAME_KEY, "");
+	String password = mSettings.getString(BeemApplication.ACCOUNT_PASSWORD_KEY, "");
+	boolean useSystemAccount = mSettings.getBoolean(BeemApplication.USE_SYSTEM_ACCOUNT_KEY, false);
+	mIsAccountConfigured = !TextUtils.isEmpty(login) && (useSystemAccount || !TextUtils.isEmpty((password)));
+	mSettings.registerOnSharedPreferenceChangeListener(mPreferenceListener);
+	SmileyParser.init(this);
+    }
+
+    @Override
+    public void onTerminate() {
+	super.onTerminate();
+	mSettings.unregisterOnSharedPreferenceChangeListener(mPreferenceListener);
+    }
+
+    /**
+     * Tell if Beem is connected to a XMPP server.
+     * @return false if not connected.
+     */
+    public boolean isConnected() {
+	return mIsConnected;
+    }
+
+    /**
+     * Set the status of the connection to a XMPP server of BEEM.
+     * @param isConnected set for the state of the connection.
+     */
+    public void setConnected(boolean isConnected) {
+	mIsConnected = isConnected;
+    }
+
+    /**
+     * Tell if a XMPP account is configured.
+     * @return false if there is no account configured.
+     */
+    public boolean isAccountConfigured() {
+	return mIsAccountConfigured;
+    }
+
+    /**
+     * Enable Pep in the application context.
+     *
+     * @param enabled true to enable pep
+     */
+    public void setPepEnabled(boolean enabled) {
+	mPepEnabled = enabled;
+    }
+
+    /**
+     * Check if Pep is enabled.
+     *
+     * @return true if enabled
+     */
+    public boolean isPepEnabled() {
+	return mPepEnabled;
+    }
+
+    /**
+     * A listener for all the change in the preference file. It is used to maintain the global state of the application.
+     */
+    private class PreferenceListener implements SharedPreferences.OnSharedPreferenceChangeListener {
+
+	/**
+	 * Constructor.
+	 */
+	public PreferenceListener() {
+	}
+
+	@Override
+	public void onSharedPreferenceChanged(SharedPreferences  sharedPreferences, String key) {
+	    if (BeemApplication.ACCOUNT_USERNAME_KEY.equals(key) || BeemApplication.ACCOUNT_PASSWORD_KEY.equals(key) || BeemApplication.USE_SYSTEM_ACCOUNT_KEY.equals(key)) {
+		String login = mSettings.getString(BeemApplication.ACCOUNT_USERNAME_KEY, "");
+		String password = mSettings.getString(BeemApplication.ACCOUNT_PASSWORD_KEY, "");
+		boolean useSystemAccount = mSettings.getBoolean(BeemApplication.USE_SYSTEM_ACCOUNT_KEY, false);
+		mIsAccountConfigured = !TextUtils.isEmpty(login) && (useSystemAccount || !TextUtils.isEmpty((password)));
+	    }
+	}
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/java/com/beem/project/beem/BeemService.java	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,657 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+package com.beem.project.beem;
+
+import java.io.File;
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+
+import javax.net.ssl.SSLContext;
+
+import android.accounts.Account;
+import android.accounts.AccountManager;
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.Service;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.SharedPreferences;
+import android.content.SharedPreferences.Editor;
+import android.net.ConnectivityManager;
+import android.net.Uri;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.preference.PreferenceManager;
+import android.provider.Settings;
+import android.util.Log;
+
+import com.beem.project.beem.service.XmppConnectionAdapter;
+import com.beem.project.beem.service.XmppFacade;
+import com.beem.project.beem.service.aidl.IXmppFacade;
+import com.beem.project.beem.service.auth.AccountAuthenticator;
+import com.beem.project.beem.service.auth.PreferenceAuthenticator;
+import com.beem.project.beem.smack.avatar.AvatarMetadataProvider;
+import com.beem.project.beem.smack.avatar.AvatarProvider;
+import com.beem.project.beem.smack.ping.PingExtension;
+import com.beem.project.beem.smack.sasl.SASLGoogleOAuth2Mechanism;
+import com.beem.project.beem.smack.sasl.ScramSaslMechanism;
+import com.beem.project.beem.utils.BeemBroadcastReceiver;
+import com.beem.project.beem.utils.BeemConnectivity;
+import com.beem.project.beem.utils.Status;
+
+import de.duenndns.ssl.MemorizingTrustManager;
+
+import org.jivesoftware.smack.ConnectionConfiguration;
+import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode;
+import org.jivesoftware.smack.Roster;
+import org.jivesoftware.smack.Roster.SubscriptionMode;
+import org.jivesoftware.smack.SASLAuthentication;
+import org.jivesoftware.smack.XMPPConnection;
+import org.jivesoftware.smack.provider.ProviderManager;
+import org.jivesoftware.smack.proxy.ProxyInfo;
+import org.jivesoftware.smack.proxy.ProxyInfo.ProxyType;
+import org.jivesoftware.smack.util.StringUtils;
+import org.jivesoftware.smackx.entitycaps.EntityCapsManager;
+import org.jivesoftware.smackx.entitycaps.SimpleDirectoryPersistentCache;
+import org.jivesoftware.smackx.entitycaps.packet.CapsExtension;
+import org.jivesoftware.smackx.packet.ChatStateExtension;
+import org.jivesoftware.smackx.provider.CapsExtensionProvider;
+import org.jivesoftware.smackx.provider.DelayInfoProvider;
+import org.jivesoftware.smackx.provider.DiscoverInfoProvider;
+import org.jivesoftware.smackx.provider.DiscoverItemsProvider;
+import org.jivesoftware.smackx.pubsub.provider.EventProvider;
+import org.jivesoftware.smackx.pubsub.provider.ItemProvider;
+import org.jivesoftware.smackx.pubsub.provider.ItemsProvider;
+import org.jivesoftware.smackx.pubsub.provider.PubSubProvider;
+
+/**
+ * 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 {
+
+    /** The id to use for status notification. */
+    public static final int NOTIFICATION_STATUS_ID = 100;
+
+    private static final String TAG = "BeemService";
+    private static final int DEFAULT_XMPP_PORT = 5222;
+
+    private NotificationManager mNotificationManager;
+    private XmppConnectionAdapter mConnection;
+    private SharedPreferences mSettings;
+    private String mLogin;
+    private String mHost;
+    private String mService;
+    private int mPort;
+    private ConnectionConfiguration mConnectionConfiguration;
+    private IXmppFacade.Stub mBind;
+
+    private BeemBroadcastReceiver mReceiver = new BeemBroadcastReceiver();
+    private BeemServiceBroadcastReceiver mOnOffReceiver = new BeemServiceBroadcastReceiver();
+    private BeemServicePreferenceListener mPreferenceListener = new BeemServicePreferenceListener();
+
+    private boolean mOnOffReceiverIsRegistered;
+
+    private SSLContext sslContext;
+
+    /**
+     * Constructor.
+     */
+    public BeemService() {
+    }
+
+    /**
+     * Initialize the connection.
+     */
+    private void initConnectionConfig() {
+	// TODO add an option for this ?
+//         SmackConfiguration.setPacketReplyTimeout(30000);
+	ProxyInfo proxyInfo = getProxyConfiguration();
+	boolean useSystemAccount = mSettings.getBoolean(BeemApplication.USE_SYSTEM_ACCOUNT_KEY, false);
+	if (useSystemAccount) {
+	    // when using system account, using SPECIFIC_SERVER settings is not a supported configuration.
+	    SASLAuthentication.supportSASLMechanism(SASLGoogleOAuth2Mechanism.MECHANISM_NAME);
+	    String accountType = mSettings.getString(BeemApplication.ACCOUNT_SYSTEM_TYPE_KEY, "");
+	    String accountName = mSettings.getString(BeemApplication.ACCOUNT_USERNAME_KEY, "");
+	    Account account = getAccount(accountName, accountType);
+	    if (account == null) {
+		mSettings.edit().putString(BeemApplication.ACCOUNT_USERNAME_KEY, "").commit();
+	    } else
+		mConnectionConfiguration = getConnectionConfigurationForAccount(account, proxyInfo);
+	}
+	if (!useSystemAccount || mConnectionConfiguration == null) {
+	    SASLAuthentication.unsupportSASLMechanism(SASLGoogleOAuth2Mechanism.MECHANISM_NAME);
+	    if (mSettings.getBoolean(BeemApplication.ACCOUNT_SPECIFIC_SERVER_KEY, false))
+		mConnectionConfiguration = new ConnectionConfiguration(mHost, mPort, mService, proxyInfo);
+	    else
+		mConnectionConfiguration = new ConnectionConfiguration(mService, proxyInfo);
+	    mConnectionConfiguration.setCallbackHandler(new PreferenceAuthenticator(this));
+	}
+
+	if (mSettings.getBoolean("settings_key_xmpp_tls_use", false)
+	    || mSettings.getBoolean("settings_key_gmail", false)) {
+	    mConnectionConfiguration.setSecurityMode(SecurityMode.required);
+	}
+	if (mSettings.getBoolean(BeemApplication.SMACK_DEBUG_KEY, false))
+	    mConnectionConfiguration.setDebuggerEnabled(true);
+	mConnectionConfiguration.setSendPresence(false);
+	mConnectionConfiguration.setRosterLoadedAtLogin(false);
+	// 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");
+	if (sslContext != null)
+	    mConnectionConfiguration.setCustomSSLContext(sslContext);
+    }
+
+    /**
+     * Get the save proxy configuration.
+     *
+     * @return the proxy configuration
+     */
+    private ProxyInfo getProxyConfiguration() {
+	boolean useProxy = mSettings.getBoolean(BeemApplication.PROXY_USE_KEY, false);
+	if (useProxy) {
+	    String stype = mSettings.getString(BeemApplication.PROXY_TYPE_KEY, "HTTP");
+	    String phost = mSettings.getString(BeemApplication.PROXY_SERVER_KEY, "");
+	    String puser = mSettings.getString(BeemApplication.PROXY_USERNAME_KEY, "");
+	    String ppass = mSettings.getString(BeemApplication.PROXY_PASSWORD_KEY, "");
+	    int pport = Integer.parseInt(mSettings.getString(BeemApplication.PROXY_PORT_KEY, "1080"));
+	    ProxyInfo.ProxyType type = ProxyType.valueOf(stype);
+	    return new ProxyInfo(type, phost, pport, puser, ppass);
+	} else {
+	    return ProxyInfo.forNoProxy();
+	}
+    }
+
+    /**
+     * Get the connection configuration for an Android system account.
+     *
+     * @param account the Android account
+     * @param proxy the proxy to use
+     * @return the ConnectionConfiguration or null if the account is not supported
+     */
+    private ConnectionConfiguration getConnectionConfigurationForAccount(Account account, ProxyInfo proxy) {
+	ConnectionConfiguration result = null;
+	if ("com.google".equals(account.type)) {
+	    result = new ConnectionConfiguration("talk.google.com", DEFAULT_XMPP_PORT, proxy);
+	    result.setServiceName(StringUtils.parseServer(account.name));
+	    result.setCallbackHandler(new AccountAuthenticator(this, account));
+	    result.setSecurityMode(SecurityMode.required);
+	}
+	return result;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public IBinder onBind(Intent intent) {
+	Log.d(TAG, "ONBIND()");
+	return mBind;
+    }
+
+    @Override
+    public boolean onUnbind(Intent intent) {
+	Log.d(TAG, "ONUNBIND()");
+	if (mConnection != null  && !mConnection.getAdaptee().isConnected()) {
+	    this.stopSelf();
+	}
+	return true;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void onCreate() {
+	super.onCreate();
+	registerReceiver(mReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
+	mSettings = PreferenceManager.getDefaultSharedPreferences(this);
+	mSettings.registerOnSharedPreferenceChangeListener(mPreferenceListener);
+	if (mSettings.getBoolean(BeemApplication.USE_AUTO_AWAY_KEY, false)) {
+	    mOnOffReceiverIsRegistered = true;
+	    registerReceiver(mOnOffReceiver, new IntentFilter(Intent.ACTION_SCREEN_OFF));
+	    registerReceiver(mOnOffReceiver, new IntentFilter(Intent.ACTION_SCREEN_ON));
+	}
+	String tmpJid = mSettings.getString(BeemApplication.ACCOUNT_USERNAME_KEY, "").trim();
+	mLogin = StringUtils.parseName(tmpJid);
+	boolean useSystemAccount = mSettings.getBoolean(BeemApplication.USE_SYSTEM_ACCOUNT_KEY, false);
+	mPort = DEFAULT_XMPP_PORT;
+	mService = StringUtils.parseServer(tmpJid);
+	mHost = mService;
+	initMemorizingTrustManager();
+
+	if (mSettings.getBoolean(BeemApplication.ACCOUNT_SPECIFIC_SERVER_KEY, false)) {
+	    mHost = mSettings.getString(BeemApplication.ACCOUNT_SPECIFIC_SERVER_HOST_KEY, "").trim();
+	    if ("".equals(mHost))
+		mHost = mService;
+	    String tmpPort = mSettings.getString(BeemApplication.ACCOUNT_SPECIFIC_SERVER_PORT_KEY, "5222");
+	    if (!"".equals(tmpPort))
+		mPort = Integer.parseInt(tmpPort);
+	}
+	if (mSettings.getBoolean(BeemApplication.FULL_JID_LOGIN_KEY, false)
+		|| "gmail.com".equals(mService) || "googlemail.com".equals(mService)
+		|| useSystemAccount)  {
+	    mLogin = tmpJid;
+	}
+
+	configure(ProviderManager.getInstance());
+
+	mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
+
+	Roster.setDefaultSubscriptionMode(SubscriptionMode.manual);
+	mBind = new XmppFacade(this);
+	Log.d(TAG, "Create BeemService");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void onDestroy() {
+	super.onDestroy();
+	mNotificationManager.cancelAll();
+	unregisterReceiver(mReceiver);
+	mSettings.unregisterOnSharedPreferenceChangeListener(mPreferenceListener);
+	if (mOnOffReceiverIsRegistered)
+	    unregisterReceiver(mOnOffReceiver);
+	if (mConnection.isAuthentificated() && BeemConnectivity.isConnected(this))
+	    mConnection.disconnect();
+	Log.i(TAG, "Stopping the service");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void onStart(Intent intent, int startId) {
+	super.onStart(intent, startId);
+	Log.d(TAG, "onStart");
+	createConnectAsync();
+    }
+
+    /**
+     * Create the XmppConnectionAdapter.
+     * This method makes a network request so it must not be called on the main thread.
+     * @return the connection
+     */
+    public XmppConnectionAdapter createConnection() {
+	if (mConnection == null) {
+	    initConnectionConfig();
+	    mConnection = new XmppConnectionAdapter(mConnectionConfiguration, mLogin, null, this);
+	}
+	return mConnection;
+    }
+
+    /**
+     * Show a notification using the preference of the user.
+     * @param id the id of the notification.
+     * @param notif the notification to show
+     */
+    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.flags |= Notification.FLAG_SHOW_LIGHTS;
+	String ringtoneStr = mSettings.getString(BeemApplication.NOTIFICATION_SOUND_KEY,
+		Settings.System.DEFAULT_NOTIFICATION_URI.toString());
+	notif.sound = Uri.parse(ringtoneStr);
+	mNotificationManager.notify(id, notif);
+    }
+
+    /**
+     * Delete a notification.
+     * @param id the id of the notification
+     */
+    public void deleteNotification(int id) {
+	mNotificationManager.cancel(id);
+    }
+
+    /**
+     * Reset the status to online after a disconnect.
+     */
+    public void resetStatus() {
+	Editor edit = mSettings.edit();
+	edit.putInt(BeemApplication.STATUS_KEY, 1);
+	edit.commit();
+    }
+
+    /**
+     * Initialize Jingle from an XmppConnectionAdapter.
+     * @param adaptee XmppConnection used for jingle.
+     */
+    public void initJingle(XMPPConnection adaptee) {
+    }
+
+    /**
+     * Return a bind to an XmppFacade instance.
+     * @return IXmppFacade a bind to an XmppFacade instance
+     */
+    public IXmppFacade getBind() {
+	return mBind;
+    }
+
+    /**
+     * Get the preference of the service.
+     * @return the preference
+     */
+    public SharedPreferences getServicePreference() {
+	return mSettings;
+    }
+
+    /**
+     * Get the notification manager system service.
+     * @return the notification manager service.
+     */
+    public NotificationManager getNotificationManager() {
+	return mNotificationManager;
+    }
+
+    /**
+     * Utility method to create and make a connection asynchronously.
+     */
+    private synchronized void createConnectAsync() {
+	if (mConnection == null) {
+	    new Thread(new Runnable() {
+
+		@Override
+		public void run() {
+		    createConnection();
+		    connectAsync();
+		}
+	    }).start();
+	} else
+	    connectAsync();
+    }
+
+    /**
+     * Utility method to connect asynchronously.
+     */
+    private void connectAsync() {
+	try {
+	    mConnection.connectAsync();
+	} catch (RemoteException e) {
+	    Log.w(TAG, "unable to connect", e);
+	}
+    }
+
+    /**
+     * Get the specified Android account.
+     *
+     * @param accountName the account name
+     * @param accountType the account type
+     *
+     * @return the account or null if it does not exist
+     */
+    private Account getAccount(String accountName, String accountType) {
+	AccountManager am = AccountManager.get(this);
+	for (Account a : am.getAccountsByType(accountType)) {
+	    if (a.name.equals(accountName)) {
+		return a;
+	    }
+	}
+	return null;
+    }
+
+    /**
+     * Install the MemorizingTrustManager in the ConnectionConfiguration of Smack.
+     */
+    private void initMemorizingTrustManager() {
+	try {
+	    sslContext = SSLContext.getInstance("TLS");
+	    sslContext.init(null, MemorizingTrustManager.getInstanceList(this),
+		    new java.security.SecureRandom());
+	} 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.
+     */
+    private void configure(ProviderManager pm) {
+	Log.d(TAG, "configure");
+	// Service Discovery # Items
+	pm.addIQProvider("query", "http://jabber.org/protocol/disco#items", new DiscoverItemsProvider());
+	// Service Discovery # Info
+	pm.addIQProvider("query", "http://jabber.org/protocol/disco#info", new DiscoverInfoProvider());
+
+	// Privacy
+	//pm.addIQProvider("query", "jabber:iq:privacy", new PrivacyProvider());
+	// Delayed Delivery only the new version
+	pm.addExtensionProvider("delay", "urn:xmpp:delay", new DelayInfoProvider());
+
+	// Service Discovery # Items
+	pm.addIQProvider("query", "http://jabber.org/protocol/disco#items", new DiscoverItemsProvider());
+	// Service Discovery # Info
+	pm.addIQProvider("query", "http://jabber.org/protocol/disco#info", new DiscoverInfoProvider());
+
+	// 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("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);
+	// capabilities
+	pm.addExtensionProvider(CapsExtension.NODE_NAME, CapsExtension.XMLNS, new CapsExtensionProvider());
+
+	//Pubsub
+	pm.addIQProvider("pubsub", "http://jabber.org/protocol/pubsub", new PubSubProvider());
+	pm.addExtensionProvider("items", "http://jabber.org/protocol/pubsub", new ItemsProvider());
+	pm.addExtensionProvider("items", "http://jabber.org/protocol/pubsub", new ItemsProvider());
+	pm.addExtensionProvider("item", "http://jabber.org/protocol/pubsub", new ItemProvider());
+
+	pm.addExtensionProvider("items", "http://jabber.org/protocol/pubsub#event", new ItemsProvider());
+	pm.addExtensionProvider("item", "http://jabber.org/protocol/pubsub#event", new ItemProvider());
+	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);
+
+	// ping
+	pm.addIQProvider(PingExtension.ELEMENT, PingExtension.NAMESPACE, PingExtension.class);
+
+	/*
+	// 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());
+	 */
+
+	/* register additionnals sasl mechanisms */
+	SASLAuthentication.registerSASLMechanism(SASLGoogleOAuth2Mechanism.MECHANISM_NAME,
+	    SASLGoogleOAuth2Mechanism.class);
+	SASLAuthentication.registerSASLMechanism(ScramSaslMechanism.MECHANISM_NAME,
+	    ScramSaslMechanism.class);
+
+	SASLAuthentication.supportSASLMechanism(ScramSaslMechanism.MECHANISM_NAME);
+	// Configure entity caps manager. This must be done only once
+	File f = new File(getCacheDir(), "entityCaps");
+	f.mkdirs();
+	try {
+	    EntityCapsManager.setPersistentCache(new SimpleDirectoryPersistentCache(f));
+	} catch (IllegalStateException e) {
+	    Log.v(TAG, "EntityCapsManager already initialized", e);
+	} catch (IOException e) {
+	    Log.w(TAG, "EntityCapsManager not able to reuse persistent cache");
+	}
+    }
+
+    /**
+     * Listen on preference changes.
+     */
+    private class BeemServicePreferenceListener implements SharedPreferences.OnSharedPreferenceChangeListener {
+
+	/**
+	 * ctor.
+	 */
+	public BeemServicePreferenceListener() {
+	}
+
+	@Override
+	public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
+	    if (BeemApplication.USE_AUTO_AWAY_KEY.equals(key)) {
+		if (sharedPreferences.getBoolean(BeemApplication.USE_AUTO_AWAY_KEY, false)) {
+		    mOnOffReceiverIsRegistered = true;
+		    registerReceiver(mOnOffReceiver, new IntentFilter(Intent.ACTION_SCREEN_OFF));
+		    registerReceiver(mOnOffReceiver, new IntentFilter(Intent.ACTION_SCREEN_ON));
+		} else {
+		    mOnOffReceiverIsRegistered = false;
+		    unregisterReceiver(mOnOffReceiver);
+		}
+	    }
+	}
+    }
+
+    /**
+     * Listen on some Intent broadcast, ScreenOn and ScreenOff.
+     */
+    private class BeemServiceBroadcastReceiver extends BroadcastReceiver {
+
+	private String mOldStatus;
+	private int mOldMode;
+
+	/**
+	 * Constructor.
+	 */
+	public BeemServiceBroadcastReceiver() {
+	}
+
+	@Override
+	public void onReceive(final Context context, final Intent intent) {
+	    String intentAction = intent.getAction();
+	    if (intentAction.equals(Intent.ACTION_SCREEN_OFF)) {
+		mOldMode = mConnection.getPreviousMode();
+		mOldStatus = mConnection.getPreviousStatus();
+		if (mConnection.isAuthentificated())
+		    mConnection.changeStatus(Status.CONTACT_STATUS_AWAY,
+			    mSettings.getString(BeemApplication.AUTO_AWAY_MSG_KEY, "Away"));
+	    } else if (intentAction.equals(Intent.ACTION_SCREEN_ON)) {
+		if (mConnection.isAuthentificated())
+		    mConnection.changeStatus(mOldMode, mOldStatus);
+	    }
+	}
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/java/com/beem/project/beem/otr/BeemOtrManager.java	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,210 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009-2011 by Frederic-Charles Barthelery,
+                               Nikita Kozlov,
+                               Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://www.beem-project.com/
+
+*/
+package com.beem.project.beem.otr;
+
+import java.io.IOException;
+import java.security.KeyPair;
+import java.util.HashMap;
+import java.util.Map;
+
+import net.java.otr4j.OtrEngine;
+import net.java.otr4j.OtrEngineHost;
+import net.java.otr4j.OtrEngineImpl;
+import net.java.otr4j.OtrEngineListener;
+import net.java.otr4j.OtrException;
+import net.java.otr4j.OtrKeyManagerImpl;
+import net.java.otr4j.OtrPolicy;
+import net.java.otr4j.OtrPolicyImpl;
+import net.java.otr4j.session.SessionID;
+import net.java.otr4j.session.SessionStatus;
+import android.util.Log;
+
+import com.beem.project.beem.service.ChatAdapter;
+
+/**
+ * BeemOtrManager.
+ */
+public class BeemOtrManager implements OtrEngineHost {
+
+    private static final String TAG = "BeemOtrEngineHostImpl";
+    private static BeemOtrManager INSTANCE;
+    //We will have a global policy for Beem as long as we won't need to modify the policy per chat.
+    private static final OtrPolicy mGlobalPolicy = new OtrPolicyImpl(OtrPolicy.ALLOW_V2 | OtrPolicy.ERROR_START_AKE);
+
+    private OtrEngine mOtrEngine;
+    private OtrKeyManagerImpl mOtrKeyManager;
+
+    //Map of chat, needed because of the message injection
+    private final Map<SessionID, ChatAdapter> mChats = new HashMap<SessionID, ChatAdapter>();
+
+    /**
+     * Private constructor prevents instantiation from other classes.
+     */
+    private BeemOtrManager() {
+	mOtrEngine = new OtrEngineImpl(this);
+	mOtrEngine.addOtrEngineListener(new BeemOtrListener());
+	try {
+	    mOtrKeyManager = new OtrKeyManagerImpl("/sdcard/beem.keystore");
+	} catch (IOException e) {
+	    e.printStackTrace();
+	}
+    }
+
+    /**
+     * getOtrManager.
+     * @return OtrEngine
+     */
+    public OtrEngine getOtrManager() {
+	return mOtrEngine;
+    }
+
+    /**
+     * BeemOtrManager.getInstance.
+     * @return BeemOtrManager
+     */
+    public static BeemOtrManager getInstance() {
+	if (INSTANCE == null)
+	    INSTANCE = new BeemOtrManager();
+	return INSTANCE;
+    }
+
+    /**
+     * We must call addChat before stating a new otr session because we will need the chat instance for message
+     * injection.
+     * @param sessionID the otr sessionID.
+     * @param chat instance.
+     */
+    public void addChat(final SessionID sessionID, final ChatAdapter chat) {
+	mChats.put(sessionID, chat);
+	Log.d(TAG, "adding new OTR session " + sessionID);
+    }
+
+    /**
+     * We must remove the chat from the map after we ended the corresponding otr session.
+     * @param sessionID the otr sessionID to remove.
+     */
+    public void removeChat(final SessionID sessionID) {
+	mChats.remove(sessionID);
+    }
+
+    /**
+     * get the fingerprint of the remote part.
+     * @param sessionID the otr session
+     * @return a string containing the fingerprint
+     */
+    public String getRemoteFingerprint(final SessionID sessionID) {
+	return mOtrKeyManager.getRemoteFingerprint(sessionID);
+    }
+
+    /**
+     * set the remote fingerprint as verified.
+     * @param sessionId the current otr session
+     */
+    public void verifyRemoteFingerprint(final SessionID sessionId) {
+	mOtrKeyManager.verify(sessionId);
+    }
+
+    /**
+     * unsetthe remote fingerprint as verified.
+     * @param sessionId the current otr session
+     */
+    public void unverifyRemoteFingerprint(final SessionID sessionId) {
+	mOtrKeyManager.unverify(sessionId);
+    }
+
+    /**
+     * get the local fingerprint.
+     * @param sessionID the otr session
+     * @return a string containing the fingerprint
+     */
+    public String getLocalFingerprint(final SessionID sessionID) {
+	return mOtrKeyManager.getLocalFingerprint(sessionID);
+    }
+
+    @Override
+    public void injectMessage(SessionID sessionID, String msg) {
+	ChatAdapter chat = mChats.get(sessionID);
+	chat.injectMessage(msg);
+    }
+
+    @Override
+    public void showWarning(SessionID sessionID, String warning) {
+	Log.d(TAG, "Warning for " + sessionID + " : " + warning);
+    }
+
+    @Override
+    public void showError(SessionID sessionID, String error) {
+	Log.d(TAG, "Error for " + sessionID + " : " + error);
+    }
+
+    @Override
+    public OtrPolicy getSessionPolicy(SessionID sessionID) {
+	return mGlobalPolicy;
+    }
+
+    @Override
+    public KeyPair getKeyPair(SessionID sessionID) {
+	KeyPair kp = mOtrKeyManager.loadLocalKeyPair(sessionID);
+
+	if (kp != null)
+	    return kp;
+
+	mOtrKeyManager.generateLocalKeyPair(sessionID);
+	return mOtrKeyManager.loadLocalKeyPair(sessionID);
+    }
+
+    /**
+     * BeemOtrListener.
+     */
+    private class BeemOtrListener implements OtrEngineListener {
+
+	@Override
+	public void sessionStatusChanged(final SessionID sessionID) {
+	    Log.d(TAG, "OTR Status changed for " + sessionID + " : " + mOtrEngine.getSessionStatus(sessionID));
+	    if (mOtrKeyManager.loadRemotePublicKey(sessionID) == null) {
+		mOtrKeyManager.savePublicKey(sessionID, mOtrEngine.getRemotePublicKey(sessionID));
+	    }
+
+	    SessionStatus status = mOtrEngine.getSessionStatus(sessionID);
+
+	    if (status.equals(SessionStatus.ENCRYPTED) && mOtrKeyManager.isVerified(sessionID)) {
+		mChats.get(sessionID).otrStateChanged("AUTHENTICATED");
+	    } else {
+		if (status.equals(SessionStatus.FINISHED)) {
+		    try {
+			mChats.get(sessionID).localEndOtrSession();
+		    } catch (OtrException e) {
+			Log.w(TAG, "error when closing local otr session", e);
+		    }
+		}
+		else {
+		    mChats.get(sessionID).otrStateChanged(status.toString());
+		}
+	    }
+	}
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/java/com/beem/project/beem/package-info.java	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,49 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+
+/**
+ * This package contains BEEM's entry points.
+ */
+package com.beem.project.beem;
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/java/com/beem/project/beem/providers/AvatarProvider.java	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,270 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+package com.beem.project.beem.providers;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.content.UriMatcher;
+import android.database.Cursor;
+import android.database.MatrixCursor;
+import android.net.Uri;
+import android.os.Environment;
+import android.os.ParcelFileDescriptor;
+import android.util.Log;
+
+
+/**
+ * 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");
+
+    /** The MIME type of a CONTENT_URI directory of Beem avatars.  */
+    public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.com.beem.project.beem.avatar";
+
+    /** The MIME type of a CONTENT_URI subdirectory of a single Beem avatar.  */
+    public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.com.beem.project.beem.avatar";
+
+    /**
+     * Id of the user avatar.
+     */
+    public static final String MY_AVATAR_ID = "my_avatar";
+
+
+    private static final String TAG = AvatarProvider.class.getSimpleName();
+    private static final String AUTHORITY = "com.beem.project.beem.providers.avatarprovider";
+
+    private static String[] columnNames = new String[] {Columns.ID, Columns.DATA};
+
+    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);
+	// should not be needed if we pass AVATAR on the constructor but it does not work
+        URIMATCHER.addURI(AUTHORITY, null, AVATAR);
+    }
+
+    private String mDataPath;
+
+    /**
+     * Create an AvatarProvider.
+     */
+    public AvatarProvider() {
+    }
+
+    @Override
+    public boolean onCreate() {
+	File cacheDir = Environment.getExternalStorageDirectory();
+	File dataPath = new File(cacheDir, "/Android/data/com.beem.project.beem/cache/avatar");
+	dataPath.mkdirs();
+	mDataPath = dataPath.getAbsolutePath();
+	return true;
+    }
+
+    @Override
+    public ParcelFileDescriptor openFile(Uri uri, String mode)
+	throws FileNotFoundException {
+    	return openFileHelper(uri, mode);
+    }
+
+    @Override
+    public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
+	MatrixCursor c = new MatrixCursor(columnNames);
+	int match = URIMATCHER.match(uri);
+	switch (match) {
+	    case AVATAR:
+		File[] files = new File(mDataPath).listFiles();
+		if (files != null) {
+		    for (File f : files) {
+			c.newRow().add(f.getName()).add(f.getAbsolutePath());
+		    }
+		}
+		break;
+	    case AVATAR_ID:
+		String id = uri.getPathSegments().get(0);
+		File f = new File(mDataPath, id);
+		if (f.exists() || MY_AVATAR_ID.equals(f.getName()))
+			c.newRow().add(f.getName()).add(f.getAbsolutePath());
+		break;
+	    default:
+		Log.w(TAG, "Unsupported uri for query match = " + match);
+	}
+	if (c != null)
+		c.setNotificationUri(getContext().getContentResolver(), uri);
+	return c;
+    }
+
+    @Override
+    public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
+	int match = URIMATCHER.match(uri);
+	String id = null;
+	switch (match) {
+	    case AVATAR_ID:
+		id = uri.getPathSegments().get(0);
+		break;
+	    default:
+		Log.w(TAG, "Unsupported uri for query match = " + match);
+	}
+
+	if (id == null)
+	    return 0;
+
+	File f = new File(mDataPath, id);
+	try {
+	    f.createNewFile();
+	    getContext().getContentResolver().notifyChange(uri, null);
+	    return 1;
+	} catch (IOException e) {
+	    Log.e(TAG, "Error while creating file", e);
+	}
+	return 0;
+    }
+
+    @Override
+    public int delete(Uri uri, String selection, String[] selectionArgs) {
+	int res = 0;
+	boolean all = false;
+	String id = null;
+	int match = URIMATCHER.match(uri);
+	switch (match) {
+	    case AVATAR_ID:
+		id = uri.getPathSegments().get(0);
+		break;
+	    case AVATAR:
+		all = true;
+		break;
+	    default:
+		Log.w(TAG, "Unsupported uri for query match = " + match);
+	}
+	File[] list = null;
+	if (id != null) {
+	    list = new File[] {new File(mDataPath, id) };
+	} else if (all) {
+	    list = new File(mDataPath).listFiles();
+	}
+
+	if (list == null)
+	    return res;
+	for (File data : list) {
+	    if (data.exists() && data.delete())
+		res++;
+	}
+	if (res > 0)
+	    getContext().getContentResolver().notifyChange(uri, null);
+	return res;
+    }
+
+    @Override
+    public Uri insert(Uri uri, ContentValues values) {
+	int match = URIMATCHER.match(uri);
+	String id = null;
+	Uri result = null;
+	switch (match) {
+	    case AVATAR:
+		id = values.getAsString(Columns.ID);
+		result = Uri.withAppendedPath(uri, id);
+		break;
+	    case AVATAR_ID:
+		id = uri.getPathSegments().get(0);
+		result = uri;
+		break;
+	    default:
+		Log.w(TAG, "Unsupported uri for query match = " + match);
+	}
+	if (id == null)
+	    return null;
+
+	File f = new File(mDataPath, id);
+	try {
+	    f.createNewFile();
+	    if (result != null)
+		getContext().getContentResolver().notifyChange(result, null);
+	    return result;
+	} catch (IOException e) {
+	    Log.e(TAG, "Error while creating file", e);
+	}
+	return null;
+    }
+
+    @Override
+    public String getType(Uri uri) {
+    	int match = URIMATCHER.match(uri);
+    	switch (match) {
+    	    case AVATAR:
+    		return CONTENT_TYPE;
+    	    case AVATAR_ID:
+    		return CONTENT_ITEM_TYPE;
+    	    default:
+    		Log.w(TAG, "Unsupported uri for query match = " + match);
+    	}
+	return null;
+    }
+
+    /**
+     * The differents columns available in the AvatarProvider.
+     */
+    public interface Columns {
+
+	/** The id of the avatar.
+	 * type: string */
+	String ID = "_id";
+
+	/** The path of the avatar file.
+	 * type: string
+	 * This field is readonly */
+	String DATA = "_data";
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/java/com/beem/project/beem/providers/package-info.java	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,49 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+
+
+/**
+ * ContentProviders for Beem.
+ */
+package com.beem.project.beem.providers;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/java/com/beem/project/beem/service/BeemAvatarCache.java	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,136 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+package com.beem.project.beem.service;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import android.content.ContentResolver;
+import android.content.Context;
+
+import android.database.Cursor;
+
+import android.net.Uri;
+
+import com.beem.project.beem.providers.AvatarProvider;
+import com.beem.project.beem.smack.avatar.AvatarCache;
+
+
+/**
+ * An implementation of an AvatarCache which store the data of the filesystem.
+ */
+public class BeemAvatarCache implements AvatarCache {
+
+    private static final String TAG = BeemAvatarCache.class.getSimpleName();
+
+    private Context mContext;
+    private ContentResolver mContentResolver;
+
+    /**
+     * Create a BeemAvatarCache.
+     *
+     * @param ctx The android context of the cache.
+     */
+    public BeemAvatarCache(final Context ctx) {
+	mContext = ctx;
+	mContentResolver = mContext.getContentResolver();
+    }
+
+
+    @Override
+    public void put(String key, byte[] data) throws IOException {
+	Uri uri = AvatarProvider.CONTENT_URI.buildUpon().appendPath(key).build();
+	mContentResolver.insert(uri, null);
+	OutputStream os = new BufferedOutputStream(mContentResolver.openOutputStream(uri));
+	try {
+	    os.write(data);
+	} finally {
+	    os.close();
+	}
+    }
+
+    @Override
+    public void put(String key, InputStream in) throws IOException {
+	Uri uri = AvatarProvider.CONTENT_URI.buildUpon().appendPath(key).build();
+	mContentResolver.insert(uri, null);
+	OutputStream os = new BufferedOutputStream(mContentResolver.openOutputStream(uri));
+	try {
+	    byte[] data = new byte[1024];
+	    int nbread;
+	    while ((nbread = in.read(data)) != -1)
+		    os.write(data, 0, nbread);
+	} finally {
+	    in.close();
+	    os.close();
+	}
+    }
+
+    @Override
+    public byte[] get(String key) throws IOException {
+	Uri uri = AvatarProvider.CONTENT_URI.buildUpon().appendPath(key).build();
+	InputStream is = new BufferedInputStream(mContentResolver.openInputStream(uri));
+	ByteArrayOutputStream bos = new ByteArrayOutputStream();
+	try {
+	    byte[] data = new byte[1024];
+	    is.read(data);
+	    bos.write(data);
+	} finally {
+	    is.close();
+	}
+	return bos.toByteArray();
+    }
+
+    @Override
+    public boolean contains(String key) {
+	Uri uri = AvatarProvider.CONTENT_URI.buildUpon().appendPath(key).build();
+	Cursor c = mContentResolver.query(uri, null, null, null, null);
+	boolean res = c.getCount() > 0;
+	c.close();
+	return res;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/java/com/beem/project/beem/service/BeemAvatarManager.java	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,170 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+
+package com.beem.project.beem.service;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.net.Uri;
+import android.provider.MediaStore;
+import android.util.Log;
+
+import com.beem.project.beem.smack.avatar.AvatarManager;
+import com.beem.project.beem.smack.avatar.AvatarCache;
+import com.beem.project.beem.smack.avatar.AvatarMetadataExtension;
+
+import java.security.NoSuchAlgorithmException;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import com.beem.project.beem.smack.pep.PepSubManager;
+import org.jivesoftware.smack.Connection;
+
+/**
+ * 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();
+    private static final int JPEG_QUALITY = 100;
+
+    private Context mContext;
+
+    /**
+     * Create a BeemAvatarManager.
+     *
+     * @param ctx the Android context
+     * @param con the connection
+     * @param pepMgr the PepSubManager of the connection
+     * @param cache the cache which will store the avatars
+     * @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) {
+	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
+     */
+    public boolean publishAvatar(Uri avatarUri) {
+	try {
+	    Bitmap bmp = MediaStore.Images.Media.getBitmap(mContext.getContentResolver(), avatarUri);
+	    return publishAvatar(bmp);
+	} catch (IOException e) {
+	    Log.d(TAG, "Error while publishing avatar " + avatarUri, e);
+	}
+	return false;
+    }
+
+    /**
+     * 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
+     */
+    private boolean publishAvatar(Bitmap bitmap) {
+	//TODO use the metadata available in the mediastore
+	AvatarMetadataExtension meta = new AvatarMetadataExtension();
+	// Probably a bug on prosody but only the last data sent is kept
+	// and in beem we retrieve the first info
+	AvatarMetadataExtension.Info jpeg = publishBitmap(bitmap, Bitmap.CompressFormat.JPEG, JPEG_QUALITY);
+	// The png format is mandatory for interoperability
+	AvatarMetadataExtension.Info png = publishBitmap(bitmap, Bitmap.CompressFormat.PNG, JPEG_QUALITY);
+	if (png == null)
+	    return false;
+	meta.addInfo(png);
+	if (jpeg != null)
+	    meta.addInfo(jpeg);
+	publishAvatarMetaData(png.getId(), meta);
+	return true;
+    }
+
+    /**
+     * 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
+     * @return the resulting info associate with this bitmap. null if the operation failed
+     */
+    private AvatarMetadataExtension.Info publishBitmap(Bitmap bmp, Bitmap.CompressFormat format, int quality) {
+	try {
+	    byte[] data = getBitmapByte(bmp, format, quality);
+	    String dataid = getAvatarId(data);
+	    if (!publishAvatarData(data))
+		return null;
+	    String mimetype = "image/png";
+	    if (Bitmap.CompressFormat.JPEG == format)
+		mimetype = "image/jpeg";
+	    AvatarMetadataExtension.Info info = new AvatarMetadataExtension.Info(dataid, mimetype, data.length);
+	    info.setHeight(bmp.getHeight());
+	    info.setWidth(bmp.getWidth());
+	    return info;
+	} catch (NoSuchAlgorithmException ex) {
+	    return null;
+	}
+    }
+
+    /**
+     * 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
+     * @return the bitmap data or a array of 0 element on error
+     */
+    private byte[] getBitmapByte(Bitmap bitmap, Bitmap.CompressFormat format, int quality) {
+	ByteArrayOutputStream bos = new ByteArrayOutputStream();
+	if (bitmap.compress(format, quality, bos))
+	    return bos.toByteArray();
+	else
+	    return new byte[0];
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/java/com/beem/project/beem/service/BeemChatManager.java	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,410 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+package com.beem.project.beem.service;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import android.app.PendingIntent;
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.net.Uri;
+import android.os.Environment;
+import android.os.RemoteCallbackList;
+import android.os.RemoteException;
+import android.preference.PreferenceManager;
+import android.support.v4.app.NotificationCompat;
+import android.util.Log;
+
+import com.beem.project.beem.BeemApplication;
+import com.beem.project.beem.BeemService;
+import com.beem.project.beem.R;
+import com.beem.project.beem.providers.AvatarProvider;
+import com.beem.project.beem.service.aidl.IChat;
+import com.beem.project.beem.service.aidl.IChatManager;
+import com.beem.project.beem.service.aidl.IChatManagerListener;
+import com.beem.project.beem.service.aidl.IMessageListener;
+import com.beem.project.beem.service.aidl.IRoster;
+import com.beem.project.beem.utils.Status;
+
+import net.java.otr4j.OtrException;
+
+import org.jivesoftware.smack.Chat;
+import org.jivesoftware.smack.ChatManager;
+import org.jivesoftware.smack.ChatManagerListener;
+import org.jivesoftware.smack.Roster;
+import org.jivesoftware.smack.RosterListener;
+import org.jivesoftware.smack.packet.Presence;
+import org.jivesoftware.smack.util.StringUtils;
+
+/**
+ * An adapter for smack's ChatManager. This class provides functionnality to handle chats.
+ * @author darisk
+ */
+public class BeemChatManager extends IChatManager.Stub {
+
+    private static final String TAG = "BeemChatManager";
+    private final ChatManager mAdaptee;
+    private final Map<String, ChatAdapter> mChats = new HashMap<String, ChatAdapter>();
+    private final ChatListener mChatListener = new ChatListener();
+    private final RemoteCallbackList<IChatManagerListener> mRemoteChatCreationListeners =
+	new RemoteCallbackList<IChatManagerListener>();
+    private final BeemService mService;
+    private final Roster mRoster;
+    private final ChatRosterListener mChatRosterListn = new ChatRosterListener();
+
+    /**
+     * Constructor.
+     * @param chatManager the smack ChatManager to adapt
+     * @param service the service which runs the chat manager
+     * @param roster roster used to get presences changes
+     */
+    public BeemChatManager(final ChatManager chatManager, final BeemService service, final Roster roster) {
+	mService = service;
+	mAdaptee = chatManager;
+	mRoster = roster;
+	mRoster.addRosterListener(mChatRosterListn);
+	mAdaptee.addChatListener(mChatListener);
+    }
+
+    @Override
+    public void addChatCreationListener(IChatManagerListener listener) throws RemoteException {
+	if (listener != null)
+	    mRemoteChatCreationListeners.register(listener);
+    }
+
+    /**
+     * Create a chat session.
+     * @param contact the contact you want to chat with
+     * @param listener listener to use for chat events on this chat session
+     * @return the chat session
+     */
+    @Override
+    public IChat createChat(Contact contact, IMessageListener listener) {
+	String jid = contact.getJIDWithRes();
+	return createChat(jid, listener);
+    }
+
+    /**
+     * Create a chat session.
+     * @param jid the jid of the contact you want to chat with
+     * @param listener listener to use for chat events on this chat session
+     * @return the chat session
+     */
+    public IChat createChat(String jid, IMessageListener listener) {
+	String key = jid;
+	ChatAdapter result;
+	if (mChats.containsKey(key)) {
+	    result = mChats.get(key);
+	    result.addMessageListener(listener);
+	    return result;
+	}
+	Chat c = mAdaptee.createChat(key, null);
+	// maybe a little probleme of thread synchronization
+	// if so use an HashTable instead of a HashMap for mChats
+	result = getChat(c);
+	result.addMessageListener(listener);
+	return result;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void destroyChat(IChat chat) throws RemoteException {
+	// Can't remove it. otherwise we will lose all futur message in this chat
+	// chat.removeMessageListener(mChatListener);
+	if (chat == null)
+	    return;
+	deleteChatNotification(chat);
+	mChats.remove(chat.getParticipant().getJID());
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void deleteChatNotification(IChat chat) {
+	try {
+	    mService.deleteNotification(chat.getParticipant().getJID().hashCode());
+	} catch (RemoteException e) {
+	    Log.v(TAG, "Remote exception ", e);
+	}
+    }
+
+    /**
+     * Get an existing ChatAdapter or create it if necessary.
+     * @param chat The real instance of smack chat
+     * @return a chat adapter register in the manager
+     */
+    private ChatAdapter getChat(Chat chat) {
+	String key = chat.getParticipant();
+	if (mChats.containsKey(key)) {
+	    return mChats.get(key);
+	}
+	ChatAdapter res = new ChatAdapter(chat);
+	boolean history = PreferenceManager.getDefaultSharedPreferences(mService.getBaseContext()).getBoolean(
+	    "settings_key_history", false);
+	String accountUser = PreferenceManager.getDefaultSharedPreferences(mService.getBaseContext()).getString(
+	    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/";
+	res.setHistory(history);
+	res.setAccountUser(accountUser);
+	res.listenOtrSession();
+	res.setHistoryPath(new File(Environment.getExternalStorageDirectory(), historyPath));
+	Log.d(TAG, "getChat put " + key);
+	mChats.put(key, res);
+	return res;
+    }
+
+    @Override
+    public ChatAdapter getChat(Contact contact) {
+	String key = contact.getJIDWithRes();
+	return mChats.get(key);
+    }
+
+    /**
+     * This methods permits to retrieve the list of contacts who have an opened chat session with us.
+     * @return An List containing Contact instances.
+     * @throws RemoteException If a Binder remote-invocation error occurred.
+     */
+    public List<Contact> getOpenedChatList() throws RemoteException {
+	List<Contact> openedChats = new ArrayList<Contact>();
+	IRoster r = mService.getBind().getRoster();
+	for (ChatAdapter chat : mChats.values()) {
+	    if (chat.getMessages().size() > 0) {
+		Contact t = r.getContact(chat.getParticipant().getJID());
+		if (t == null)
+		    t = new Contact(chat.getParticipant().getJID());
+		openedChats.add(t);
+	    }
+	}
+	return openedChats;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void removeChatCreationListener(IChatManagerListener listener) throws RemoteException {
+	if (listener != null)
+	    mRemoteChatCreationListeners.unregister(listener);
+    }
+
+    /**
+     * A listener for all the chat creation event that happens on the connection.
+     * @author darisk
+     */
+    private class ChatListener extends IMessageListener.Stub implements ChatManagerListener {
+
+	/**
+	 * Constructor.
+	 */
+	public ChatListener() {
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public void chatCreated(Chat chat, boolean locally) {
+	    IChat newchat = getChat(chat);
+	    Log.d(TAG, "Chat" + chat.toString() + " created locally " + locally + " with " + chat.getParticipant());
+	    try {
+		newchat.addMessageListener(mChatListener);
+		final int n = mRemoteChatCreationListeners.beginBroadcast();
+
+		for (int i = 0; i < n; i++) {
+		    IChatManagerListener listener = mRemoteChatCreationListeners.getBroadcastItem(i);
+		    listener.chatCreated(newchat, locally);
+		}
+		mRemoteChatCreationListeners.finishBroadcast();
+	    } catch (RemoteException e) {
+		// The RemoteCallbackList will take care of removing the
+		// dead listeners.
+		Log.w(TAG, " Error while triggering remote connection listeners in chat creation", e);
+	    }
+	}
+
+	/**
+	 * Create the PendingIntent to launch our activity if the user select this chat notification.
+	 * @param chat A ChatAdapter instance
+	 * @return A Chat activity PendingIntent
+	 */
+	private PendingIntent makeChatIntent(IChat chat) {
+	    Intent chatIntent = new Intent(mService, com.beem.project.beem.ui.Chat.class);
+	    chatIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP
+		| Intent.FLAG_ACTIVITY_NEW_TASK);
+	    try {
+		chatIntent.setData(chat.getParticipant().toUri());
+	    } catch (RemoteException e) {
+		Log.e(TAG, e.getMessage());
+	    }
+	    PendingIntent contentIntent = PendingIntent.getActivity(mService, 0, chatIntent,
+		PendingIntent.FLAG_UPDATE_CURRENT);
+	    return contentIntent;
+	}
+
+	/**
+	 * Set a notification of a new chat.
+	 * @param chat The chat to access by the notification
+	 * @param msgBody the body of the new message
+	 */
+	private void notifyNewChat(IChat chat, String msgBody) {
+	    NotificationCompat.Builder notif = new NotificationCompat.Builder(mService);
+	    try {
+		String contactJid = chat.getParticipant().getJID();
+		Contact c = mService.getBind().getRoster().getContact(contactJid);
+		String contactName = contactJid;
+		if (c != null) {
+		    contactName = c.getName();
+		    Bitmap avatar = getAvatar(c);
+		    notif.setLargeIcon(avatar);
+		}
+		notif.setTicker(contactName).setContentTitle(contactName);
+		notif.setContentText(msgBody);
+		notif.setSmallIcon(R.drawable.beem_status_icon_gray);
+		notif.setNumber(chat.getUnreadMessageCount());
+		notif.setContentIntent(makeChatIntent(chat));
+		notif.setAutoCancel(true).setWhen(System.currentTimeMillis());
+		mService.sendNotification(chat.getParticipant().getJID().hashCode(), notif.getNotification());
+	    } catch (RemoteException e) {
+		Log.e(TAG, e.getMessage());
+	    }
+	}
+
+	/**
+	 * Get the avatar of a contact.
+	 * @param c the contact
+	 * @return the avatar of c or null if avatar is not defined
+	 */
+	private Bitmap getAvatar(Contact c) {
+	    String id = c.getAvatarId();
+	    if (id == null)
+		id = "";
+	    Uri uri = AvatarProvider.CONTENT_URI.buildUpon().appendPath(id).build();
+	    try {
+		InputStream in = mService.getContentResolver().openInputStream(uri);
+		return BitmapFactory.decodeStream(in);
+	    } catch (FileNotFoundException e) {
+		Log.d(TAG, "Error loading avatar id: " + id, e);
+		return null;
+	    }
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public void processMessage(final IChat chat, Message message) {
+	    try {
+		String body = message.getBody();
+		if (!chat.isOpen() && body != null) {
+		    if (chat instanceof ChatAdapter) {
+			mChats.put(chat.getParticipant().getJID(), (ChatAdapter) chat);
+		    }
+		    notifyNewChat(chat, body);
+		}
+	    } catch (RemoteException e) {
+		Log.e(TAG, e.getMessage());
+	    }
+	}
+
+	@Override
+	public void stateChanged(final IChat chat) {
+	}
+
+	@Override
+	public void otrStateChanged(String otrState) throws RemoteException {
+	    // TODO Auto-generated method stub
+
+	}
+    }
+
+    /**
+     * implement a roster listener, is used to detect and close otr chats.
+     * @author nikita
+     *
+     */
+    private class ChatRosterListener implements RosterListener {
+
+	@Override
+	public void entriesAdded(Collection<String> arg0) {
+	}
+
+	@Override
+	public void entriesDeleted(Collection<String> arg0) {
+	}
+
+	@Override
+	public void entriesUpdated(Collection<String> arg0) {
+	}
+
+	@Override
+	public void presenceChanged(Presence presence) {
+	    String key = StringUtils.parseBareAddress(presence.getFrom());
+	    if (!mChats.containsKey(key)) {
+		return;
+	    }
+
+	    if (Status.getStatusFromPresence(presence) >= Status.CONTACT_STATUS_DISCONNECT) {
+		try {
+		    mChats.get(key).localEndOtrSession();
+		} catch (OtrException e) {
+		    e.printStackTrace();
+		}
+	    }
+	}
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/java/com/beem/project/beem/service/ChatAdapter.java	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,522 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+package com.beem.project.beem.service;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+import android.os.Environment;
+import android.os.RemoteCallbackList;
+import android.os.RemoteException;
+import android.util.Log;
+
+import com.beem.project.beem.otr.BeemOtrManager;
+import com.beem.project.beem.service.aidl.IChat;
+import com.beem.project.beem.service.aidl.IMessageListener;
+
+import net.java.otr4j.OtrException;
+import net.java.otr4j.session.SessionID;
+
+import org.jivesoftware.smack.Chat;
+import org.jivesoftware.smack.XMPPException;
+import org.jivesoftware.smack.util.StringUtils;
+import org.jivesoftware.smackx.ChatState;
+import org.jivesoftware.smackx.ChatStateListener;
+
+/**
+ * An adapter for smack's Chat class.
+ * @author darisk
+ */
+public class ChatAdapter extends IChat.Stub {
+    private static final int HISTORY_MAX_SIZE = 50;
+    private static final String TAG = "ChatAdapter";
+    private static final String PROTOCOL = "XMPP";
+
+    private final Chat mAdaptee;
+    private final Contact mParticipant;
+    private String mState;
+    private boolean mIsOpen;
+    private final List<Message> mMessages;
+    private final RemoteCallbackList<IMessageListener> mRemoteListeners = new RemoteCallbackList<IMessageListener>();
+    private final MsgListener mMsgListener = new MsgListener();
+    private SessionID mOtrSessionId;
+    private boolean mIsHistory;
+    private File mHistoryPath;
+    private String mAccountUser;
+    private int mUnreadMsgCount;
+
+    /**
+     * Constructor.
+     * @param chat The chat to adapt
+     */
+    public ChatAdapter(final Chat chat) {
+	mAdaptee = chat;
+	mParticipant = new Contact(chat.getParticipant());
+	mMessages = new LinkedList<Message>();
+	mAdaptee.addMessageListener(mMsgListener);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Contact getParticipant() throws RemoteException {
+	return mParticipant;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void sendMessage(com.beem.project.beem.service.Message message) throws RemoteException {
+	com.beem.project.beem.service.Message encrypted = otrEncryptMessage(message);
+	if (encrypted != null) {
+	    transferMessage(encrypted);
+	} else {
+	    transferMessage(message);
+	}
+	addMessage(message);
+    }
+
+    /**
+     * private method for sending message.
+     * @param message the message to send
+     */
+    private void transferMessage(com.beem.project.beem.service.Message message) {
+	org.jivesoftware.smack.packet.Message send = new org.jivesoftware.smack.packet.Message();
+	String msgBody = message.getBody();
+	send.setTo(message.getTo());
+	Log.w(TAG, "message to " + message.getTo());
+	send.setBody(msgBody);
+
+	send.setThread(message.getThread());
+	send.setSubject(message.getSubject());
+	send.setType(org.jivesoftware.smack.packet.Message.Type.chat);
+	// TODO gerer les messages contenant des XMPPError
+	// send.set
+	try {
+	    mAdaptee.sendMessage(send);
+	} catch (XMPPException e) {
+	    e.printStackTrace();
+	}
+    }
+
+    /**
+     * send message.
+     * @param msg to send.
+     */
+    public void injectMessage(String msg) {
+	Message msgToSend = new Message(mParticipant.getJIDWithRes(), Message.MSG_TYPE_CHAT);
+	msgToSend.setBody(msg);
+	transferMessage(msgToSend);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void addMessageListener(IMessageListener listen) {
+	if (listen != null)
+	    mRemoteListeners.register(listen);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void removeMessageListener(IMessageListener listen) {
+	if (listen != null) {
+	    mRemoteListeners.unregister(listen);
+	}
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getState() throws RemoteException {
+	return mState;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setState(String state) throws RemoteException {
+	mState = state;
+    }
+
+    /**
+     * Get the adaptee for the Chat.
+     * @return The real chat object
+     */
+    public Chat getAdaptee() {
+	return mAdaptee;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setOpen(boolean isOpen) {
+	this.mIsOpen = isOpen;
+	if (isOpen)
+		mUnreadMsgCount = 0;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean isOpen() {
+	return mIsOpen;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public List<Message> getMessages() throws RemoteException {
+	return Collections.unmodifiableList(mMessages);
+    }
+
+    /**
+     * Add a message in the chat history.
+     * @param msg the message to add
+     */
+    private void addMessage(Message msg) {
+	if (mMessages.size() == HISTORY_MAX_SIZE)
+	    mMessages.remove(0);
+	mMessages.add(msg);
+	if (!isOpen())
+	    mUnreadMsgCount++;
+	if (!"".equals(msg.getBody()) && msg.getBody() != null) {
+	    logMessage(msg);
+	}
+    }
+
+    /**
+     * Save message in SDCard.
+     * @param msg the message receive
+     * @param contactName the name of the contact
+     */
+    public void saveHistory(Message msg, String contactName) {
+	File path = getHistoryPath();
+	File filepath;
+	if (contactName.equals(msg.getFrom()))
+	    filepath = new File(path, StringUtils.parseBareAddress(contactName));
+	else
+	    filepath = new File(path, StringUtils.parseBareAddress(msg.getTo()));
+	path.mkdirs();
+	try {
+	    FileWriter file = new FileWriter(filepath, true);
+	    String log = msg.getTimestamp() + " " + contactName + " " + msg.getBody()
+		+ System.getProperty("line.separator");
+	    file.write(log);
+	    file.close();
+	} catch (IOException e) {
+	    Log.e(TAG, "Error writing chat history", e);
+	}
+    }
+
+    /**
+     * set History enable/disable.
+     * @param isHisory history state
+     */
+    public void setHistory(boolean isHisory) {
+	this.mIsHistory = isHisory;
+    }
+
+    /**
+     * get History state.
+     * @return mIsHistory
+     */
+    public boolean getHistory() {
+	return mIsHistory;
+    }
+
+    /**
+     * Set Account user name.
+     * @param accountUser user name
+     */
+    public void setAccountUser(String accountUser) {
+	mAccountUser = accountUser;
+    }
+
+    /**
+     * get Account user name.
+     * @return mAccountUser
+     */
+    public String getAccountUser() {
+	return mAccountUser;
+    }
+
+    /**
+     * set History path.
+     * @param historyPath history path
+     */
+    public void setHistoryPath(File historyPath) {
+	this.mHistoryPath = historyPath;
+    }
+
+    /**
+     * get History path.
+     * @return mHistoryPath;
+     */
+    public File getHistoryPath() {
+	return mHistoryPath;
+    }
+
+    /**
+     * log a message.
+     * @param message message to log
+     */
+    private void logMessage(com.beem.project.beem.service.Message message) {
+	String state = Environment.getExternalStorageState();
+	if (mIsHistory && Environment.MEDIA_MOUNTED.equals(state))
+	    saveHistory(message, mAccountUser);
+
+    }
+
+    /**
+     * encrypt a message with an otr session.
+     * @param unencrypted message with cleartext body
+     * @return message with encrypted body
+     */
+    private com.beem.project.beem.service.Message otrEncryptMessage(com.beem.project.beem.service.Message unencrypted) {
+
+	if (mOtrSessionId != null && unencrypted != null && unencrypted.getBody() != null) {
+	    try {
+		String body = BeemOtrManager.getInstance().getOtrManager()
+		    .transformSending(mOtrSessionId, unencrypted.getBody());
+		Message result = new Message(unencrypted.getTo(), unencrypted.getType());
+		result.setBody(body);
+		return result;
+	    } catch (OtrException e) {
+		Log.e(TAG, "OTR: Unable to encrypt message", e);
+	    }
+	}
+	return null;
+    }
+
+    /**
+     * This method is executed when the otr session status change.
+     * @param otrState the new state of otr session.
+     */
+    public void otrStateChanged(final String otrState) {
+	Message m = new Message(null, Message.MSG_TYPE_INFO);
+	m.setBody(otrState);
+	addMessage(m);
+	final int n = mRemoteListeners.beginBroadcast();
+
+	for (int i = 0; i < n; i++) {
+	    IMessageListener listener = mRemoteListeners.getBroadcastItem(i);
+	    try {
+		listener.otrStateChanged(otrState);
+	    } catch (RemoteException e) {
+		Log.w(TAG, e.getMessage());
+	    }
+	}
+	mRemoteListeners.finishBroadcast();
+    }
+
+    @Override
+    public void startOtrSession() throws RemoteException {
+	if (mOtrSessionId == null) {
+	    mOtrSessionId = new SessionID(mAccountUser, mParticipant.getJIDWithRes(), PROTOCOL);
+	    BeemOtrManager.getInstance().addChat(mOtrSessionId, this);
+	}
+
+	try {
+	    BeemOtrManager.getInstance().getOtrManager().startSession(mOtrSessionId);
+	} catch (OtrException e) {
+	    mOtrSessionId = null;
+	    e.printStackTrace();
+	    throw new RemoteException();
+	}
+    }
+
+    @Override
+    public void endOtrSession() throws RemoteException {
+	try {
+	    localEndOtrSession();
+	} catch (OtrException e) {
+	    e.printStackTrace();
+	    throw new RemoteException();
+	}
+    }
+
+    /**
+     * end an Otr session.
+     * @return false if something bad happened.
+     * @throws OtrException an exception from otr
+     */
+    public boolean localEndOtrSession() throws OtrException {
+	if (mOtrSessionId == null)
+	    return true;
+
+	BeemOtrManager.getInstance().getOtrManager().endSession(mOtrSessionId);
+	BeemOtrManager.getInstance().removeChat(mOtrSessionId);
+	mOtrSessionId = null;
+	listenOtrSession();
+	return true;
+    }
+
+    /**
+     * Start listenning to an OTR session.
+     */
+    public void listenOtrSession() {
+	if (mOtrSessionId != null)
+	    return;
+
+	mOtrSessionId = new SessionID(mAccountUser, mParticipant.getJIDWithRes(), PROTOCOL);
+	BeemOtrManager.getInstance().addChat(mOtrSessionId, this);
+	//OtrEngineImpl will make a call to "this.getSession(sessionID)" which will instantiate our session.
+	BeemOtrManager.getInstance().getOtrManager().getSessionStatus(mOtrSessionId);
+    }
+
+    @Override
+    public String getLocalOtrFingerprint() throws RemoteException {
+	if (mOtrSessionId == null)
+	    return null;
+
+	return BeemOtrManager.getInstance().getLocalFingerprint(mOtrSessionId);
+    }
+
+    @Override
+    public String getRemoteOtrFingerprint() throws RemoteException {
+	if (mOtrSessionId == null)
+	    return null;
+
+	return BeemOtrManager.getInstance().getRemoteFingerprint(mOtrSessionId);
+    }
+
+    @Override
+    public void verifyRemoteFingerprint(boolean ok) {
+	if (mOtrSessionId != null) {
+	    if (ok)
+		BeemOtrManager.getInstance().verifyRemoteFingerprint(mOtrSessionId);
+	    else
+		BeemOtrManager.getInstance().unverifyRemoteFingerprint(mOtrSessionId);
+	}
+    }
+
+    @Override
+    public String getOtrStatus() throws RemoteException {
+	if (mOtrSessionId == null)
+	    return null;
+	return BeemOtrManager.getInstance().getOtrManager().getSessionStatus(mOtrSessionId).toString();
+    }
+
+    @Override
+    public int getUnreadMessageCount() throws RemoteException {
+	return mUnreadMsgCount;
+    }
+
+    /**
+     * Listener.
+     */
+    private class MsgListener implements ChatStateListener {
+	/**
+	 * Constructor.
+	 */
+	public MsgListener() {
+	}
+
+	@Override
+	public void processMessage(Chat chat, org.jivesoftware.smack.packet.Message message) {
+	    Message msg = new Message(message);
+	    Log.d(TAG, "new msg " + msg.getBody());
+	    String body;
+
+	    if (mOtrSessionId != null) {
+		try {
+		    body = BeemOtrManager.getInstance().getOtrManager()
+			.transformReceiving(mOtrSessionId, msg.getBody());
+		    msg.setBody(body);
+		} catch (OtrException e) {
+		    Log.w(TAG, "Unable to decrypt OTR message", e);
+		}
+	    }
+	    //TODO add que les message pas de type errors
+	    ChatAdapter.this.addMessage(msg);
+	    final int n = mRemoteListeners.beginBroadcast();
+	    for (int i = 0; i < n; i++) {
+		IMessageListener listener = mRemoteListeners.getBroadcastItem(i);
+		try {
+		    if (listener != null)
+			listener.processMessage(ChatAdapter.this, msg);
+		} catch (RemoteException e) {
+		    Log.w(TAG, "Error while diffusing message to listener", e);
+		}
+	    }
+	    mRemoteListeners.finishBroadcast();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public void stateChanged(Chat chat, ChatState state) {
+	    mState = state.name();
+	    final int n = mRemoteListeners.beginBroadcast();
+
+	    for (int i = 0; i < n; i++) {
+		IMessageListener listener = mRemoteListeners.getBroadcastItem(i);
+		try {
+		    listener.stateChanged(ChatAdapter.this);
+		} catch (RemoteException e) {
+		    Log.w(TAG, e.getMessage());
+		}
+	    }
+	    mRemoteListeners.finishBroadcast();
+	}
+
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/java/com/beem/project/beem/service/Contact.java	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,461 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+package com.beem.project.beem.service;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.jivesoftware.smack.RosterGroup;
+import org.jivesoftware.smack.packet.Presence;
+import org.jivesoftware.smack.util.StringUtils;
+
+import android.net.Uri;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import com.beem.project.beem.utils.Status;
+
+/**
+ * This class contains informations on a jabber contact.
+ * @author darisk
+ */
+public class Contact implements Parcelable {
+
+    /** Parcelable.Creator needs by Android. */
+    public static final Parcelable.Creator<Contact> CREATOR = new Parcelable.Creator<Contact>() {
+
+	@Override
+	public Contact createFromParcel(Parcel source) {
+	    return new Contact(source);
+	}
+
+	@Override
+	public Contact[] newArray(int size) {
+	    return new Contact[size];
+	}
+    };
+
+    private int mID;
+    private int mStatus;
+    private final String mJID;
+    private String mSelectedRes;
+    private String mMsgState;
+    private List<String> mRes;
+    private final List<String> mGroups = new ArrayList<String>();
+    private String mName;
+    private String mAvatarId;
+
+    /**
+     * Construct a contact from a parcel.
+     * @param in parcel to use for construction
+     */
+    private Contact(final Parcel in) {
+	mID = in.readInt();
+	mStatus = in.readInt();
+	mJID = in.readString();
+	mSelectedRes = in.readString();
+	mName = in.readString();
+	mMsgState = in.readString();
+	mAvatarId = in.readString();
+	mRes = new ArrayList<String>();
+	in.readStringList(mRes);
+	in.readStringList(mGroups);
+    }
+
+    /**
+     * Constructor.
+     * @param jid JID of the contact
+     */
+    public Contact(final String jid) {
+	mJID = StringUtils.parseBareAddress(jid);
+	mName = mJID;
+	mStatus = Status.CONTACT_STATUS_DISCONNECT;
+	mMsgState = null;
+	mRes = new ArrayList<String>();
+	String res = StringUtils.parseResource(jid);
+	mSelectedRes = res;
+	if (!"".equals(res))
+	    mRes.add(res);
+    }
+
+    /**
+     * Create a contact from a Uri.
+     * @param uri an uri for the contact
+     * @throws IllegalArgumentException if it is not a xmpp uri
+     */
+    public Contact(final Uri uri) {
+	if (!"xmpp".equals(uri.getScheme()))
+	    throw new IllegalArgumentException();
+	String enduri = uri.getEncodedSchemeSpecificPart();
+	mJID = StringUtils.parseBareAddress(enduri);
+	mName = mJID;
+	mStatus = Status.CONTACT_STATUS_DISCONNECT;
+	mMsgState = null;
+	mRes = new ArrayList<String>();
+	String res = StringUtils.parseResource(enduri);
+	mSelectedRes = res;
+	mRes.add(res);
+    }
+
+    /**
+     * Make an xmpp uri for a spcific jid.
+     *
+     * @param jid the jid to represent as an uri
+     * @return an uri representing this jid.
+     */
+    public static Uri makeXmppUri(String jid) {
+	StringBuilder build = new StringBuilder("xmpp:");
+	String name = StringUtils.parseName(jid);
+	build.append(name);
+	if (!"".equals(name))
+	    build.append('@');
+	build.append(StringUtils.parseServer(jid));
+	String resource = StringUtils.parseResource(jid);
+	if (!"".equals(resource)) {
+	    build.append('/');
+	    build.append(resource);
+	}
+	Uri u = Uri.parse(build.toString());
+	return u;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+	dest.writeInt(mID);
+	dest.writeInt(mStatus);
+	dest.writeString(mJID);
+	dest.writeString(mSelectedRes);
+	dest.writeString(mName);
+	dest.writeString(mMsgState);
+	dest.writeString(mAvatarId);
+	dest.writeStringList(getMRes());
+	dest.writeStringList(getGroups());
+    }
+
+    /**
+     * Add a group for the contact.
+     * @param group the group
+     */
+    public void addGroup(String group) {
+	if (!mGroups.contains(group))
+	    mGroups.add(group);
+    }
+
+    /**
+     * Remove the contact from a group.
+     * @param group the group to delete the contact from.
+     */
+    public void delGroup(String group) {
+	mGroups.remove(group);
+    }
+
+    /**
+     * Add a resource for this contact.
+     * @param res the resource to add
+     */
+    public void addRes(String res) {
+	if (!mRes.contains(res))
+	    mRes.add(res);
+    }
+
+    /**
+     * Delete a resource for this contact.
+     * @param res the resource de delete
+     */
+    public void delRes(String res) {
+	mRes.remove(res);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public int describeContents() {
+	return 0;
+    }
+
+    /**
+     * Get the groups the contact is in.
+     * @return the mGroups
+     */
+    public List<String> getGroups() {
+	return mGroups;
+    }
+
+    /**
+     * Get the id of the contact on the phone contact list.
+     * @return the mID
+     */
+    public int getID() {
+	return mID;
+    }
+
+    /**
+     * Get the Jabber ID of the contact.
+     * @return the Jabber ID
+     */
+    public String getJID() {
+	return mJID;
+    }
+
+    /**
+     * Get selected resource.
+     * @return the selected resource.
+     */
+    public String getSelectedRes() {
+	return mSelectedRes;
+    }
+
+    /**
+     * Get the list of resource for the contact.
+     * @return the mRes
+     */
+    public List<String> getMRes() {
+	return mRes;
+    }
+
+    /**
+     * Get the message status of the contact.
+     * @return the message status of the contact.
+     */
+    public String getMsgState() {
+	return mMsgState;
+    }
+
+    /**
+     * Get the name of the contact.
+     * @return the mName
+     */
+    public String getName() {
+	return mName;
+    }
+
+    /**
+     * Get the status of the contact.
+     * @return the mStatus
+     */
+    public int getStatus() {
+	return mStatus;
+    }
+
+    /**
+     * Get the avatar id of the contact.
+     *
+     * @return the avatar id or null if there is not
+     */
+    public String getAvatarId() {
+	return mAvatarId;
+    }
+
+    /**
+     * Set the groups the contact is in.
+     * @param groups list of groups
+     */
+    public void setGroups(Collection<RosterGroup> groups) {
+	this.mGroups.clear();
+	for (RosterGroup rosterGroup : groups) {
+	    mGroups.add(rosterGroup.getName());
+	}
+    }
+
+    /**
+     * Set the groups the contact is in.
+     * @param groups the mGroups to set
+     */
+    public void setGroups(List<String> groups) {
+	mGroups.clear();
+	mGroups.addAll(groups);
+    }
+
+    /**
+     * set the id of te contact on the phone contact list.
+     * @param mid the mID to set
+     */
+    public void setID(int mid) {
+	mID = mid;
+    }
+
+    /**
+     * Set the avatar id of the contact.
+     *
+     * @param avatarId the avatar id
+     */
+    public void setAvatarId(String avatarId) {
+	mAvatarId = avatarId;
+    }
+
+    /**
+     * Set the resource of the contact.
+     * @param resource to set.
+     */
+    public void setSelectedRes(String resource) {
+	mSelectedRes = resource;
+    }
+
+    /**
+     * Set a list of resource for the contact.
+     * @param mRes the mRes to set
+     */
+    public void setMRes(List<String> mRes) {
+	this.mRes = mRes;
+    }
+
+    /**
+     * Set the message status of the contact.
+     * @param msgState the message status of the contact to set
+     */
+    public void setMsgState(String msgState) {
+	mMsgState = msgState;
+    }
+
+    /**
+     * Set the name of the contact.
+     * @param name the mName to set
+     */
+    public void setName(String name) {
+	if (name == null || "".equals(name)) {
+	    this.mName = this.mJID;
+	    this.mName = StringUtils.parseName(this.mName);
+	    if (this.mName == null || "".equals(this.mName))
+		this.mName = this.mJID;
+	} else {
+	    this.mName = name;
+	}
+    }
+
+    /**
+     * Set the status of the contact.
+     * @param status the mStatus to set
+     */
+    public void setStatus(int status) {
+	mStatus = status;
+    }
+
+    /**
+     * Set the status of the contact using a presence packet.
+     * @param presence the presence containing status
+     */
+    public void setStatus(Presence presence) {
+	mStatus = Status.getStatusFromPresence(presence);
+	mMsgState = presence.getStatus();
+    }
+
+    /**
+     * Set status for the contact.
+     * @param presence The presence packet which contains the status
+     */
+    public void setStatus(PresenceAdapter presence) {
+	mStatus = presence.getStatus();
+	mMsgState = presence.getStatusText();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String toString() {
+	if (mJID != null)
+	    return mJID + "/[" + mRes + "]";
+	return super.toString();
+    }
+
+    /**
+     * Get a URI to access the contact.
+     * @return the URI
+     */
+    public Uri toUri() {
+	return makeXmppUri(mJID);
+    }
+
+    /**
+     * Get a URI to access the specific contact on this resource.
+     * @param resource the resource of the contact
+     * @return the URI
+     */
+    public Uri toUri(String resource) {
+	StringBuilder build = new StringBuilder("xmpp:");
+	String name = StringUtils.parseName(mJID);
+	build.append(name);
+	if (!"".equals(name))
+	    build.append('@');
+	build.append(StringUtils.parseServer(mJID));
+	if (!"".equals(resource)) {
+	    build.append('/');
+	    build.append(resource);
+	}
+	Uri u = Uri.parse(build.toString());
+	return u;
+    }
+
+    /**
+     * Get a JID to access the specific contact on this resource.
+     * @return the JID.
+     */
+    public String getJIDWithRes() {
+	StringBuilder build = new StringBuilder(mJID);
+	if (!"".equals(mSelectedRes))
+	    build.append('/').append(mSelectedRes);
+	return build.toString();
+    }
+
+    @Override
+    public boolean equals(Object other) {
+	if (!(other instanceof Contact))
+	    return false;
+	if (other == this)
+	    return true;
+	Contact c = (Contact) other;
+	return c.getJID().equals(getJID());
+    }
+
+    @Override
+    public int hashCode() {
+	return mJID.hashCode();
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/java/com/beem/project/beem/service/LoginAsyncTask.java	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,134 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+package com.beem.project.beem.service;
+
+import android.os.AsyncTask;
+import android.os.RemoteException;
+import android.util.Log;
+import com.beem.project.beem.service.aidl.IXmppConnection;
+import com.beem.project.beem.service.aidl.IXmppFacade;
+
+/**
+ * This is an asynchronous task that will launch a connection to the XMPP server.
+ * @see android.os.AsyncTask
+ * @author Da Risk <da_risk@elyzion.net>
+ */
+public class LoginAsyncTask extends AsyncTask<IXmppFacade, Integer, Boolean> {
+
+    /**
+     * State of a running connection.
+     */
+    public static final int STATE_CONNECTION_RUNNING = 0;
+    /**
+     * State of an already connected connection but authentication is running.
+     */
+    public static final int STATE_LOGIN_RUNNING = 1;
+    /**
+     * State of a connected and authenticated succesfully.
+     */
+    public static final int STATE_LOGIN_SUCCESS = 2;
+    /**
+     * State of a connected but failed authentication.
+     */
+    public static final int STATE_LOGIN_FAILED = 3;
+
+    private static final String TAG = "BeemLoginTask";
+
+    private IXmppConnection mConnection;
+    private String mErrorMessage;
+
+    /**
+     * Constructor.
+     */
+    public LoginAsyncTask() {
+    }
+
+    @Override
+    protected Boolean doInBackground(IXmppFacade... params) {
+	boolean result = true;
+	IXmppFacade facade = params[0];
+	try {
+	    publishProgress(STATE_CONNECTION_RUNNING);
+	    mConnection = facade.createConnection();
+	    if (!mConnection.connect()) {
+		mErrorMessage = mConnection.getErrorMessage();
+		return false;
+	    }
+	    publishProgress(STATE_LOGIN_RUNNING);
+
+	    if (!mConnection.login()) {
+		mErrorMessage = mConnection.getErrorMessage();
+		publishProgress(STATE_LOGIN_FAILED);
+		return false;
+	    }
+	    publishProgress(STATE_LOGIN_SUCCESS);
+	} catch (RemoteException e) {
+	    mErrorMessage = "Exception during connection :" + e;
+	    result = false;
+	}
+	return result;
+    }
+
+    /**
+     * Make sur to call the parent method when overriding this method.
+     */
+    @Override
+    protected void onCancelled() {
+	try {
+	    if (mConnection != null && mConnection.isAuthentificated()) {
+		mConnection.disconnect();
+	    }
+	} catch (RemoteException e) {
+	    Log.d(TAG, "Remote exception", e);
+	}
+    }
+
+    /**
+     * Get the error Message.
+     * @return the error message. null if no error
+     */
+    public String getErrorMessage() {
+	return mErrorMessage;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/java/com/beem/project/beem/service/Message.java	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,322 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+package com.beem.project.beem.service;
+
+import org.jivesoftware.smack.packet.XMPPError;
+import org.jivesoftware.smackx.packet.DelayInformation;
+import org.jivesoftware.smack.packet.PacketExtension;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+import java.util.Date;
+
+/**
+ * This class represents a instant message.
+ * @author darisk
+ */
+public class Message implements Parcelable {
+
+    /** Normal message type. Theese messages are like an email, with subject. */
+    public static final int MSG_TYPE_NORMAL = 100;
+
+    /** Chat message type. */
+    public static final int MSG_TYPE_CHAT = 200;
+
+    /** Group chat message type. */
+    public static final int MSG_TYPE_GROUP_CHAT = 300;
+
+    /** 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<Message> CREATOR = new Parcelable.Creator<Message>() {
+
+	@Override
+	public Message createFromParcel(Parcel source) {
+	    return new Message(source);
+	}
+
+	@Override
+	public Message[] newArray(int size) {
+	    return new Message[size];
+	}
+    };
+
+    private int mType;
+    private String mBody;
+    private String mSubject;
+    private String mTo;
+    private String mFrom;
+    private String mThread;
+    private Date mTimestamp;
+
+    // TODO ajouter l'erreur
+
+    /**
+     * Constructor.
+     * @param to the destinataire of the message
+     * @param type the message type
+     */
+    public Message(final String to, final int type) {
+	mTo = to;
+	mType = type;
+	mBody = "";
+	mSubject = "";
+	mThread = "";
+	mFrom = null;
+	mTimestamp = new Date();
+    }
+
+    /**
+     * Constructor a message of type chat.
+     * @param to the destinataire of the message
+     */
+    public Message(final String to) {
+	this(to, MSG_TYPE_CHAT);
+    }
+
+    /**
+     * Construct a message from a smack message packet.
+     * @param smackMsg Smack message packet
+     */
+    public Message(final org.jivesoftware.smack.packet.Message smackMsg) {
+	this(smackMsg.getTo());
+	switch (smackMsg.getType()) {
+	    case chat:
+		mType = MSG_TYPE_CHAT;
+		break;
+	    case groupchat:
+		mType = MSG_TYPE_GROUP_CHAT;
+		break;
+	    case normal:
+		mType = MSG_TYPE_NORMAL;
+		break;
+	    // TODO gerer les message de type error
+	    // this a little work around waiting for a better handling of error
+	    // messages
+	    case error:
+		mType = MSG_TYPE_ERROR;
+		break;
+	    default:
+		mType = MSG_TYPE_NORMAL;
+		break;
+	}
+	this.mFrom = smackMsg.getFrom();
+	//TODO better handling of error messages
+	if (mType == MSG_TYPE_ERROR) {
+	    XMPPError er = smackMsg.getError();
+	    String msg = er.getMessage();
+	    if (msg != null)
+		mBody = msg;
+	    else
+		mBody = er.getCondition();
+	} else {
+	    mBody = smackMsg.getBody();
+	    mSubject = smackMsg.getSubject();
+	    mThread = smackMsg.getThread();
+	}
+	PacketExtension pTime = smackMsg.getExtension("delay", "urn:xmpp:delay");
+	if (pTime instanceof DelayInformation) {
+	    mTimestamp = ((DelayInformation) pTime).getStamp();
+	} else {
+	    mTimestamp = new Date();
+	}
+    }
+
+    /**
+     * Construct a message from a parcel.
+     * @param in parcel to use for construction
+     */
+    private Message(final Parcel in) {
+	mType = in.readInt();
+	mTo = in.readString();
+	mBody = in.readString();
+	mSubject = in.readString();
+	mThread = in.readString();
+	mFrom = in.readString();
+	mTimestamp = new Date(in.readLong());
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+	// TODO Auto-generated method stub
+	dest.writeInt(mType);
+	dest.writeString(mTo);
+	dest.writeString(mBody);
+	dest.writeString(mSubject);
+	dest.writeString(mThread);
+	dest.writeString(mFrom);
+	dest.writeLong(mTimestamp.getTime());
+    }
+
+    /**
+     * Get the type of the message.
+     * @return the type of the message.
+     */
+    public int getType() {
+	return mType;
+    }
+
+    /**
+     * Set the type of the message.
+     * @param type the type to set
+     */
+    public void setType(int type) {
+	mType = type;
+    }
+
+    /**
+     * Get the body of the message.
+     * @return the Body of the message
+     */
+    public String getBody() {
+	return mBody;
+    }
+
+    /**
+     * Set the body of the message.
+     * @param body the body to set
+     */
+    public void setBody(String body) {
+	mBody = body;
+    }
+
+    /**
+     * Get the subject of the message.
+     * @return the subject
+     */
+    public String getSubject() {
+	return mSubject;
+    }
+
+    /**
+     * Set the subject of the message.
+     * @param subject the subject to set
+     */
+    public void setSubject(String subject) {
+	mSubject = subject;
+    }
+
+    /**
+     * Get the destinataire of the message.
+     * @return the destinataire of the message
+     */
+    public String getTo() {
+	return mTo;
+    }
+
+    /**
+     * Set the destinataire of the message.
+     * @param to the destinataire to set
+     */
+    public void setTo(String to) {
+	mTo = to;
+    }
+
+    /**
+     * Set the from field of the message.
+     * @param from the mFrom to set
+     */
+    public void setFrom(String from) {
+	this.mFrom = from;
+    }
+
+    /**
+     * Get the from field of the message.
+     * @return the mFrom
+     */
+    public String getFrom() {
+	return mFrom;
+    }
+
+    /**
+     * Get the thread of the message.
+     * @return the thread
+     */
+    public String getThread() {
+	return mThread;
+    }
+
+    /**
+     * Set the thread of the message.
+     * @param thread the thread to set
+     */
+    public void setThread(String thread) {
+	mThread = thread;
+    }
+
+    /**
+     * Set the Date of the message.
+     *
+     * @param date date of the message.
+     */
+    public void setTimestamp(Date date) {
+	mTimestamp = date;
+    }
+
+    /**
+     * Get the Date of the message.
+     *
+     * @return if it is a delayed message get the date the message was sended.
+     */
+    public Date getTimestamp() {
+	return mTimestamp;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public int describeContents() {
+	// TODO Auto-generated method stub
+	return 0;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/java/com/beem/project/beem/service/PresenceAdapter.java	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,204 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+package com.beem.project.beem.service;
+
+import org.jivesoftware.smack.packet.Presence;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import com.beem.project.beem.utils.PresenceType;
+import com.beem.project.beem.utils.Status;
+
+/**
+ * this class contain contact presence informations.
+ * @author nikita
+ */
+public class PresenceAdapter implements Parcelable {
+
+    /** Parcelable.Creator needs by Android. */
+    public static final Parcelable.Creator<PresenceAdapter> CREATOR = new Parcelable.Creator<PresenceAdapter>() {
+
+	@Override
+	public PresenceAdapter createFromParcel(Parcel source) {
+	    return new PresenceAdapter(source);
+	}
+
+	@Override
+	public PresenceAdapter[] newArray(int size) {
+	    return new PresenceAdapter[size];
+	}
+    };
+
+    private int mType;
+    private int mStatus;
+    private String mTo;
+    private String mFrom;
+    private String mStatusText;
+
+    /**
+     * constructor from Parcel.
+     * @param source parcelable presence.
+     */
+    public PresenceAdapter(final Parcel source) {
+	mType = source.readInt();
+	mStatus = source.readInt();
+	mTo = source.readString();
+	mFrom = source.readString();
+	mStatusText = source.readString();
+    }
+
+    /**
+     * constructor from smack Presence.
+     * @param presence smack presence.
+     */
+    public PresenceAdapter(final Presence presence) {
+	mType = PresenceType.getPresenceType(presence);
+	mStatus = Status.getStatusFromPresence(presence);
+	mTo = presence.getTo();
+	mFrom = presence.getFrom();
+	mStatusText = presence.getStatus();
+    }
+
+    /* (non-Javadoc)
+     * @see android.os.Parcelable#describeContents()
+     */
+    @Override
+    public int describeContents() {
+	// TODO Auto-generated method stub
+	return 0;
+    }
+
+    /**
+     * mFrom getter.
+     * @return the mFrom
+     */
+    public String getFrom() {
+	return mFrom;
+    }
+
+    /**
+     * mStatus getter.
+     * @return the mStatus
+     */
+    public int getStatus() {
+	return mStatus;
+    }
+
+    /**
+     * mStatusText getter.
+     * @return the mStatusText
+     */
+    public String getStatusText() {
+	return mStatusText;
+    }
+
+    /**
+     * mTo getter.
+     * @return the mTo
+     */
+    public String getTo() {
+	return mTo;
+    }
+
+    /**
+     * mType getter.
+     * @return the mType
+     */
+    public int getType() {
+	return mType;
+    }
+
+    /**
+     * mFrom setter.
+     * @param from the mFrom to set
+     */
+    public void setFrom(final String from) {
+	this.mFrom = from;
+    }
+
+    /**
+     * mStatus setter.
+     * @param status the mStatus to set
+     */
+    public void setStatus(final int status) {
+	this.mStatus = status;
+    }
+
+    /**
+     * mStatusText setter.
+     * @param statusText the mStatusText to set
+     */
+    public void setStatusText(final String statusText) {
+	this.mStatusText = statusText;
+    }
+
+    /**
+     * mTo setter.
+     * @param to the mTo to set
+     */
+    public void setTo(final String to) {
+	this.mTo = to;
+    }
+
+    /**
+     * mType setter.
+     * @param type the type to set
+     */
+    public void setType(int type) {
+	this.mType = type;
+    }
+
+    /* (non-Javadoc)
+     * @see android.os.Parcelable#writeToParcel(android.os.Parcel, int)
+     */
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+	dest.writeInt(mType);
+	dest.writeInt(mStatus);
+	dest.writeString(mTo);
+	dest.writeString(mFrom);
+	dest.writeString(mStatusText);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/java/com/beem/project/beem/service/PrivacyListItem.java	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,153 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+package com.beem.project.beem.service;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * A simplified version of the Smack PrivacyItem class.
+ * @author Jean-Manuel Da Silva <dasilvj at beem-project dot com>
+ */
+public class PrivacyListItem implements Parcelable {
+
+    /**
+     * Constructor. Needed to implements the Parcelable.Creator interface. Generates instances of PrivacyListItem from a
+     * Parcel.
+     */
+    public static final Parcelable.Creator<PrivacyListItem> CREATOR = new Parcelable.Creator<PrivacyListItem>() {
+	public PrivacyListItem createFromParcel(Parcel in) {
+	    return new PrivacyListItem(in);
+	}
+
+	public PrivacyListItem[] newArray(int size) {
+	    return new PrivacyListItem[size];
+	}
+    };
+
+    private int mType;
+    private String mValue;
+
+    /**
+     * Constructor.
+     */
+    public PrivacyListItem() {
+    }
+
+    /**
+     * Constructor. Generates instances of PrivacyListItem from a Parcel.
+     * @param in The Parcel used to initialize object's attributes.
+     */
+    public PrivacyListItem(final Parcel in) {
+	readFromParcel(in);
+    }
+
+    /**
+     * Constructor.
+     * @param type The type of the item.
+     * @param value The value of the item.
+     */
+    public PrivacyListItem(final int type, final String value) {
+	mType = type;
+	mValue = value;
+    }
+
+    /**
+     * {@inheritDoc}.
+     */
+    @Override
+    public int describeContents() {
+	return 0;
+    }
+
+    /**
+     * Initialize object's attributes from a Parcel.
+     * @param in The Parcel used to initialize object's attributes.
+     */
+    public void readFromParcel(Parcel in) {
+	mType = in.readInt();
+	mValue = in.readString();
+    }
+
+    /**
+     * {@inheritDoc}.
+     */
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+	dest.writeInt(mType);
+	dest.writeString(mValue);
+    }
+
+    /**
+     * PrivacyListItem type accessor.
+     * @return The type of the PrivacyListItem.
+     */
+    public int getType() {
+	return mType;
+    }
+
+    /**
+     * PrivacyListItem value accessor.
+     * @return The value of the PrivacyListItem.
+     */
+    public String getValue() {
+	return mValue;
+    }
+
+    /**
+     * PrivacyListItem type mutator.
+     * @param type The type of the PrivacyListItem.
+     */
+    public void setType(final int type) {
+	mType = type;
+    }
+
+    /**
+     * PrivacyListItem value mutator.
+     * @param value The value of the PrivacyListItem.
+     */
+    public void setValue(final String value) {
+	mValue = value;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/java/com/beem/project/beem/service/PrivacyListManagerAdapter.java	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,358 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+package com.beem.project.beem.service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jivesoftware.smack.PrivacyList;
+import org.jivesoftware.smack.PrivacyListListener;
+import org.jivesoftware.smack.PrivacyListManager;
+import org.jivesoftware.smack.XMPPException;
+import org.jivesoftware.smack.packet.PrivacyItem;
+import org.jivesoftware.smack.packet.PrivacyItem.PrivacyRule;
+
+import android.os.RemoteCallbackList;
+import android.os.RemoteException;
+import android.util.Log;
+
+import com.beem.project.beem.service.aidl.IPrivacyListListener;
+import com.beem.project.beem.service.aidl.IPrivacyListManager;
+
+/**
+ * An adapter for the Smack's PrivacyListManager.
+ * @author Jean-Manuel Da Silva <dasilvj at beem-project dot com>
+ */
+public class PrivacyListManagerAdapter extends IPrivacyListManager.Stub {
+
+    /** Class's Tag. */
+    public static final String TAG = "PrivacyListManagerAdapter";
+
+    private final PrivacyListManager mPrivacyListManager;
+
+    private final RemoteCallbackList<IPrivacyListListener> mPrivacyListListeners =
+	new RemoteCallbackList<IPrivacyListListener>();
+    private final PrivacyListListenerAdapter mPrivacyListListener = new PrivacyListListenerAdapter();
+
+    /**
+     * Constructor.
+     * @param privacyListManager the privacy list manager
+     */
+    public PrivacyListManagerAdapter(final PrivacyListManager privacyListManager) {
+	mPrivacyListManager = privacyListManager;
+	mPrivacyListManager.addListener(mPrivacyListListener);
+    }
+
+    /* (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)
+     * @see com.beem.project.beem.service.aidl.IPrivacyListManager#createPrivacyList(java.lang.String, java.util.List)
+     */
+    @Override
+    public void createPrivacyList(String listName, List<PrivacyListItem> items) throws RemoteException {
+	Log.d(TAG, "BEGIN createPrivacyList.");
+	try {
+	    List<PrivacyItem> privacyItems = new ArrayList<PrivacyItem>();
+
+	    PrivacyItem item = new PrivacyItem(PrivacyItem.Type.subscription.name(), true, 2);
+	    item.setValue(PrivacyRule.SUBSCRIPTION_BOTH);
+	    privacyItems.add(item);
+
+	    mPrivacyListManager.createPrivacyList(listName, privacyItems);
+	} catch (XMPPException e) {
+	    Log.e(TAG, e.getMessage());
+	}
+	Log.d(TAG, "END createPrivacyList.");
+    }
+
+    /* (non-Javadoc)
+     * @see com.beem.project.beem.service.aidl.IPrivacyListManager#declineActivePrivacyList()
+     */
+    @Override
+    public void declineActivePrivacyList() throws RemoteException {
+	try {
+	    mPrivacyListManager.declineActiveList();
+	} catch (XMPPException e) {
+	    Log.e(TAG, e.getMessage());
+	}
+    }
+
+    /* (non-Javadoc)
+     * @see com.beem.project.beem.service.aidl.IPrivacyListManager#declineDefaultPrivacyList()
+     */
+    @Override
+    public void declineDefaultPrivacyList() throws RemoteException {
+	try {
+	    mPrivacyListManager.declineDefaultList();
+	} catch (XMPPException e) {
+	    Log.e(TAG, e.getMessage());
+	}
+    }
+
+    /* (non-Javadoc)
+     * @see com.beem.project.beem.service.aidl.IPrivacyListManager#editPrivacyList(java.lang.String, java.util.List)
+     */
+    @Override
+    public void editPrivacyList(String listName, List<PrivacyListItem> items) throws RemoteException {
+	Log.d(TAG, "BEGIN editPrivacyList.");
+	try {
+	    mPrivacyListManager.updatePrivacyList(listName, tranformPrivacyListItemsToPrivacyItems(items));
+	} catch (XMPPException e) {
+	    Log.e(TAG, e.getMessage());
+	}
+	Log.d(TAG, "END editPrivacyList.");
+    }
+
+    /* (non-Javadoc)
+     * @see com.beem.project.beem.service.aidl.IPrivacyListManager#getActivePrivacyList()
+     */
+    @Override
+    public String getActivePrivacyList() throws RemoteException {
+	try {
+	    PrivacyList activePrivacyList = mPrivacyListManager.getActiveList();
+	    return activePrivacyList.toString();
+	} catch (XMPPException e) {
+	    Log.e(TAG, e.getMessage());
+	}
+	return null;
+    }
+
+    /* (non-Javadoc)
+     * @see com.beem.project.beem.service.aidl.IPrivacyListManager#getBlockedGroupsByList(java.lang.String)
+     */
+    @Override
+    public List<String> getBlockedGroupsByList(String listName) throws RemoteException {
+	List<String> blockedGroups = new ArrayList<String>();
+	try {
+	    PrivacyList pL = mPrivacyListManager.getPrivacyList(listName);
+	    for (PrivacyItem pI : pL.getItems()) {
+		if (pI.getType().equals(PrivacyItem.Type.group) && !pI.isAllow())
+		    blockedGroups.add(pI.getValue());
+	    }
+	} catch (XMPPException e) {
+	    Log.e(TAG, e.getMessage());
+	}
+	return blockedGroups;
+    }
+
+    /* (non-Javadoc)
+     * @see com.beem.project.beem.service.aidl.IPrivacyListManager#getBlockedUsersByList(java.lang.String)
+     */
+    @Override
+    public List<String> getBlockedUsersByList(String listName) throws RemoteException {
+	List<String> blockedUsers = new ArrayList<String>();
+	try {
+	    PrivacyList pL = mPrivacyListManager.getPrivacyList(listName);
+	    for (PrivacyItem pI : pL.getItems()) {
+		if (pI.getType().equals(PrivacyItem.Type.jid) && !pI.isAllow())
+		    blockedUsers.add(pI.getValue());
+	    }
+	} catch (XMPPException e) {
+	    Log.e(TAG, e.getMessage());
+	}
+	return blockedUsers;
+    }
+
+    /* (non-Javadoc)
+     * @see com.beem.project.beem.service.aidl.IPrivacyListManager#getDefaultPrivacyList()
+     */
+    @Override
+    public String getDefaultPrivacyList() throws RemoteException {
+	try {
+	    PrivacyList defaultPrivacyList = mPrivacyListManager.getDefaultList();
+	    return defaultPrivacyList.toString();
+	} catch (XMPPException e) {
+	    Log.e(TAG, e.getMessage());
+	}
+	return null;
+    }
+
+    /* (non-Javadoc)
+     * @see com.beem.project.beem.service.aidl.IPrivacyListManager#removePrivacyList(java.lang.String)
+     */
+    @Override
+    public void removePrivacyList(String listName) throws RemoteException {
+	try {
+	    mPrivacyListManager.deletePrivacyList(listName);
+	} catch (XMPPException e) {
+	    Log.e(TAG, e.getMessage());
+	}
+    }
+
+    /* (non-Javadoc)
+     * @see com.beem.project.beem.service.aidl.IPrivacyListManager#setActivePrivacyList(java.lang.String)
+     */
+    @Override
+    public void setActivePrivacyList(String listName) throws RemoteException {
+	try {
+	    mPrivacyListManager.setActiveListName(listName);
+	} catch (XMPPException e) {
+	    Log.e(TAG, e.getMessage());
+	}
+    }
+
+    /* (non-Javadoc)
+     * @see com.beem.project.beem.service.aidl.IPrivacyListManager#setDefaultPrivacyList(java.lang.String)
+     */
+    @Override
+    public void setDefaultPrivacyList(String listName) throws RemoteException {
+	try {
+	    mPrivacyListManager.setDefaultListName(listName);
+	} catch (XMPPException e) {
+	    Log.e(TAG, e.getMessage());
+	}
+    }
+
+    /**
+     * From a List of PrivacyListItem get a List of PrivacyItem.
+     * @param items The List of PrivacyListItem.
+     * @return A list of PrivacyItem.
+     */
+    private List<PrivacyItem> tranformPrivacyListItemsToPrivacyItems(List<PrivacyListItem> items) {
+	List<PrivacyItem> rItems = new ArrayList<PrivacyItem>();
+	PrivacyItem.Type[] itemTypes = PrivacyItem.Type.values();
+
+	for (int i = 0; i < items.size(); i++) {
+	    rItems.add(new PrivacyItem(itemTypes[items.get(i).getType()].name(), false, i));
+	}
+
+	return rItems;
+    }
+
+    /**
+     * From a List of PrivacyItem get a List of PrivacyListItem.
+     * @param items The List of PrivacyItem.
+     * @return A list of PrivacyListItem.
+     */
+    private List<PrivacyListItem> tranformPrivacyItemsToPrivacyListItems(List<PrivacyItem> items) {
+	List<PrivacyListItem> rItems = new ArrayList<PrivacyListItem>();
+
+	for (int i = 0; i < items.size(); i++) {
+	    rItems.add(new PrivacyListItem(items.get(i).getType().ordinal(), items.get(i).getValue()));
+	}
+	return rItems;
+    }
+
+    /**
+     * An adapter for the Smack's PrivacyListListener.
+     * @author Jean-Manuel Da Silva <dasilvj at beem-project dot com>
+     */
+    private class PrivacyListListenerAdapter implements PrivacyListListener {
+	/**
+	 * Constructor.
+	 */
+	public PrivacyListListenerAdapter() { }
+
+	@Override
+	public void setPrivacyList(final String listName, final List<PrivacyItem> listItem) {
+	    int i = mPrivacyListListeners.beginBroadcast();
+	    while (i > 0) {
+		i--;
+		try {
+		    mPrivacyListListeners.getBroadcastItem(i).setPrivacyList(listName,
+			tranformPrivacyItemsToPrivacyListItems(listItem));
+		} catch (RemoteException e) {
+		    Log.w(TAG, e.getMessage());
+		}
+	    }
+	    mPrivacyListListeners.finishBroadcast();
+	}
+
+	@Override
+	public void updatedPrivacyList(final String listName) {
+	    Log.d(TAG, "BEGIN updatedPrivacyList.");
+	    int i = mPrivacyListListeners.beginBroadcast();
+	    while (i > 0) {
+		i--;
+		try {
+		    mPrivacyListListeners.getBroadcastItem(i).updatedPrivacyList(listName);
+		} catch (RemoteException e) {
+		    Log.w(TAG, e.getMessage());
+		}
+	    }
+	    mPrivacyListListeners.finishBroadcast();
+	    Log.d(TAG, "END updatedPrivacyList.");
+	}
+    }
+
+    @Override
+    public void addPrivacyListListener(IPrivacyListListener listener) throws RemoteException {
+	if (listener != null)
+	    mPrivacyListListeners.register(listener);
+    }
+
+    @Override
+    public void removePrivacyListListener(IPrivacyListListener listener) throws RemoteException {
+	if (listener != null)
+	    mPrivacyListListeners.unregister(listener);
+    }
+
+    /* (non-Javadoc)
+     * @see com.beem.project.beem.service.aidl.IPrivacyListManager#getPrivacyLists()
+     */
+    @Override
+    public List<String> getPrivacyLists() throws RemoteException {
+	Log.d(TAG, "BEGIN getPrivacyLists.");
+	List<String> res = new ArrayList<String>();
+	try {
+	    PrivacyList[] registeredPrivacyLists = mPrivacyListManager.getPrivacyLists();
+	    Log.d(TAG, "> registeredPrivacyLists size: " + registeredPrivacyLists.length);
+	    if (registeredPrivacyLists.length > 0) {
+		for (int i = 0; i < registeredPrivacyLists.length; i++) {
+		    res.add(registeredPrivacyLists[i].toString());
+		    Log.d(TAG, "> " + res.get(i) + " added.");
+		}
+	    }
+	} catch (XMPPException e) {
+	    Log.e(TAG, e.getMessage());
+	}
+	Log.d(TAG, "END getPrivacyLists.");
+	return res;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/java/com/beem/project/beem/service/RosterAdapter.java	Sun Mar 15 18:03:03 2015 +0100
@@ -0,0 +1,416 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+*/
+package com.beem.project.beem.service;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import android.content.Context;
+import android.os.RemoteCallbackList;
+import android.os.RemoteException;
+import android.util.Log;
+
+import com.beem.project.beem.R;
+import com.beem.project.beem.service.aidl.IBeemRosterListener;
+import com.beem.project.beem.smack.avatar.AvatarListener;
+import com.beem.project.beem.smack.avatar.AvatarManager;
+import com.beem.project.beem.smack.avatar.AvatarMetadataExtension.Info;
+import com.beem.project.beem.utils.Status;
+
+import org.jivesoftware.smack.Roster;
+import org.jivesoftware.smack.RosterEntry;
+import org.jivesoftware.smack.RosterGroup;
+import org.jivesoftware.smack.RosterListener;
+import org.jivesoftware.smack.XMPPException;
+import org.jivesoftware.smack.packet.Presence;
+import org.jivesoftware.smack.util.StringUtils;
+
+
+/**
+ * This class implement a Roster adapter for BEEM.
+ */
+public class RosterAdapter extends com.beem.project.beem.service.aidl.IRoster.Stub {
+
+    private static final String TAG = "RosterAdapter";
+    private final Roster mAdaptee;
+    private final RemoteCallbackList<IBeemRosterListener> mRemoteRosListeners =
+	new RemoteCallbackList<IBeemRosterListener>();
+    private final Map<Integer, String> mDefaultStatusMessages;
+    private final RosterListenerAdapter mRosterListener = new RosterListenerAdapter();
+    private Map<String, String> mAvatarIdmap = new HashMap<String, String>();
+    private AvatarManager mAvatarManager;
+
+    /**
+     * Constructor.
+     * @param roster The roster to adapt.
+     * @param context The context of the RosterAdapter.
+     */
+    public RosterAdapter(final Roster roster, final Context context) {
+	mAdaptee = roster;
+	roster.addRosterListener(mRosterListener);
+	mDefaultStatusMessages = createDefaultStatusMessagesMap(context);
+    }
+
+    /**
+     * Constructor.
+     * @param roster The roster to adapt.
+     * @param context The context of the RosterAdapter.
+     * @param avatarMgr The AvatarManager of the connection
+     */
+    public RosterAdapter(final Roster roster, final Context context, final AvatarManager avatarMgr) {
+	mAdaptee = roster;
+	roster.addRosterListener(mRosterListener);
+	mDefaultStatusMessages = createDefaultStatusMessagesMap(context);
+	mAvatarManager = avatarMgr;
+	if (mAvatarManager != null)
+	    mAvatarManager.addAvatarListener(new AvatarEventListener());
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void addRosterListener(IBeemRosterListener listen) throws RemoteException {
+	if (listen != null)
+	    mRemoteRosListeners.register(listen);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean addContact(String user, String name, String[] groups) throws RemoteException {
+	RosterEntry contact = mAdaptee.getEntry(user);
+	try {
+	    mAdaptee.createEntry(user, name, groups);
+	    contact = mAdaptee.getEntry(user);
+	} catch (XMPPException e) {
+	    Log.e(TAG, "Error while adding new contact", e);
+	    return false;
+	}
+	return true;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void deleteContact(Contact contact) throws RemoteException {
+	try {
+	    RosterEntry entry = mAdaptee.getEntry(contact.getJID());
+	    mAdaptee.removeEntry(entry);
+	} catch (XMPPException e) {
+	    e.printStackTrace();
+	}
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void createGroup(String groupname) throws RemoteException {
+	if (mAdaptee.getGroup(groupname) == null)
+	    mAdaptee.createGroup(groupname);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Contact getContact(String jid) throws RemoteException {
+	if (mAdaptee.contains(jid))
+	    return getContactFromRosterEntry(mAdaptee.getEntry(jid));
+	return null;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public List<Contact> getContactList() throws RemoteException {
+	boolean add = true;
+	Collection<RosterEntry> list = mAdaptee.getEntries();
+	List<Contact> coList = new ArrayList<Contact>(list.size());
+	for (RosterEntry entry : list) {
+	    coList.add(getContactFromRosterEntry(entry));
+	}
+	return coList;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public List<String> getGroupsNames() throws RemoteException {
+	Collection<RosterGroup> groups = mAdaptee.getGroups();
+	List<String> result = new ArrayList<String>(groups.size());
+	for (RosterGroup rosterGroup : groups) {
+	    result.add(rosterGroup.getName());
+	}
+	return result;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void removeRosterListener(IBeemRosterListener listen) throws RemoteException {
+	if (listen != null)
+	    mRemoteRosListeners.unregister(listen);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setContactName(String jid, String name) throws RemoteException {
+	mAdaptee.getEntry(jid).setName(name);
+    }
+
+    /* (non-Javadoc)
+     * @see com.beem.project.beem.service.aidl.IRoster#getPresence(java.lang.String)
+     */
+    @Override
+    public PresenceAdapter getPresence(String jid) throws RemoteException {
+	return new PresenceAdapter(mAdaptee.getPresence(jid));
+    }
+
+    /* (non-Javadoc)
+     * @see com.beem.project.beem.service.aidl.IRoster#addContactToGroup(java.lang.String, java.lang.String)
+     */
+    @Override
+    public void addContactToGroup(String groupName, String jid) throws RemoteException {
+	createGroup(groupName);
+	RosterGroup group = mAdaptee.getGroup(groupName);
+	try {
+	    group.addEntry(mAdaptee.getEntry(jid));
+	} catch (XMPPException e) {
+	    e.printStackTrace();
+	}
+    }
+
+    /* (non-Javadoc)
+     * @see com.beem.project.beem.service.aidl.IRoster#removeContactFromGroup(java.lang.String, java.lang.String)
+     */
+    @Override
+    public void removeContactFromGroup(String groupName, String jid) throws RemoteException {
+	RosterGroup group = mAdaptee.getGroup(groupName);
+	try {
+	    group.removeEntry(mAdaptee.getEntry(jid));
+	} catch (XMPPException e) {
+	    e.printStackTrace();
+	}
+    }
+
+    /**
+     * Get a contact from a RosterEntry.
+     * @param entry a roster entry containing information for the contact.
+     * @return a contact for this entry.
+     */
+    private Contact getContactFromRosterEntry(RosterEntry entry) {
+	String user = entry.getUser();
+	Contact c = new Contact(user);
+	Presence p = mAdaptee.getPresence(user);
+
+	if (p.getStatus() == null || "".equals(p.getStatus()))
+	    p.setStatus(mDefaultStatusMessages.get(Status.getStatusFromPresence(p)));
+	c.setStatus(p);
+	try {
+	    c.setGroups(entry.getGroups());
+	} catch (NullPointerException e) {
+	    Log.d(TAG, "Group list not ready", e);
+	}
+	Iterator<Presence> iPres = mAdaptee.getPresences(user);
+	while (iPres.hasNext()) {
+	    p = iPres.next();
+	    if (!p.getType().equals(Presence.Type.unavailable))
+		c.addRes(StringUtils.parseResource(p.getFrom()));
+	}
+	c.setName(entry.getName());
+	c.setAvatarId(mAvatarIdmap.get(user));
+	return c;
+    }
+
+    /**
+     * Create a map which contains default status messages.
+     * @param context The context of the roster adapter.
+     * @return A Map<Integer, String> which assigns a status to a message.
+     */
+    private Map<Integer, String> createDefaultStatusMessagesMap(Context context) {
+	Map<Integer, String> defaultStatusMessages = new HashMap<Integer, String>();
+	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_UNAVAILABLE, context.getString(R.string.contact_status_msg_xa));
+
+	return defaultStatusMessages;
+    }
+
+    /**
+     * Listener for the roster events. It will call the remote listeners registered.
+     * @author darisk
+     */
+    private class RosterListenerAdapter implements RosterListener {
+
+	/**
+	 * Constructor.
+	 */
+	public RosterListenerAdapter() {
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public void entriesAdded(Collection<String> addresses) {
+	    final int n = mRemoteRosListeners.beginBroadcast();
+
+	    List<String> tab = new ArrayList<String>();
+	    tab.addAll(addresses);
+	    for (int i = 0; i < n; i++) {
+		IBeemRosterListener listener = mRemoteRosListeners.getBroadcastItem(i);
+		try {
+		    listener.onEntriesAdded(tab);
+		} catch (RemoteException e) {
+		    Log.w(TAG, "Error while adding roster entries", e);
+		}
+	    }
+	    mRemoteRosListeners.finishBroadcast();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public void entriesDeleted(Collection<String> addresses) {
+	    final int n = mRemoteRosListeners.beginBroadcast();
+
+	    List<String> tab = new ArrayList<String>();
+	    tab.addAll(addresses);
+	    for (int i = 0; i < n; i++) {
+		IBeemRosterListener listener = mRemoteRosListeners.getBroadcastItem(i);
+		try {
+		    listener.onEntriesDeleted(tab);
+		} catch (RemoteException e) {
+		    Log.w(TAG, "Error while deleting roster entries", e);
+		}
+	    }
+	    mRemoteRosListeners.finishBroadcast();
+	}