Refactored packages.

This commit is contained in:
Felix Ableitner 2014-12-12 00:49:12 +02:00
parent 834f3ca724
commit 539d955737
28 changed files with 54 additions and 52 deletions

View File

@ -1,7 +1,7 @@
package com.nutomic.ensichat.aodvv2 package com.nutomic.ensichat.protocol
import android.test.AndroidTestCase import android.test.AndroidTestCase
import com.nutomic.ensichat.aodvv2.AddressTest._ import com.nutomic.ensichat.protocol.AddressTest._
import junit.framework.Assert._ import junit.framework.Assert._
object AddressTest { object AddressTest {

View File

@ -1,7 +1,7 @@
package com.nutomic.ensichat.messages package com.nutomic.ensichat.protocol
import android.test.AndroidTestCase import android.test.AndroidTestCase
import com.nutomic.ensichat.aodvv2.MessageTest._ import com.nutomic.ensichat.protocol.messages.MessageTest
import junit.framework.Assert._ import junit.framework.Assert._
class CryptoTest extends AndroidTestCase { class CryptoTest extends AndroidTestCase {
@ -16,7 +16,7 @@ class CryptoTest extends AndroidTestCase {
} }
def testSignVerify(): Unit = { def testSignVerify(): Unit = {
messages.foreach { m => MessageTest.messages.foreach { m =>
val signed = Crypto.sign(m) val signed = Crypto.sign(m)
assertTrue(Crypto.verify(signed, Crypto.getLocalPublicKey)) assertTrue(Crypto.verify(signed, Crypto.getLocalPublicKey))
assertEquals(m.Header, signed.Header) assertEquals(m.Header, signed.Header)
@ -25,7 +25,7 @@ class CryptoTest extends AndroidTestCase {
} }
def testEncryptDecrypt(): Unit = { def testEncryptDecrypt(): Unit = {
messages.foreach{ m => MessageTest.messages.foreach{ m =>
val encrypted = Crypto.encrypt(Crypto.sign(m), Crypto.getLocalPublicKey) val encrypted = Crypto.encrypt(Crypto.sign(m), Crypto.getLocalPublicKey)
val decrypted = Crypto.decrypt(encrypted) val decrypted = Crypto.decrypt(encrypted)
assertEquals(m.Body, decrypted.Body) assertEquals(m.Body, decrypted.Body)

View File

@ -1,8 +1,8 @@
package com.nutomic.ensichat.aodvv2 package com.nutomic.ensichat.protocol.messages
import android.content.Context import android.content.Context
import android.test.AndroidTestCase import android.test.AndroidTestCase
import com.nutomic.ensichat.messages.Crypto import com.nutomic.ensichat.protocol.Crypto
import junit.framework.Assert import junit.framework.Assert
object ConnectionInfoTest { object ConnectionInfoTest {

View File

@ -1,10 +1,11 @@
package com.nutomic.ensichat.aodvv2 package com.nutomic.ensichat.protocol.messages
import java.util.GregorianCalendar import java.util.GregorianCalendar
import android.test.AndroidTestCase import android.test.AndroidTestCase
import com.nutomic.ensichat.aodvv2.MessageHeaderTest._ import com.nutomic.ensichat.protocol.{Address, AddressTest}
import junit.framework.Assert._ import junit.framework.Assert._
import com.nutomic.ensichat.protocol.messages.MessageHeaderTest._
object MessageHeaderTest { object MessageHeaderTest {

View File

@ -1,12 +1,12 @@
package com.nutomic.ensichat.aodvv2 package com.nutomic.ensichat.protocol.messages
import java.io.ByteArrayInputStream import java.io.ByteArrayInputStream
import java.util.GregorianCalendar import java.util.GregorianCalendar
import com.nutomic.ensichat.protocol.messages.MessageHeaderTest._
import com.nutomic.ensichat.protocol.messages.MessageTest._
import android.test.AndroidTestCase import android.test.AndroidTestCase
import com.nutomic.ensichat.aodvv2.MessageHeaderTest._ import com.nutomic.ensichat.protocol.{AddressTest, Crypto, messages}
import com.nutomic.ensichat.aodvv2.MessageTest._
import com.nutomic.ensichat.messages.Crypto
import junit.framework.Assert._ import junit.framework.Assert._
import scala.collection.immutable.TreeSet import scala.collection.immutable.TreeSet
@ -60,7 +60,7 @@ class MessageTest extends AndroidTestCase {
} }
def testSerializeEncrypted(): Unit = { def testSerializeEncrypted(): Unit = {
messages.foreach{ m => MessageTest.messages.foreach{ m =>
val signed = Crypto.sign(m) val signed = Crypto.sign(m)
val encrypted = Crypto.encrypt(signed, Crypto.getLocalPublicKey) val encrypted = Crypto.encrypt(signed, Crypto.getLocalPublicKey)
val bytes = encrypted.write val bytes = encrypted.write

View File

@ -1,4 +1,4 @@
package com.nutomic.ensichat.aodvv2 package com.nutomic.ensichat.protocol.messages
import android.test.AndroidTestCase import android.test.AndroidTestCase
import junit.framework.Assert._ import junit.framework.Assert._

View File

@ -8,8 +8,9 @@ import android.database.DatabaseErrorHandler
import android.database.sqlite.SQLiteDatabase import android.database.sqlite.SQLiteDatabase
import android.test.AndroidTestCase import android.test.AndroidTestCase
import android.test.mock.MockContext import android.test.mock.MockContext
import com.nutomic.ensichat.aodvv2.AddressTest import com.nutomic.ensichat.protocol.AddressTest
import com.nutomic.ensichat.aodvv2.MessageTest._ import com.nutomic.ensichat.protocol.messages.MessageTest
import com.nutomic.ensichat.protocol.messages.MessageTest._
import junit.framework.Assert._ import junit.framework.Assert._
class DatabaseTest extends AndroidTestCase { class DatabaseTest extends AndroidTestCase {

View File

@ -10,10 +10,10 @@ import android.view._
import android.widget.AdapterView.OnItemClickListener import android.widget.AdapterView.OnItemClickListener
import android.widget._ import android.widget._
import com.nutomic.ensichat.R import com.nutomic.ensichat.R
import com.nutomic.ensichat.aodvv2.{Address, Message, RequestAddContact, ResultAddContact}
import com.nutomic.ensichat.bluetooth.ChatService import com.nutomic.ensichat.bluetooth.ChatService
import com.nutomic.ensichat.bluetooth.ChatService.OnMessageReceivedListener import com.nutomic.ensichat.bluetooth.ChatService.OnMessageReceivedListener
import com.nutomic.ensichat.messages.Crypto import com.nutomic.ensichat.protocol.messages.{Message, RequestAddContact, ResultAddContact}
import com.nutomic.ensichat.protocol.{Address, Crypto}
import com.nutomic.ensichat.util.{DevicesAdapter, IdenticonGenerator} import com.nutomic.ensichat.util.{DevicesAdapter, IdenticonGenerator}
import scala.collection.SortedSet import scala.collection.SortedSet

View File

@ -7,8 +7,8 @@ import android.os.Bundle
import android.view.MenuItem import android.view.MenuItem
import android.widget.Toast import android.widget.Toast
import com.nutomic.ensichat.R import com.nutomic.ensichat.R
import com.nutomic.ensichat.aodvv2.Address
import com.nutomic.ensichat.fragments.{ChatFragment, ContactsFragment} import com.nutomic.ensichat.fragments.{ChatFragment, ContactsFragment}
import com.nutomic.ensichat.protocol.Address
/** /**
* Main activity, entry point for app start. * Main activity, entry point for app start.

View File

@ -10,9 +10,9 @@ import android.preference.PreferenceManager
import android.util.Log import android.util.Log
import com.google.common.collect.HashBiMap import com.google.common.collect.HashBiMap
import com.nutomic.ensichat.R import com.nutomic.ensichat.R
import com.nutomic.ensichat.aodvv2._
import com.nutomic.ensichat.bluetooth.ChatService.{OnMessageReceivedListener, OnNearbyContactsChangedListener} import com.nutomic.ensichat.bluetooth.ChatService.{OnMessageReceivedListener, OnNearbyContactsChangedListener}
import com.nutomic.ensichat.messages._ import com.nutomic.ensichat.protocol._
import com.nutomic.ensichat.protocol.messages.{ConnectionInfo, Message, MessageBody, MessageHeader}
import com.nutomic.ensichat.util.Database import com.nutomic.ensichat.util.Database
import scala.collection.SortedSet import scala.collection.SortedSet

View File

@ -4,8 +4,8 @@ import java.io._
import android.bluetooth.BluetoothSocket import android.bluetooth.BluetoothSocket
import android.util.Log import android.util.Log
import com.nutomic.ensichat.aodvv2._ import com.nutomic.ensichat.protocol._
import com.nutomic.ensichat.messages.Crypto import com.nutomic.ensichat.protocol.messages.{ConnectionInfo, Message, MessageHeader}
/** /**
* Transfers data between connnected devices. * Transfers data between connnected devices.

View File

@ -9,9 +9,10 @@ import android.widget.TextView.OnEditorActionListener
import android.widget._ import android.widget._
import com.nutomic.ensichat.R import com.nutomic.ensichat.R
import com.nutomic.ensichat.activities.EnsiChatActivity import com.nutomic.ensichat.activities.EnsiChatActivity
import com.nutomic.ensichat.aodvv2.{Address, Message, Text}
import com.nutomic.ensichat.bluetooth.ChatService import com.nutomic.ensichat.bluetooth.ChatService
import com.nutomic.ensichat.bluetooth.ChatService.OnMessageReceivedListener import com.nutomic.ensichat.bluetooth.ChatService.OnMessageReceivedListener
import com.nutomic.ensichat.protocol.Address
import com.nutomic.ensichat.protocol.messages.{Message, Text}
import com.nutomic.ensichat.util.MessagesAdapter import com.nutomic.ensichat.util.MessagesAdapter
import scala.collection.SortedSet import scala.collection.SortedSet

View File

@ -1,4 +1,4 @@
package com.nutomic.ensichat.aodvv2 package com.nutomic.ensichat.protocol
import java.util import java.util

View File

@ -1,4 +1,4 @@
package com.nutomic.ensichat.util package com.nutomic.ensichat.protocol
import java.nio.ByteBuffer import java.nio.ByteBuffer

View File

@ -1,4 +1,4 @@
package com.nutomic.ensichat.messages package com.nutomic.ensichat.protocol
import java.io._ import java.io._
import java.security._ import java.security._
@ -9,8 +9,8 @@ import javax.crypto.{Cipher, CipherOutputStream, KeyGenerator, SecretKey}
import android.content.Context import android.content.Context
import android.preference.PreferenceManager import android.preference.PreferenceManager
import android.util.Log import android.util.Log
import com.nutomic.ensichat.aodvv2._ import com.nutomic.ensichat.protocol.Crypto._
import com.nutomic.ensichat.messages.Crypto._ import com.nutomic.ensichat.protocol.messages._
import com.nutomic.ensichat.util.PRNGFixes import com.nutomic.ensichat.util.PRNGFixes
object Crypto { object Crypto {

View File

@ -1,11 +1,10 @@
package com.nutomic.ensichat.aodvv2 package com.nutomic.ensichat.protocol.messages
import java.nio.ByteBuffer import java.nio.ByteBuffer
import java.security.spec.X509EncodedKeySpec import java.security.spec.X509EncodedKeySpec
import java.security.{KeyFactory, PublicKey} import java.security.{KeyFactory, PublicKey}
import com.nutomic.ensichat.messages.Crypto import com.nutomic.ensichat.protocol.{BufferUtils, Crypto}
import com.nutomic.ensichat.util.BufferUtils
object ConnectionInfo { object ConnectionInfo {

View File

@ -1,9 +1,9 @@
package com.nutomic.ensichat.aodvv2 package com.nutomic.ensichat.protocol.messages
import java.nio.ByteBuffer import java.nio.ByteBuffer
import java.util.Arrays import java.util.Arrays
import com.nutomic.ensichat.util.BufferUtils import com.nutomic.ensichat.protocol.BufferUtils
object CryptoData { object CryptoData {

View File

@ -1,4 +1,4 @@
package com.nutomic.ensichat.aodvv2 package com.nutomic.ensichat.protocol.messages
/** /**
* Represents the data in an encrypted message body. * Represents the data in an encrypted message body.

View File

@ -1,4 +1,4 @@
package com.nutomic.ensichat.aodvv2 package com.nutomic.ensichat.protocol.messages
import java.io.InputStream import java.io.InputStream

View File

@ -1,6 +1,4 @@
package com.nutomic.ensichat.aodvv2 package com.nutomic.ensichat.protocol.messages
import android.util.Log
/** /**
* Holds the actual message content. * Holds the actual message content.

View File

@ -1,9 +1,9 @@
package com.nutomic.ensichat.aodvv2 package com.nutomic.ensichat.protocol.messages
import java.nio.ByteBuffer import java.nio.ByteBuffer
import java.util.Date import java.util.Date
import com.nutomic.ensichat.util.BufferUtils import com.nutomic.ensichat.protocol.{Address, BufferUtils}
object MessageHeader { object MessageHeader {

View File

@ -1,4 +1,4 @@
package com.nutomic.ensichat.aodvv2 package com.nutomic.ensichat.protocol.messages
import java.nio.ByteBuffer import java.nio.ByteBuffer

View File

@ -1,8 +1,8 @@
package com.nutomic.ensichat.aodvv2 package com.nutomic.ensichat.protocol.messages
import java.nio.ByteBuffer import java.nio.ByteBuffer
import com.nutomic.ensichat.util.BufferUtils import com.nutomic.ensichat.protocol.BufferUtils
object ResultAddContact { object ResultAddContact {

View File

@ -1,8 +1,8 @@
package com.nutomic.ensichat.aodvv2 package com.nutomic.ensichat.protocol.messages
import java.nio.ByteBuffer import java.nio.ByteBuffer
import com.nutomic.ensichat.util.BufferUtils import com.nutomic.ensichat.protocol.BufferUtils
object Text { object Text {

View File

@ -4,7 +4,8 @@ import java.util.Date
import android.content.{ContentValues, Context} import android.content.{ContentValues, Context}
import android.database.sqlite.{SQLiteDatabase, SQLiteOpenHelper} import android.database.sqlite.{SQLiteDatabase, SQLiteOpenHelper}
import com.nutomic.ensichat.aodvv2._ import com.nutomic.ensichat.protocol._
import com.nutomic.ensichat.protocol.messages._
import scala.collection.SortedSet import scala.collection.SortedSet
import scala.collection.immutable.TreeSet import scala.collection.immutable.TreeSet

View File

@ -3,8 +3,8 @@ package com.nutomic.ensichat.util
import android.content.Context import android.content.Context
import android.view.{View, ViewGroup} import android.view.{View, ViewGroup}
import android.widget.{ArrayAdapter, TextView} import android.widget.{ArrayAdapter, TextView}
import com.nutomic.ensichat.aodvv2.Address
import com.nutomic.ensichat.bluetooth.Device import com.nutomic.ensichat.bluetooth.Device
import com.nutomic.ensichat.protocol.Address
/** /**
* Displays [[Device]]s in ListView. * Displays [[Device]]s in ListView.

View File

@ -3,7 +3,7 @@ package com.nutomic.ensichat.util
import android.content.Context import android.content.Context
import android.graphics.Bitmap.Config import android.graphics.Bitmap.Config
import android.graphics.{Bitmap, Canvas, Color} import android.graphics.{Bitmap, Canvas, Color}
import com.nutomic.ensichat.aodvv2.Address import com.nutomic.ensichat.protocol.Address
/** /**
* Calculates a unique identicon for the given hash. * Calculates a unique identicon for the given hash.

View File

@ -4,7 +4,8 @@ import android.content.Context
import android.view.{Gravity, View, ViewGroup} import android.view.{Gravity, View, ViewGroup}
import android.widget.{ArrayAdapter, RelativeLayout, TextView} import android.widget.{ArrayAdapter, RelativeLayout, TextView}
import com.nutomic.ensichat.R import com.nutomic.ensichat.R
import com.nutomic.ensichat.aodvv2.{Address, Message, Text} import com.nutomic.ensichat.protocol.Address
import com.nutomic.ensichat.protocol.messages.{Message, Text}
/** /**
* Displays [[Message]]s in ListView. * Displays [[Message]]s in ListView.