diff --git a/app/src/androidTest/scala/com/nutomic/ensichat/protocol/CryptoTest.scala b/app/src/androidTest/scala/com/nutomic/ensichat/protocol/CryptoTest.scala index 7531843..b574628 100644 --- a/app/src/androidTest/scala/com/nutomic/ensichat/protocol/CryptoTest.scala +++ b/app/src/androidTest/scala/com/nutomic/ensichat/protocol/CryptoTest.scala @@ -1,7 +1,6 @@ package com.nutomic.ensichat.protocol import android.test.AndroidTestCase -import com.nutomic.ensichat.protocol.messages.MessageTest import junit.framework.Assert._ class CryptoTest extends AndroidTestCase { diff --git a/app/src/androidTest/scala/com/nutomic/ensichat/protocol/messages/MessageTest.scala b/app/src/androidTest/scala/com/nutomic/ensichat/protocol/MessageTest.scala similarity index 87% rename from app/src/androidTest/scala/com/nutomic/ensichat/protocol/messages/MessageTest.scala rename to app/src/androidTest/scala/com/nutomic/ensichat/protocol/MessageTest.scala index c696c48..710272b 100644 --- a/app/src/androidTest/scala/com/nutomic/ensichat/protocol/messages/MessageTest.scala +++ b/app/src/androidTest/scala/com/nutomic/ensichat/protocol/MessageTest.scala @@ -1,12 +1,13 @@ -package com.nutomic.ensichat.protocol.messages +package com.nutomic.ensichat.protocol import java.io.ByteArrayInputStream import java.util.GregorianCalendar import android.test.AndroidTestCase -import com.nutomic.ensichat.protocol.messages.ContentHeaderTest._ -import com.nutomic.ensichat.protocol.messages.MessageTest._ -import com.nutomic.ensichat.protocol.{AddressTest, Crypto} +import com.nutomic.ensichat.protocol.body.{ConnectionInfo, ConnectionInfoTest, Text} +import com.nutomic.ensichat.protocol.header.ContentHeaderTest._ +import com.nutomic.ensichat.protocol.MessageTest._ +import com.nutomic.ensichat.protocol.header.MessageHeader import junit.framework.Assert._ import scala.collection.immutable.TreeSet diff --git a/app/src/androidTest/scala/com/nutomic/ensichat/protocol/RouterTest.scala b/app/src/androidTest/scala/com/nutomic/ensichat/protocol/RouterTest.scala index b0e388f..56faf68 100644 --- a/app/src/androidTest/scala/com/nutomic/ensichat/protocol/RouterTest.scala +++ b/app/src/androidTest/scala/com/nutomic/ensichat/protocol/RouterTest.scala @@ -1,7 +1,8 @@ package com.nutomic.ensichat.protocol import android.test.AndroidTestCase -import com.nutomic.ensichat.protocol.messages._ +import com.nutomic.ensichat.protocol.body.UserName +import com.nutomic.ensichat.protocol.header.ContentHeader import junit.framework.Assert._ class RouterTest extends AndroidTestCase { diff --git a/app/src/androidTest/scala/com/nutomic/ensichat/protocol/messages/ConnectionInfoTest.scala b/app/src/androidTest/scala/com/nutomic/ensichat/protocol/body/ConnectionInfoTest.scala similarity index 93% rename from app/src/androidTest/scala/com/nutomic/ensichat/protocol/messages/ConnectionInfoTest.scala rename to app/src/androidTest/scala/com/nutomic/ensichat/protocol/body/ConnectionInfoTest.scala index 765690f..1cf5550 100644 --- a/app/src/androidTest/scala/com/nutomic/ensichat/protocol/messages/ConnectionInfoTest.scala +++ b/app/src/androidTest/scala/com/nutomic/ensichat/protocol/body/ConnectionInfoTest.scala @@ -1,4 +1,4 @@ -package com.nutomic.ensichat.protocol.messages +package com.nutomic.ensichat.protocol.body import android.content.Context import android.test.AndroidTestCase @@ -25,4 +25,4 @@ class ConnectionInfoTest extends AndroidTestCase { Assert.assertEquals(ci.key, body.asInstanceOf[ConnectionInfo].key) } -} \ No newline at end of file +} diff --git a/app/src/androidTest/scala/com/nutomic/ensichat/protocol/messages/ResultAddContactTest.scala b/app/src/androidTest/scala/com/nutomic/ensichat/protocol/body/ResultAddContactTest.scala similarity index 88% rename from app/src/androidTest/scala/com/nutomic/ensichat/protocol/messages/ResultAddContactTest.scala rename to app/src/androidTest/scala/com/nutomic/ensichat/protocol/body/ResultAddContactTest.scala index 30b2691..4e71241 100644 --- a/app/src/androidTest/scala/com/nutomic/ensichat/protocol/messages/ResultAddContactTest.scala +++ b/app/src/androidTest/scala/com/nutomic/ensichat/protocol/body/ResultAddContactTest.scala @@ -1,4 +1,4 @@ -package com.nutomic.ensichat.protocol.messages +package com.nutomic.ensichat.protocol.body import android.test.AndroidTestCase import junit.framework.Assert._ diff --git a/app/src/androidTest/scala/com/nutomic/ensichat/protocol/messages/UserNameTest.scala b/app/src/androidTest/scala/com/nutomic/ensichat/protocol/body/UserNameTest.scala similarity index 86% rename from app/src/androidTest/scala/com/nutomic/ensichat/protocol/messages/UserNameTest.scala rename to app/src/androidTest/scala/com/nutomic/ensichat/protocol/body/UserNameTest.scala index 1b9d035..bad2c9f 100644 --- a/app/src/androidTest/scala/com/nutomic/ensichat/protocol/messages/UserNameTest.scala +++ b/app/src/androidTest/scala/com/nutomic/ensichat/protocol/body/UserNameTest.scala @@ -1,4 +1,4 @@ -package com.nutomic.ensichat.protocol.messages +package com.nutomic.ensichat.protocol.body import android.test.AndroidTestCase import junit.framework.Assert @@ -12,4 +12,4 @@ class UserNameTest extends AndroidTestCase { Assert.assertEquals(name, body.asInstanceOf[UserName]) } -} \ No newline at end of file +} diff --git a/app/src/androidTest/scala/com/nutomic/ensichat/protocol/messages/ContentHeaderTest.scala b/app/src/androidTest/scala/com/nutomic/ensichat/protocol/header/ContentHeaderTest.scala similarity index 92% rename from app/src/androidTest/scala/com/nutomic/ensichat/protocol/messages/ContentHeaderTest.scala rename to app/src/androidTest/scala/com/nutomic/ensichat/protocol/header/ContentHeaderTest.scala index 59977b4..276bbbd 100644 --- a/app/src/androidTest/scala/com/nutomic/ensichat/protocol/messages/ContentHeaderTest.scala +++ b/app/src/androidTest/scala/com/nutomic/ensichat/protocol/header/ContentHeaderTest.scala @@ -1,6 +1,7 @@ -package com.nutomic.ensichat.protocol.messages +package com.nutomic.ensichat.protocol.header import android.test.AndroidTestCase +import com.nutomic.ensichat.protocol.body.Text import com.nutomic.ensichat.protocol.{Address, AddressTest} import junit.framework.Assert._ diff --git a/app/src/androidTest/scala/com/nutomic/ensichat/protocol/messages/MessageHeaderTest.scala b/app/src/androidTest/scala/com/nutomic/ensichat/protocol/header/MessageHeaderTest.scala similarity index 87% rename from app/src/androidTest/scala/com/nutomic/ensichat/protocol/messages/MessageHeaderTest.scala rename to app/src/androidTest/scala/com/nutomic/ensichat/protocol/header/MessageHeaderTest.scala index 6b5f909..40295ac 100644 --- a/app/src/androidTest/scala/com/nutomic/ensichat/protocol/messages/MessageHeaderTest.scala +++ b/app/src/androidTest/scala/com/nutomic/ensichat/protocol/header/MessageHeaderTest.scala @@ -1,7 +1,7 @@ -package com.nutomic.ensichat.protocol.messages +package com.nutomic.ensichat.protocol.header import android.test.AndroidTestCase -import com.nutomic.ensichat.protocol.messages.MessageHeaderTest._ +import com.nutomic.ensichat.protocol.header.MessageHeaderTest._ import com.nutomic.ensichat.protocol.{Address, AddressTest} import junit.framework.Assert._ diff --git a/app/src/androidTest/scala/com/nutomic/ensichat/util/AddContactsHandlerTest.scala b/app/src/androidTest/scala/com/nutomic/ensichat/util/AddContactsHandlerTest.scala index 92efac3..4427a8e 100644 --- a/app/src/androidTest/scala/com/nutomic/ensichat/util/AddContactsHandlerTest.scala +++ b/app/src/androidTest/scala/com/nutomic/ensichat/util/AddContactsHandlerTest.scala @@ -2,8 +2,9 @@ package com.nutomic.ensichat.util import android.content.Context import android.test.AndroidTestCase -import com.nutomic.ensichat.protocol.messages._ -import com.nutomic.ensichat.protocol.{Address, Crypto, UserTest} +import com.nutomic.ensichat.protocol.body.{RequestAddContact, ResultAddContact} +import com.nutomic.ensichat.protocol.header.ContentHeader +import com.nutomic.ensichat.protocol.{Address, Crypto, Message, UserTest} import junit.framework.Assert._ class AddContactsHandlerTest extends AndroidTestCase { diff --git a/app/src/androidTest/scala/com/nutomic/ensichat/util/DatabaseTest.scala b/app/src/androidTest/scala/com/nutomic/ensichat/util/DatabaseTest.scala index 8a44025..8bce82c 100644 --- a/app/src/androidTest/scala/com/nutomic/ensichat/util/DatabaseTest.scala +++ b/app/src/androidTest/scala/com/nutomic/ensichat/util/DatabaseTest.scala @@ -6,10 +6,12 @@ import android.content.Context import android.database.DatabaseErrorHandler import android.database.sqlite.SQLiteDatabase import android.test.{AndroidTestCase, mock} -import com.nutomic.ensichat.protocol.UserTest -import com.nutomic.ensichat.protocol.messages.ContentHeaderTest._ -import com.nutomic.ensichat.protocol.messages.MessageTest._ -import com.nutomic.ensichat.protocol.messages.{ContentHeader, CryptoData} +import com.nutomic.ensichat.protocol.{MessageTest, UserTest} +import com.nutomic.ensichat.protocol.body.CryptoData +import com.nutomic.ensichat.protocol.header.ContentHeaderTest +import com.nutomic.ensichat.protocol.header.ContentHeader +import ContentHeaderTest._ +import MessageTest._ import com.nutomic.ensichat.util.Database.OnContactsUpdatedListener import junit.framework.Assert._ diff --git a/app/src/main/scala/com/nutomic/ensichat/activities/AddContactsActivity.scala b/app/src/main/scala/com/nutomic/ensichat/activities/AddContactsActivity.scala index 4dcf49d..2e10710 100644 --- a/app/src/main/scala/com/nutomic/ensichat/activities/AddContactsActivity.scala +++ b/app/src/main/scala/com/nutomic/ensichat/activities/AddContactsActivity.scala @@ -8,7 +8,7 @@ import android.widget.AdapterView.OnItemClickListener import android.widget._ import com.nutomic.ensichat.R import com.nutomic.ensichat.protocol.ChatService -import com.nutomic.ensichat.protocol.messages.RequestAddContact +import com.nutomic.ensichat.protocol.body.RequestAddContact import com.nutomic.ensichat.util.Database.OnContactsUpdatedListener import com.nutomic.ensichat.util.{Database, UsersAdapter} diff --git a/app/src/main/scala/com/nutomic/ensichat/activities/ConfirmAddContactActivity.scala b/app/src/main/scala/com/nutomic/ensichat/activities/ConfirmAddContactActivity.scala index 2b542a6..59ae1d2 100644 --- a/app/src/main/scala/com/nutomic/ensichat/activities/ConfirmAddContactActivity.scala +++ b/app/src/main/scala/com/nutomic/ensichat/activities/ConfirmAddContactActivity.scala @@ -7,7 +7,7 @@ import android.os.Bundle import android.view.{ContextThemeWrapper, LayoutInflater} import android.widget.{ImageView, TextView} import com.nutomic.ensichat.R -import com.nutomic.ensichat.protocol.messages.ResultAddContact +import com.nutomic.ensichat.protocol.body.ResultAddContact import com.nutomic.ensichat.protocol.{Address, Crypto} import com.nutomic.ensichat.util.IdenticonGenerator diff --git a/app/src/main/scala/com/nutomic/ensichat/bluetooth/BluetoothInterface.scala b/app/src/main/scala/com/nutomic/ensichat/bluetooth/BluetoothInterface.scala index 8f47fe9..bd0bc94 100644 --- a/app/src/main/scala/com/nutomic/ensichat/bluetooth/BluetoothInterface.scala +++ b/app/src/main/scala/com/nutomic/ensichat/bluetooth/BluetoothInterface.scala @@ -12,7 +12,7 @@ import com.nutomic.ensichat.R import com.nutomic.ensichat.fragments.SettingsFragment import com.nutomic.ensichat.protocol.ChatService.InterfaceHandler import com.nutomic.ensichat.protocol._ -import com.nutomic.ensichat.protocol.messages.{ConnectionInfo, Message} +import com.nutomic.ensichat.protocol.body.ConnectionInfo import scala.collection.immutable.HashMap diff --git a/app/src/main/scala/com/nutomic/ensichat/bluetooth/TransferThread.scala b/app/src/main/scala/com/nutomic/ensichat/bluetooth/TransferThread.scala index 65beddc..4a2e43f 100644 --- a/app/src/main/scala/com/nutomic/ensichat/bluetooth/TransferThread.scala +++ b/app/src/main/scala/com/nutomic/ensichat/bluetooth/TransferThread.scala @@ -5,8 +5,9 @@ import java.io._ import android.bluetooth.BluetoothSocket import android.util.Log import com.nutomic.ensichat.protocol._ -import com.nutomic.ensichat.protocol.messages.Message.ReadMessageException -import com.nutomic.ensichat.protocol.messages.{ConnectionInfo, Message, MessageHeader} +import com.nutomic.ensichat.protocol.body.ConnectionInfo +import com.nutomic.ensichat.protocol.header.MessageHeader +import Message.ReadMessageException /** * Transfers data between connnected devices. diff --git a/app/src/main/scala/com/nutomic/ensichat/fragments/ChatFragment.scala b/app/src/main/scala/com/nutomic/ensichat/fragments/ChatFragment.scala index 181de6a..dd9cfb7 100644 --- a/app/src/main/scala/com/nutomic/ensichat/fragments/ChatFragment.scala +++ b/app/src/main/scala/com/nutomic/ensichat/fragments/ChatFragment.scala @@ -10,8 +10,8 @@ import android.widget._ import com.nutomic.ensichat.R import com.nutomic.ensichat.activities.EnsiChatActivity import com.nutomic.ensichat.protocol.ChatService.OnMessageReceivedListener -import com.nutomic.ensichat.protocol.messages.{Message, Text} -import com.nutomic.ensichat.protocol.{Address, ChatService} +import com.nutomic.ensichat.protocol.body.Text +import com.nutomic.ensichat.protocol.{Message, Address, ChatService} import com.nutomic.ensichat.util.{Database, MessagesAdapter} /** diff --git a/app/src/main/scala/com/nutomic/ensichat/fragments/SettingsFragment.scala b/app/src/main/scala/com/nutomic/ensichat/fragments/SettingsFragment.scala index fa9b162..053fce3 100644 --- a/app/src/main/scala/com/nutomic/ensichat/fragments/SettingsFragment.scala +++ b/app/src/main/scala/com/nutomic/ensichat/fragments/SettingsFragment.scala @@ -6,7 +6,7 @@ import android.preference.{Preference, PreferenceFragment, PreferenceManager} import com.nutomic.ensichat.R import com.nutomic.ensichat.activities.EnsiChatActivity import com.nutomic.ensichat.fragments.SettingsFragment._ -import com.nutomic.ensichat.protocol.messages.UserName +import com.nutomic.ensichat.protocol.body.UserName import com.nutomic.ensichat.util.Database object SettingsFragment { diff --git a/app/src/main/scala/com/nutomic/ensichat/protocol/ChatService.scala b/app/src/main/scala/com/nutomic/ensichat/protocol/ChatService.scala index 77ba1f8..2ebf48f 100644 --- a/app/src/main/scala/com/nutomic/ensichat/protocol/ChatService.scala +++ b/app/src/main/scala/com/nutomic/ensichat/protocol/ChatService.scala @@ -10,7 +10,8 @@ import com.nutomic.ensichat.R import com.nutomic.ensichat.bluetooth.BluetoothInterface import com.nutomic.ensichat.fragments.SettingsFragment import com.nutomic.ensichat.protocol.ChatService.{OnConnectionsChangedListener, OnMessageReceivedListener} -import com.nutomic.ensichat.protocol.messages._ +import com.nutomic.ensichat.protocol.body.{UserName, MessageBody, ConnectionInfo} +import com.nutomic.ensichat.protocol.header.ContentHeader import com.nutomic.ensichat.util.{AddContactsHandler, Database, NotificationHandler} import scala.collection.mutable diff --git a/app/src/main/scala/com/nutomic/ensichat/protocol/Crypto.scala b/app/src/main/scala/com/nutomic/ensichat/protocol/Crypto.scala index 86978fc..0c38c43 100644 --- a/app/src/main/scala/com/nutomic/ensichat/protocol/Crypto.scala +++ b/app/src/main/scala/com/nutomic/ensichat/protocol/Crypto.scala @@ -10,7 +10,8 @@ import android.content.Context import android.preference.PreferenceManager import android.util.Log import com.nutomic.ensichat.protocol.Crypto._ -import com.nutomic.ensichat.protocol.messages._ +import com.nutomic.ensichat.protocol.body._ +import com.nutomic.ensichat.protocol.header.ContentHeader import com.nutomic.ensichat.util.PRNGFixes object Crypto { diff --git a/app/src/main/scala/com/nutomic/ensichat/protocol/messages/Message.scala b/app/src/main/scala/com/nutomic/ensichat/protocol/Message.scala similarity index 92% rename from app/src/main/scala/com/nutomic/ensichat/protocol/messages/Message.scala rename to app/src/main/scala/com/nutomic/ensichat/protocol/Message.scala index 8ef9fef..8ebe3c5 100644 --- a/app/src/main/scala/com/nutomic/ensichat/protocol/messages/Message.scala +++ b/app/src/main/scala/com/nutomic/ensichat/protocol/Message.scala @@ -1,8 +1,11 @@ -package com.nutomic.ensichat.protocol.messages +package com.nutomic.ensichat.protocol import java.io.InputStream import java.security.spec.InvalidKeySpecException +import com.nutomic.ensichat.protocol.body._ +import com.nutomic.ensichat.protocol.header.{AbstractHeader, ContentHeader, MessageHeader} + object Message { /** diff --git a/app/src/main/scala/com/nutomic/ensichat/protocol/Router.scala b/app/src/main/scala/com/nutomic/ensichat/protocol/Router.scala index 60893b1..ad4e504 100644 --- a/app/src/main/scala/com/nutomic/ensichat/protocol/Router.scala +++ b/app/src/main/scala/com/nutomic/ensichat/protocol/Router.scala @@ -1,6 +1,6 @@ package com.nutomic.ensichat.protocol -import com.nutomic.ensichat.protocol.messages.{ContentHeader, Message} +import com.nutomic.ensichat.protocol.header.ContentHeader /** * Forwards messages to all connected devices. diff --git a/app/src/main/scala/com/nutomic/ensichat/protocol/SeqNumGenerator.scala b/app/src/main/scala/com/nutomic/ensichat/protocol/SeqNumGenerator.scala index 431af20..9b58209 100644 --- a/app/src/main/scala/com/nutomic/ensichat/protocol/SeqNumGenerator.scala +++ b/app/src/main/scala/com/nutomic/ensichat/protocol/SeqNumGenerator.scala @@ -2,7 +2,7 @@ package com.nutomic.ensichat.protocol import android.content.Context import android.preference.PreferenceManager -import com.nutomic.ensichat.protocol.messages.ContentHeader +import com.nutomic.ensichat.protocol.header.ContentHeader /** * Generates sequence numbers acorrding to protocol, which are stored persistently. diff --git a/app/src/main/scala/com/nutomic/ensichat/protocol/messages/ConnectionInfo.scala b/app/src/main/scala/com/nutomic/ensichat/protocol/body/ConnectionInfo.scala similarity index 88% rename from app/src/main/scala/com/nutomic/ensichat/protocol/messages/ConnectionInfo.scala rename to app/src/main/scala/com/nutomic/ensichat/protocol/body/ConnectionInfo.scala index a5d8c72..06a5431 100644 --- a/app/src/main/scala/com/nutomic/ensichat/protocol/messages/ConnectionInfo.scala +++ b/app/src/main/scala/com/nutomic/ensichat/protocol/body/ConnectionInfo.scala @@ -1,10 +1,11 @@ -package com.nutomic.ensichat.protocol.messages +package com.nutomic.ensichat.protocol.body import java.nio.ByteBuffer import java.security.spec.X509EncodedKeySpec import java.security.{KeyFactory, PublicKey} -import com.nutomic.ensichat.protocol.{BufferUtils, Crypto} +import com.nutomic.ensichat.protocol.Crypto +import com.nutomic.ensichat.util.BufferUtils object ConnectionInfo { diff --git a/app/src/main/scala/com/nutomic/ensichat/protocol/messages/CryptoData.scala b/app/src/main/scala/com/nutomic/ensichat/protocol/body/CryptoData.scala similarity index 94% rename from app/src/main/scala/com/nutomic/ensichat/protocol/messages/CryptoData.scala rename to app/src/main/scala/com/nutomic/ensichat/protocol/body/CryptoData.scala index 50cff63..f0a9bb9 100644 --- a/app/src/main/scala/com/nutomic/ensichat/protocol/messages/CryptoData.scala +++ b/app/src/main/scala/com/nutomic/ensichat/protocol/body/CryptoData.scala @@ -1,9 +1,9 @@ -package com.nutomic.ensichat.protocol.messages +package com.nutomic.ensichat.protocol.body import java.nio.ByteBuffer import java.util -import com.nutomic.ensichat.protocol.BufferUtils +import com.nutomic.ensichat.util.BufferUtils object CryptoData { diff --git a/app/src/main/scala/com/nutomic/ensichat/protocol/messages/EncryptedBody.scala b/app/src/main/scala/com/nutomic/ensichat/protocol/body/EncryptedBody.scala similarity index 84% rename from app/src/main/scala/com/nutomic/ensichat/protocol/messages/EncryptedBody.scala rename to app/src/main/scala/com/nutomic/ensichat/protocol/body/EncryptedBody.scala index 077ed35..cd92f82 100644 --- a/app/src/main/scala/com/nutomic/ensichat/protocol/messages/EncryptedBody.scala +++ b/app/src/main/scala/com/nutomic/ensichat/protocol/body/EncryptedBody.scala @@ -1,4 +1,4 @@ -package com.nutomic.ensichat.protocol.messages +package com.nutomic.ensichat.protocol.body /** * Represents the data in an encrypted message body. diff --git a/app/src/main/scala/com/nutomic/ensichat/protocol/messages/MessageBody.scala b/app/src/main/scala/com/nutomic/ensichat/protocol/body/MessageBody.scala similarity index 83% rename from app/src/main/scala/com/nutomic/ensichat/protocol/messages/MessageBody.scala rename to app/src/main/scala/com/nutomic/ensichat/protocol/body/MessageBody.scala index c2acc13..8c48b96 100644 --- a/app/src/main/scala/com/nutomic/ensichat/protocol/messages/MessageBody.scala +++ b/app/src/main/scala/com/nutomic/ensichat/protocol/body/MessageBody.scala @@ -1,4 +1,4 @@ -package com.nutomic.ensichat.protocol.messages +package com.nutomic.ensichat.protocol.body /** * Holds the actual message content. diff --git a/app/src/main/scala/com/nutomic/ensichat/protocol/messages/RequestAddContact.scala b/app/src/main/scala/com/nutomic/ensichat/protocol/body/RequestAddContact.scala similarity index 92% rename from app/src/main/scala/com/nutomic/ensichat/protocol/messages/RequestAddContact.scala rename to app/src/main/scala/com/nutomic/ensichat/protocol/body/RequestAddContact.scala index f318142..fbe4040 100644 --- a/app/src/main/scala/com/nutomic/ensichat/protocol/messages/RequestAddContact.scala +++ b/app/src/main/scala/com/nutomic/ensichat/protocol/body/RequestAddContact.scala @@ -1,4 +1,4 @@ -package com.nutomic.ensichat.protocol.messages +package com.nutomic.ensichat.protocol.body import java.nio.ByteBuffer diff --git a/app/src/main/scala/com/nutomic/ensichat/protocol/messages/ResultAddContact.scala b/app/src/main/scala/com/nutomic/ensichat/protocol/body/ResultAddContact.scala similarity index 89% rename from app/src/main/scala/com/nutomic/ensichat/protocol/messages/ResultAddContact.scala rename to app/src/main/scala/com/nutomic/ensichat/protocol/body/ResultAddContact.scala index 7c61443..b1cc16f 100644 --- a/app/src/main/scala/com/nutomic/ensichat/protocol/messages/ResultAddContact.scala +++ b/app/src/main/scala/com/nutomic/ensichat/protocol/body/ResultAddContact.scala @@ -1,8 +1,8 @@ -package com.nutomic.ensichat.protocol.messages +package com.nutomic.ensichat.protocol.body import java.nio.ByteBuffer -import com.nutomic.ensichat.protocol.BufferUtils +import com.nutomic.ensichat.util.BufferUtils object ResultAddContact { diff --git a/app/src/main/scala/com/nutomic/ensichat/protocol/messages/Text.scala b/app/src/main/scala/com/nutomic/ensichat/protocol/body/Text.scala similarity index 89% rename from app/src/main/scala/com/nutomic/ensichat/protocol/messages/Text.scala rename to app/src/main/scala/com/nutomic/ensichat/protocol/body/Text.scala index af6bb86..738dd09 100644 --- a/app/src/main/scala/com/nutomic/ensichat/protocol/messages/Text.scala +++ b/app/src/main/scala/com/nutomic/ensichat/protocol/body/Text.scala @@ -1,9 +1,9 @@ -package com.nutomic.ensichat.protocol.messages +package com.nutomic.ensichat.protocol.body import java.nio.ByteBuffer import java.util.Date - -import com.nutomic.ensichat.protocol.BufferUtils +import com.nutomic.ensichat.protocol.Message +import com.nutomic.ensichat.util.BufferUtils object Text { diff --git a/app/src/main/scala/com/nutomic/ensichat/protocol/messages/UserName.scala b/app/src/main/scala/com/nutomic/ensichat/protocol/body/UserName.scala similarity index 86% rename from app/src/main/scala/com/nutomic/ensichat/protocol/messages/UserName.scala rename to app/src/main/scala/com/nutomic/ensichat/protocol/body/UserName.scala index 29ddc87..84709f3 100644 --- a/app/src/main/scala/com/nutomic/ensichat/protocol/messages/UserName.scala +++ b/app/src/main/scala/com/nutomic/ensichat/protocol/body/UserName.scala @@ -1,8 +1,8 @@ -package com.nutomic.ensichat.protocol.messages +package com.nutomic.ensichat.protocol.body import java.nio.ByteBuffer - -import com.nutomic.ensichat.protocol.BufferUtils +import com.nutomic.ensichat.protocol.Message +import com.nutomic.ensichat.util.BufferUtils object UserName { diff --git a/app/src/main/scala/com/nutomic/ensichat/protocol/messages/AbstractHeader.scala b/app/src/main/scala/com/nutomic/ensichat/protocol/header/AbstractHeader.scala similarity index 88% rename from app/src/main/scala/com/nutomic/ensichat/protocol/messages/AbstractHeader.scala rename to app/src/main/scala/com/nutomic/ensichat/protocol/header/AbstractHeader.scala index e9e89b0..2016efe 100644 --- a/app/src/main/scala/com/nutomic/ensichat/protocol/messages/AbstractHeader.scala +++ b/app/src/main/scala/com/nutomic/ensichat/protocol/header/AbstractHeader.scala @@ -1,8 +1,9 @@ -package com.nutomic.ensichat.protocol.messages +package com.nutomic.ensichat.protocol.header import java.nio.ByteBuffer -import com.nutomic.ensichat.protocol.{Address, BufferUtils} +import com.nutomic.ensichat.protocol.Address +import com.nutomic.ensichat.util.BufferUtils object AbstractHeader { @@ -10,7 +11,7 @@ object AbstractHeader { val Version = 0 - private[messages] val Length = 10 + 2 * Address.Length + private[header] val Length = 10 + 2 * Address.Length } diff --git a/app/src/main/scala/com/nutomic/ensichat/protocol/messages/ContentHeader.scala b/app/src/main/scala/com/nutomic/ensichat/protocol/header/ContentHeader.scala similarity index 92% rename from app/src/main/scala/com/nutomic/ensichat/protocol/messages/ContentHeader.scala rename to app/src/main/scala/com/nutomic/ensichat/protocol/header/ContentHeader.scala index 900175a..ebf6759 100644 --- a/app/src/main/scala/com/nutomic/ensichat/protocol/messages/ContentHeader.scala +++ b/app/src/main/scala/com/nutomic/ensichat/protocol/header/ContentHeader.scala @@ -1,8 +1,9 @@ -package com.nutomic.ensichat.protocol.messages +package com.nutomic.ensichat.protocol.header import java.nio.ByteBuffer -import com.nutomic.ensichat.protocol.{Address, BufferUtils} +import com.nutomic.ensichat.protocol.Address +import com.nutomic.ensichat.util.BufferUtils object ContentHeader { diff --git a/app/src/main/scala/com/nutomic/ensichat/protocol/messages/MessageHeader.scala b/app/src/main/scala/com/nutomic/ensichat/protocol/header/MessageHeader.scala similarity index 89% rename from app/src/main/scala/com/nutomic/ensichat/protocol/messages/MessageHeader.scala rename to app/src/main/scala/com/nutomic/ensichat/protocol/header/MessageHeader.scala index 49e52a9..2074957 100644 --- a/app/src/main/scala/com/nutomic/ensichat/protocol/messages/MessageHeader.scala +++ b/app/src/main/scala/com/nutomic/ensichat/protocol/header/MessageHeader.scala @@ -1,9 +1,10 @@ -package com.nutomic.ensichat.protocol.messages +package com.nutomic.ensichat.protocol.header import java.nio.ByteBuffer -import com.nutomic.ensichat.protocol.messages.Message.ParseMessageException -import com.nutomic.ensichat.protocol.{Address, BufferUtils} +import com.nutomic.ensichat.protocol.{Message, Address} +import Message.ParseMessageException +import com.nutomic.ensichat.util.BufferUtils object MessageHeader { diff --git a/app/src/main/scala/com/nutomic/ensichat/util/AddContactsHandler.scala b/app/src/main/scala/com/nutomic/ensichat/util/AddContactsHandler.scala index 269be32..96d0b23 100644 --- a/app/src/main/scala/com/nutomic/ensichat/util/AddContactsHandler.scala +++ b/app/src/main/scala/com/nutomic/ensichat/util/AddContactsHandler.scala @@ -7,8 +7,8 @@ import android.widget.Toast import com.nutomic.ensichat.R import com.nutomic.ensichat.activities.ConfirmAddContactActivity import com.nutomic.ensichat.protocol.ChatService.OnMessageReceivedListener -import com.nutomic.ensichat.protocol.messages.{Message, RequestAddContact, ResultAddContact} -import com.nutomic.ensichat.protocol.{Address, User} +import com.nutomic.ensichat.protocol.body.{ResultAddContact, RequestAddContact} +import com.nutomic.ensichat.protocol.{Message, Address, User} /** * Handles [[RequestAddContact]] and [[ResultAddContact]] messages, adds new contacts. diff --git a/app/src/main/scala/com/nutomic/ensichat/protocol/BufferUtils.scala b/app/src/main/scala/com/nutomic/ensichat/util/BufferUtils.scala similarity index 96% rename from app/src/main/scala/com/nutomic/ensichat/protocol/BufferUtils.scala rename to app/src/main/scala/com/nutomic/ensichat/util/BufferUtils.scala index 4c8ea64..3b2493b 100644 --- a/app/src/main/scala/com/nutomic/ensichat/protocol/BufferUtils.scala +++ b/app/src/main/scala/com/nutomic/ensichat/util/BufferUtils.scala @@ -1,4 +1,4 @@ -package com.nutomic.ensichat.protocol +package com.nutomic.ensichat.util import java.nio.ByteBuffer diff --git a/app/src/main/scala/com/nutomic/ensichat/util/Database.scala b/app/src/main/scala/com/nutomic/ensichat/util/Database.scala index 8e9da6d..0bc1ad9 100644 --- a/app/src/main/scala/com/nutomic/ensichat/util/Database.scala +++ b/app/src/main/scala/com/nutomic/ensichat/util/Database.scala @@ -6,7 +6,8 @@ import android.content.{ContentValues, Context} import android.database.sqlite.{SQLiteDatabase, SQLiteOpenHelper} import com.nutomic.ensichat.protocol.ChatService.OnMessageReceivedListener import com.nutomic.ensichat.protocol._ -import com.nutomic.ensichat.protocol.messages._ +import com.nutomic.ensichat.protocol.body.{Text, ResultAddContact, RequestAddContact} +import com.nutomic.ensichat.protocol.header.ContentHeader import com.nutomic.ensichat.util.Database.OnContactsUpdatedListener import scala.collection.immutable.TreeSet diff --git a/app/src/main/scala/com/nutomic/ensichat/util/MessagesAdapter.scala b/app/src/main/scala/com/nutomic/ensichat/util/MessagesAdapter.scala index aa1a3d1..bdd6a50 100644 --- a/app/src/main/scala/com/nutomic/ensichat/util/MessagesAdapter.scala +++ b/app/src/main/scala/com/nutomic/ensichat/util/MessagesAdapter.scala @@ -4,8 +4,8 @@ import android.content.Context import android.view.{Gravity, View, ViewGroup} import android.widget.{ArrayAdapter, RelativeLayout, TextView} import com.nutomic.ensichat.R -import com.nutomic.ensichat.protocol.Address -import com.nutomic.ensichat.protocol.messages.{Message, Text} +import com.nutomic.ensichat.protocol.{Message, Address} +import com.nutomic.ensichat.protocol.body.Text /** * Displays [[Message]]s in ListView. diff --git a/app/src/main/scala/com/nutomic/ensichat/util/NotificationHandler.scala b/app/src/main/scala/com/nutomic/ensichat/util/NotificationHandler.scala index 17b486d..0f5e0ec 100644 --- a/app/src/main/scala/com/nutomic/ensichat/util/NotificationHandler.scala +++ b/app/src/main/scala/com/nutomic/ensichat/util/NotificationHandler.scala @@ -5,8 +5,8 @@ import android.content.{Context, Intent} import com.nutomic.ensichat.R import com.nutomic.ensichat.activities.MainActivity import com.nutomic.ensichat.protocol.ChatService.OnMessageReceivedListener -import com.nutomic.ensichat.protocol.Crypto -import com.nutomic.ensichat.protocol.messages.{Message, Text} +import com.nutomic.ensichat.protocol.{Message, Crypto} +import com.nutomic.ensichat.protocol.body.Text /** * Displays notifications for new messages.