Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xabber-android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
xabber-android
Commits
4efe2dbe
Commit
4efe2dbe
authored
Aug 21, 2013
by
Alexander Ivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Proxy settings. Close #30.
parent
4f5bd1c3
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
328 additions
and
50 deletions
+328
-50
account_editor.xml
res/values/account_editor.xml
+9
-0
preferences.xml
res/values/preferences.xml
+18
-0
account_editor_oauth.xml
res/xml/account_editor_oauth.xml
+27
-0
account_editor_xmpp.xml
res/xml/account_editor_xmpp.xml
+27
-0
DatabaseManager.java
src/com/xabber/android/data/DatabaseManager.java
+1
-1
AccountItem.java
src/com/xabber/android/data/account/AccountItem.java
+11
-5
AccountManager.java
src/com/xabber/android/data/account/AccountManager.java
+61
-13
AccountTable.java
src/com/xabber/android/data/account/AccountTable.java
+63
-26
ConnectionItem.java
src/com/xabber/android/data/connection/ConnectionItem.java
+6
-2
ConnectionSettings.java
...om/xabber/android/data/connection/ConnectionSettings.java
+47
-2
ConnectionThread.java
src/com/xabber/android/data/connection/ConnectionThread.java
+20
-1
AccountEditor.java
src/com/xabber/android/ui/AccountEditor.java
+38
-0
No files found.
res/values/account_editor.xml
View file @
4efe2dbe
...
...
@@ -104,6 +104,15 @@
<string
name=
"account_protocol_wlm_title"
>
WLM
</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/account_editor_01.png -->
<string
name=
"account_protocol_xmpp_title"
>
XMPP
</string>
<string
name=
"account_proxy_type"
>
Proxy type
</string>
<string
name=
"account_proxy_type_none"
>
Disabled
</string>
<string
name=
"account_proxy_type_http"
>
HTTP
</string>
<string
name=
"account_proxy_type_socks4"
>
SOCKS4
</string>
<string
name=
"account_proxy_type_socks5"
>
SOCKS5
</string>
<string
name=
"account_proxy_host"
>
Proxy host
</string>
<string
name=
"account_proxy_port"
>
Proxy port
</string>
<string
name=
"account_proxy_user"
>
Proxy user
</string>
<string
name=
"account_proxy_password"
>
Proxy password
</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/account_editor_02.png -->
<string
name=
"account_sasl"
>
Use SASL Authentication (recommended)
</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/account_editor_02.png -->
...
...
res/values/preferences.xml
View file @
4efe2dbe
...
...
@@ -390,6 +390,11 @@
<string
name=
"account_sasl_key"
>
account_sasl
</string>
<string
name=
"account_tls_mode_key"
>
account_tls_mode
</string>
<string
name=
"account_compression_key"
>
account_compression
</string>
<string
name=
"account_proxy_type_key"
>
account_proxy_type
</string>
<string
name=
"account_proxy_host_key"
>
account_proxy_host
</string>
<string
name=
"account_proxy_port_key"
>
account_proxy_port
</string>
<string
name=
"account_proxy_user_key"
>
account_proxy_user
</string>
<string
name=
"account_proxy_password_key"
>
account_proxy_password
</string>
<string
name=
"account_custom_key"
>
account_custom
</string>
<string
name=
"account_archive_mode_key"
>
account_archive_mode
</string>
...
...
@@ -404,6 +409,19 @@
<item>
@string/account_tls_legacy_summary
</item>
</string-array>
<string-array
name=
"account_proxy_type_entries"
>
<item>
@string/account_proxy_type_none
</item>
<item>
@string/account_proxy_type_http
</item>
<item>
@string/account_proxy_type_socks4
</item>
<item>
@string/account_proxy_type_socks5
</item>
</string-array>
<string-array
name=
"account_proxy_type_entryvalues"
>
<item>
@string/account_proxy_type_none
</item>
<item>
@string/account_proxy_type_http
</item>
<item>
@string/account_proxy_type_socks4
</item>
<item>
@string/account_proxy_type_socks5
</item>
</string-array>
<string-array
name=
"account_archive_mode_entries"
>
<item>
@string/account_archive_mode_server
</item>
<item>
@string/account_archive_mode_available
</item>
...
...
res/xml/account_editor_oauth.xml
View file @
4efe2dbe
...
...
@@ -41,6 +41,33 @@
android:dialogTitle=
"@string/account_priority"
android:singleLine=
"true"
/>
<ListPreference
android:title=
"@string/account_proxy_type"
android:key=
"@string/account_proxy_type_key"
android:entries=
"@array/account_proxy_type_entries"
android:entryValues=
"@array/account_proxy_type_entryvalues"
/>
<EditTextPreference
android:key=
"@string/account_proxy_host_key"
android:title=
"@string/account_proxy_host"
android:singleLine=
"true"
/>
<EditTextPreference
android:key=
"@string/account_proxy_port_key"
android:title=
"@string/account_proxy_port"
android:singleLine=
"true"
/>
<EditTextPreference
android:key=
"@string/account_proxy_user_key"
android:title=
"@string/account_proxy_user"
android:singleLine=
"true"
/>
<EditTextPreference
android:key=
"@string/account_proxy_password_key"
android:title=
"@string/account_proxy_password"
android:password=
"true"
android:singleLine=
"true"
/>
<ListPreference
android:title=
"@string/account_archive_mode"
android:key=
"@string/account_archive_mode_key"
...
...
res/xml/account_editor_xmpp.xml
View file @
4efe2dbe
...
...
@@ -95,6 +95,33 @@
android:summary=
"@string/account_compression_summary"
android:key=
"@string/account_compression_key"
/>
<ListPreference
android:title=
"@string/account_proxy_type"
android:key=
"@string/account_proxy_type_key"
android:entries=
"@array/account_proxy_type_entries"
android:entryValues=
"@array/account_proxy_type_entryvalues"
/>
<EditTextPreference
android:key=
"@string/account_proxy_host_key"
android:title=
"@string/account_proxy_host"
android:singleLine=
"true"
/>
<EditTextPreference
android:key=
"@string/account_proxy_port_key"
android:title=
"@string/account_proxy_port"
android:singleLine=
"true"
/>
<EditTextPreference
android:key=
"@string/account_proxy_user_key"
android:title=
"@string/account_proxy_user"
android:singleLine=
"true"
/>
<EditTextPreference
android:key=
"@string/account_proxy_password_key"
android:title=
"@string/account_proxy_password"
android:password=
"true"
android:singleLine=
"true"
/>
<ListPreference
android:title=
"@string/account_archive_mode"
android:key=
"@string/account_archive_mode_key"
...
...
src/com/xabber/android/data/DatabaseManager.java
View file @
4efe2dbe
...
...
@@ -38,7 +38,7 @@ public class DatabaseManager extends SQLiteOpenHelper implements
OnLoadListener
,
OnClearListener
{
private
static
final
String
DATABASE_NAME
=
"xabber.db"
;
private
static
final
int
DATABASE_VERSION
=
6
5
;
private
static
final
int
DATABASE_VERSION
=
6
6
;
private
static
final
SQLiteException
DOWNGRAD_EXCEPTION
=
new
SQLiteException
(
"Database file was deleted"
);
...
...
src/com/xabber/android/data/account/AccountItem.java
View file @
4efe2dbe
...
...
@@ -19,6 +19,7 @@ import java.util.Date;
import
org.jivesoftware.smack.packet.Presence
;
import
org.jivesoftware.smack.packet.Presence.Type
;
import
org.jivesoftware.smack.proxy.ProxyInfo.ProxyType
;
import
com.xabber.android.data.NetworkException
;
import
com.xabber.android.data.SettingsManager
;
...
...
@@ -106,10 +107,13 @@ public class AccountItem extends ConnectionItem {
boolean
storePassword
,
String
password
,
int
colorIndex
,
int
priority
,
StatusMode
statusMode
,
String
statusText
,
boolean
enabled
,
boolean
saslEnabled
,
TLSMode
tlsMode
,
boolean
compression
,
boolean
syncable
,
KeyPair
keyPair
,
Date
lastSync
,
ArchiveMode
archiveMode
)
{
boolean
compression
,
ProxyType
proxyType
,
String
proxyHost
,
int
proxyPort
,
String
proxyUser
,
String
proxyPassword
,
boolean
syncable
,
KeyPair
keyPair
,
Date
lastSync
,
ArchiveMode
archiveMode
)
{
super
(
protocol
,
custom
,
host
,
port
,
serverName
,
userName
,
resource
,
storePassword
,
password
,
saslEnabled
,
tlsMode
,
compression
);
storePassword
,
password
,
saslEnabled
,
tlsMode
,
compression
,
proxyType
,
proxyHost
,
proxyPort
,
proxyUser
,
proxyPassword
);
this
.
id
=
null
;
this
.
account
=
userName
+
"@"
+
serverName
+
"/"
+
resource
;
this
.
colorIndex
=
colorIndex
;
...
...
@@ -334,9 +338,11 @@ public class AccountItem extends ConnectionItem {
*/
void
updateConnectionSettings
(
boolean
custom
,
String
host
,
int
port
,
String
password
,
boolean
saslEnabled
,
TLSMode
tlsMode
,
boolean
compression
)
{
boolean
compression
,
ProxyType
proxyType
,
String
proxyHost
,
int
proxyPort
,
String
proxyUser
,
String
proxyPassword
)
{
getConnectionSettings
().
update
(
custom
,
host
,
port
,
password
,
saslEnabled
,
tlsMode
,
compression
);
saslEnabled
,
tlsMode
,
compression
,
proxyType
,
proxyHost
,
proxyPort
,
proxyUser
,
proxyPassword
);
passwordRequested
=
false
;
AccountManager
.
getInstance
().
removePasswordRequest
(
account
);
}
...
...
src/com/xabber/android/data/account/AccountManager.java
View file @
4efe2dbe
...
...
@@ -24,6 +24,7 @@ import java.util.HashSet;
import
java.util.List
;
import
java.util.Map
;
import
org.jivesoftware.smack.proxy.ProxyInfo.ProxyType
;
import
org.jivesoftware.smack.util.StringUtils
;
import
android.content.res.TypedArray
;
...
...
@@ -192,6 +193,11 @@ public class AccountManager implements OnLoadListener, OnWipeListener {
AccountTable
.
isSaslEnabled
(
cursor
),
AccountTable
.
getTLSMode
(
cursor
),
AccountTable
.
isCompression
(
cursor
),
AccountTable
.
getProxyType
(
cursor
),
AccountTable
.
getProxyHost
(
cursor
),
AccountTable
.
getProxyPort
(
cursor
),
AccountTable
.
getProxyUser
(
cursor
),
AccountTable
.
getProxyPassword
(
cursor
),
AccountTable
.
isSyncable
(
cursor
),
AccountTable
.
getKeyPair
(
cursor
),
AccountTable
.
getLastSync
(
cursor
),
...
...
@@ -300,6 +306,16 @@ public class AccountManager implements OnLoadListener, OnWipeListener {
.
getTlsMode
();
final
boolean
compression
=
accountItem
.
getConnectionSettings
()
.
useCompression
();
final
ProxyType
proxyType
=
accountItem
.
getConnectionSettings
()
.
getProxyType
();
final
String
proxyHost
=
accountItem
.
getConnectionSettings
()
.
getProxyHost
();
final
int
proxyPort
=
accountItem
.
getConnectionSettings
()
.
getProxyPort
();
final
String
proxyUser
=
accountItem
.
getConnectionSettings
()
.
getProxyUser
();
final
String
proxyPassword
=
accountItem
.
getConnectionSettings
()
.
getProxyPassword
();
final
boolean
syncable
=
accountItem
.
isSyncable
();
final
KeyPair
keyPair
=
accountItem
.
getKeyPair
();
final
Date
lastSync
=
accountItem
.
getLastSync
();
...
...
@@ -311,8 +327,9 @@ public class AccountManager implements OnLoadListener, OnWipeListener {
accountItem
.
getId
(),
protocol
,
custom
,
host
,
port
,
serverName
,
userName
,
resource
,
storePassword
,
password
,
colorIndex
,
priority
,
statusMode
,
statusText
,
enabled
,
saslEnabled
,
tlsMode
,
compression
,
syncable
,
keyPair
,
lastSync
,
archiveMode
));
enabled
,
saslEnabled
,
tlsMode
,
compression
,
proxyType
,
proxyHost
,
proxyPort
,
proxyUser
,
proxyPassword
,
syncable
,
keyPair
,
lastSync
,
archiveMode
));
}
});
}
...
...
@@ -325,12 +342,16 @@ public class AccountManager implements OnLoadListener, OnWipeListener {
boolean
storePassword
,
String
password
,
String
resource
,
int
color
,
int
priority
,
StatusMode
statusMode
,
String
statusText
,
boolean
enabled
,
boolean
saslEnabled
,
TLSMode
tlsMode
,
boolean
compression
,
boolean
syncable
,
KeyPair
keyPair
,
Date
lastSync
,
ArchiveMode
archiveMode
)
{
boolean
compression
,
ProxyType
proxyType
,
String
proxyHost
,
int
proxyPort
,
String
proxyUser
,
String
proxyPassword
,
boolean
syncable
,
KeyPair
keyPair
,
Date
lastSync
,
ArchiveMode
archiveMode
)
{
AccountItem
accountItem
=
new
AccountItem
(
protocol
,
custom
,
host
,
port
,
serverName
,
userName
,
resource
,
storePassword
,
password
,
color
,
priority
,
statusMode
,
statusText
,
enabled
,
saslEnabled
,
tlsMode
,
compression
,
syncable
,
keyPair
,
lastSync
,
archiveMode
);
tlsMode
,
compression
,
proxyType
,
proxyHost
,
proxyPort
,
proxyUser
,
proxyPassword
,
syncable
,
keyPair
,
lastSync
,
archiveMode
);
requestToWriteAccount
(
accountItem
);
addAccount
(
accountItem
);
accountItem
.
updateConnection
(
true
);
...
...
@@ -425,7 +446,8 @@ public class AccountManager implements OnLoadListener, OnWipeListener {
getNextColorIndex
(),
0
,
StatusMode
.
available
,
SettingsManager
.
statusText
(),
true
,
true
,
tlsRequired
?
TLSMode
.
required
:
TLSMode
.
enabled
,
false
,
syncable
,
null
,
null
,
ArchiveMode
.
available
);
ProxyType
.
NONE
,
"localhost"
,
8080
,
""
,
""
,
syncable
,
null
,
null
,
ArchiveMode
.
available
);
onAccountChanged
(
accountItem
.
getAccount
());
if
(
accountItems
.
size
()
>
1
&&
SettingsManager
.
contactsEnableShowAccounts
())
...
...
@@ -500,8 +522,9 @@ public class AccountManager implements OnLoadListener, OnWipeListener {
int
port
,
String
serverName
,
String
userName
,
boolean
storePassword
,
String
password
,
String
resource
,
int
priority
,
boolean
enabled
,
boolean
saslEnabled
,
TLSMode
tlsMode
,
boolean
compression
,
boolean
syncable
,
ArchiveMode
archiveMode
)
{
TLSMode
tlsMode
,
boolean
compression
,
ProxyType
proxyType
,
String
proxyHost
,
int
proxyPort
,
String
proxyUser
,
String
proxyPassword
,
boolean
syncable
,
ArchiveMode
archiveMode
)
{
AccountItem
result
;
AccountItem
accountItem
=
getAccount
(
account
);
if
(
accountItem
.
getConnectionSettings
().
getServerName
()
...
...
@@ -520,9 +543,18 @@ public class AccountManager implements OnLoadListener, OnWipeListener {
.
equals
(
password
)
||
accountItem
.
getConnectionSettings
().
getTlsMode
()
!=
tlsMode
||
accountItem
.
getConnectionSettings
().
isSaslEnabled
()
!=
saslEnabled
||
accountItem
.
getConnectionSettings
().
useCompression
()
!=
compression
)
{
||
accountItem
.
getConnectionSettings
().
useCompression
()
!=
compression
||
accountItem
.
getConnectionSettings
().
getProxyType
()
!=
proxyType
||
!
accountItem
.
getConnectionSettings
().
getProxyHost
()
.
equals
(
proxyHost
)
||
accountItem
.
getConnectionSettings
().
getProxyPort
()
!=
proxyPort
||
!
accountItem
.
getConnectionSettings
().
getProxyUser
()
.
equals
(
proxyUser
)
||
!
accountItem
.
getConnectionSettings
().
getProxyPassword
()
.
equals
(
proxyPassword
))
{
result
.
updateConnectionSettings
(
custom
,
host
,
port
,
password
,
saslEnabled
,
tlsMode
,
compression
);
saslEnabled
,
tlsMode
,
compression
,
proxyType
,
proxyHost
,
proxyPort
,
proxyUser
,
proxyPassword
);
reconnect
=
true
;
}
if
(
result
.
isSyncable
()
!=
syncable
)
{
...
...
@@ -577,7 +609,8 @@ public class AccountManager implements OnLoadListener, OnWipeListener {
result
=
addAccount
(
protocol
,
custom
,
host
,
port
,
serverName
,
userName
,
storePassword
,
password
,
resource
,
colorIndex
,
priority
,
statusMode
,
statusText
,
enabled
,
saslEnabled
,
tlsMode
,
compression
,
syncable
,
keyPair
,
lastSync
,
tlsMode
,
compression
,
proxyType
,
proxyHost
,
proxyPort
,
proxyUser
,
proxyPassword
,
syncable
,
keyPair
,
lastSync
,
archiveMode
);
}
onAccountChanged
(
result
.
getAccount
());
...
...
@@ -608,7 +641,12 @@ public class AccountManager implements OnLoadListener, OnWipeListener {
accountItem
.
getPriority
(),
accountItem
.
isEnabled
(),
accountItem
.
getConnectionSettings
().
isSaslEnabled
(),
accountItem
.
getConnectionSettings
().
getTlsMode
(),
accountItem
.
getConnectionSettings
().
useCompression
(),
syncable
,
.
getConnectionSettings
().
useCompression
(),
accountItem
.
getConnectionSettings
().
getProxyType
(),
accountItem
.
getConnectionSettings
().
getProxyHost
(),
accountItem
.
getConnectionSettings
().
getProxyPort
(),
accountItem
.
getConnectionSettings
().
getProxyUser
(),
accountItem
.
getConnectionSettings
().
getProxyPassword
(),
syncable
,
accountItem
.
getArchiveMode
());
}
...
...
@@ -624,7 +662,12 @@ public class AccountManager implements OnLoadListener, OnWipeListener {
accountItem
.
getPriority
(),
accountItem
.
isEnabled
(),
accountItem
.
getConnectionSettings
().
isSaslEnabled
(),
accountItem
.
getConnectionSettings
().
getTlsMode
(),
accountItem
.
getConnectionSettings
().
useCompression
(),
.
getConnectionSettings
().
useCompression
(),
accountItem
.
getConnectionSettings
().
getProxyType
(),
accountItem
.
getConnectionSettings
().
getProxyHost
(),
accountItem
.
getConnectionSettings
().
getProxyPort
(),
accountItem
.
getConnectionSettings
().
getProxyUser
(),
accountItem
.
getConnectionSettings
().
getProxyPassword
(),
accountItem
.
isSyncable
(),
accountItem
.
getArchiveMode
());
}
...
...
@@ -644,6 +687,11 @@ public class AccountManager implements OnLoadListener, OnWipeListener {
accountItem
.
getConnectionSettings
().
isSaslEnabled
(),
accountItem
.
getConnectionSettings
().
getTlsMode
(),
accountItem
.
getConnectionSettings
().
useCompression
(),
accountItem
.
getConnectionSettings
().
getProxyType
(),
accountItem
.
getConnectionSettings
().
getProxyHost
(),
accountItem
.
getConnectionSettings
().
getProxyPort
(),
accountItem
.
getConnectionSettings
().
getProxyUser
(),
accountItem
.
getConnectionSettings
().
getProxyPassword
(),
accountItem
.
isSyncable
(),
archiveMode
);
}
...
...
src/com/xabber/android/data/account/AccountTable.java
View file @
4efe2dbe
...
...
@@ -24,6 +24,8 @@ import java.security.spec.PKCS8EncodedKeySpec;
import
java.security.spec.X509EncodedKeySpec
;
import
java.util.Date
;
import
org.jivesoftware.smack.proxy.ProxyInfo.ProxyType
;
import
android.content.ContentValues
;
import
android.content.SharedPreferences.Editor
;
import
android.database.Cursor
;
...
...
@@ -70,6 +72,11 @@ class AccountTable extends AbstractTable {
public
static
final
String
PRIVATE_KEY
=
"private_key"
;
public
static
final
String
LAST_SYNC
=
"last_sync"
;
public
static
final
String
ARCHIVE_MODE
=
"archive_mode"
;
public
static
final
String
PROXY_TYPE
=
"proxy_type"
;
public
static
final
String
PROXY_HOST
=
"proxy_host"
;
public
static
final
String
PROXY_PORT
=
"proxy_port"
;
public
static
final
String
PROXY_USER
=
"proxy_user"
;
public
static
final
String
PROXY_PASSWORD
=
"proxy_password"
;
}
private
static
final
String
NAME
=
"accounts"
;
...
...
@@ -80,7 +87,9 @@ class AccountTable extends AbstractTable {
Fields
.
STATUS_MODE
,
Fields
.
STATUS_TEXT
,
Fields
.
ENABLED
,
Fields
.
SASL_ENABLED
,
Fields
.
TLS_MODE
,
Fields
.
COMPRESSION
,
Fields
.
SYNCABLE
,
Fields
.
STORE_PASSWORD
,
Fields
.
PUBLIC_KEY
,
Fields
.
PRIVATE_KEY
,
Fields
.
LAST_SYNC
,
Fields
.
ARCHIVE_MODE
};
Fields
.
PRIVATE_KEY
,
Fields
.
LAST_SYNC
,
Fields
.
ARCHIVE_MODE
,
Fields
.
PROXY_TYPE
,
Fields
.
PROXY_HOST
,
Fields
.
PROXY_PORT
,
Fields
.
PROXY_USER
,
Fields
.
PROXY_PASSWORD
};
private
final
DatabaseManager
databaseManager
;
...
...
@@ -114,7 +123,11 @@ class AccountTable extends AbstractTable {
+
" INTEGER,"
+
Fields
.
SYNCABLE
+
" INTEGER,"
+
Fields
.
STORE_PASSWORD
+
" INTEGER,"
+
Fields
.
PUBLIC_KEY
+
" BLOB,"
+
Fields
.
PRIVATE_KEY
+
" BLOB,"
+
Fields
.
LAST_SYNC
+
" INTEGER,"
+
Fields
.
ARCHIVE_MODE
+
" INTEGER);"
;
+
" INTEGER,"
+
Fields
.
ARCHIVE_MODE
+
" INTEGER,"
+
Fields
.
PROXY_TYPE
+
" INTEGER,"
+
Fields
.
PROXY_HOST
+
" TEXT,"
+
Fields
.
PROXY_PORT
+
" INTEGER,"
+
Fields
.
PROXY_USER
+
" TEXT,"
+
Fields
.
PROXY_PASSWORD
+
" TEXT);"
;
DatabaseManager
.
execSQL
(
db
,
sql
);
}
...
...
@@ -264,6 +277,24 @@ class AccountTable extends AbstractTable {
+
";"
;
DatabaseManager
.
execSQL
(
db
,
sql
);
break
;
case
66
:
sql
=
"ALTER TABLE accounts ADD COLUMN proxy_type INTEGER;"
;
DatabaseManager
.
execSQL
(
db
,
sql
);
sql
=
"ALTER TABLE accounts ADD COLUMN proxy_host TEXT;"
;
DatabaseManager
.
execSQL
(
db
,
sql
);
sql
=
"ALTER TABLE accounts ADD COLUMN proxy_port INTEGER;"
;
DatabaseManager
.
execSQL
(
db
,
sql
);
sql
=
"ALTER TABLE accounts ADD COLUMN proxy_user TEXT;"
;
DatabaseManager
.
execSQL
(
db
,
sql
);
sql
=
"ALTER TABLE accounts ADD COLUMN proxy_password TEXT;"
;
DatabaseManager
.
execSQL
(
db
,
sql
);
sql
=
"UPDATE accounts SET proxy_type = "
+
ProxyType
.
NONE
.
ordinal
()
+
", "
+
"proxy_host = \"localhost\", "
+
"proxy_port = 8080, "
+
"proxy_user = \"\", "
+
"proxy_password = \"\" "
+
"WHERE proxy_type IS NULL;"
;
DatabaseManager
.
execSQL
(
db
,
sql
);
break
;
default
:
break
;
}
...
...
@@ -272,28 +303,6 @@ class AccountTable extends AbstractTable {
/**
* Adds or updates account.
*
* @param id
* @param protocol
* @param custom
* @param host
* @param port
* @param serverName
* @param userName
* @param resource
* @param storePassword
* @param password
* @param colorIndex
* @param priority
* @param statusMode
* @param statusText
* @param enabled
* @param saslEnabled
* @param tlsMode
* @param compression
* @param syncable
* @param keyPair
* @param lastSync
* @param archiveMode
* @return Assigned id.
*/
long
write
(
Long
id
,
AccountProtocol
protocol
,
boolean
custom
,
String
host
,
...
...
@@ -301,8 +310,10 @@ class AccountTable extends AbstractTable {
boolean
storePassword
,
String
password
,
int
colorIndex
,
int
priority
,
StatusMode
statusMode
,
String
statusText
,
boolean
enabled
,
boolean
saslEnabled
,
TLSMode
tlsMode
,
boolean
compression
,
boolean
syncable
,
KeyPair
keyPair
,
Date
lastSync
,
ArchiveMode
archiveMode
)
{
boolean
compression
,
ProxyType
proxyType
,
String
proxyHost
,
int
proxyPort
,
String
proxyUser
,
String
proxyPassword
,
boolean
syncable
,
KeyPair
keyPair
,
Date
lastSync
,
ArchiveMode
archiveMode
)
{
ContentValues
values
=
new
ContentValues
();
values
.
put
(
Fields
.
PROTOCOL
,
protocol
.
name
());
values
.
put
(
Fields
.
CUSTOM
,
custom
?
1
:
0
);
...
...
@@ -322,6 +333,11 @@ class AccountTable extends AbstractTable {
values
.
put
(
Fields
.
SASL_ENABLED
,
saslEnabled
?
1
:
0
);
values
.
put
(
Fields
.
TLS_MODE
,
tlsMode
.
ordinal
());
values
.
put
(
Fields
.
COMPRESSION
,
compression
?
1
:
0
);
values
.
put
(
Fields
.
PROXY_TYPE
,
proxyType
.
ordinal
());
values
.
put
(
Fields
.
PROXY_HOST
,
proxyHost
);
values
.
put
(
Fields
.
PROXY_PORT
,
proxyPort
);
values
.
put
(
Fields
.
PROXY_USER
,
proxyUser
);
values
.
put
(
Fields
.
PROXY_PASSWORD
,
proxyPassword
);
values
.
put
(
Fields
.
SYNCABLE
,
syncable
?
1
:
0
);
values
.
put
(
Fields
.
STORE_PASSWORD
,
storePassword
?
1
:
0
);
if
(
keyPair
==
null
)
{
...
...
@@ -480,6 +496,27 @@ class AccountTable extends AbstractTable {
return
ArchiveMode
.
values
()[
index
];
}
static
ProxyType
getProxyType
(
Cursor
cursor
)
{
int
index
=
cursor
.
getInt
(
cursor
.
getColumnIndex
(
Fields
.
PROXY_TYPE
));
return
ProxyType
.
values
()[
index
];
}
static
String
getProxyHost
(
Cursor
cursor
)
{
return
cursor
.
getString
(
cursor
.
getColumnIndex
(
Fields
.
PROXY_HOST
));
}
static
int
getProxyPort
(
Cursor
cursor
)
{
return
cursor
.
getInt
(
cursor
.
getColumnIndex
(
Fields
.
PROXY_PORT
));
}
static
String
getProxyUser
(
Cursor
cursor
)
{
return
cursor
.
getString
(
cursor
.
getColumnIndex
(
Fields
.
PROXY_USER
));
}
static
String
getProxyPassword
(
Cursor
cursor
)
{
return
cursor
.
getString
(
cursor
.
getColumnIndex
(
Fields
.
PROXY_PASSWORD
));
}
static
KeyPair
getKeyPair
(
Cursor
cursor
)
{
byte
[]
publicKeyBytes
=
cursor
.
getBlob
(
cursor
.
getColumnIndex
(
Fields
.
PUBLIC_KEY
));
...
...
src/com/xabber/android/data/connection/ConnectionItem.java
View file @
4efe2dbe
...
...
@@ -15,6 +15,7 @@
package
com
.
xabber
.
android
.
data
.
connection
;
import
org.jivesoftware.smack.XMPPConnection
;
import
org.jivesoftware.smack.proxy.ProxyInfo.ProxyType
;
import
com.xabber.android.data.Application
;
import
com.xabber.android.data.LogManager
;
...
...
@@ -57,10 +58,13 @@ public abstract class ConnectionItem {
public
ConnectionItem
(
AccountProtocol
protocol
,
boolean
custom
,
String
host
,
int
port
,
String
serverName
,
String
userName
,
String
resource
,
boolean
storePassword
,
String
password
,
boolean
saslEnabled
,
TLSMode
tlsMode
,
boolean
compression
)
{
boolean
saslEnabled
,
TLSMode
tlsMode
,
boolean
compression
,
ProxyType
proxyType
,
String
proxyHost
,
int
proxyPort
,
String
proxyUser
,
String
proxyPassword
)
{
connectionSettings
=
new
ConnectionSettings
(
protocol
,
userName
,
serverName
,
resource
,
custom
,
host
,
port
,
password
,
saslEnabled
,
tlsMode
,
compression
);
saslEnabled
,
tlsMode
,
compression
,
proxyType
,
proxyHost
,
proxyPort
,
proxyUser
,
proxyPassword
);
connectionRequest
=
false
;
disconnectionRequested
=
false
;
connectionThread
=
null
;
...
...
src/com/xabber/android/data/connection/ConnectionSettings.java
View file @
4efe2dbe
...
...
@@ -14,6 +14,8 @@
*/
package
com
.
xabber
.
android
.
data
.
connection
;
import
org.jivesoftware.smack.proxy.ProxyInfo.ProxyType
;
import
com.xabber.android.data.account.AccountProtocol
;
/**
...
...
@@ -79,10 +81,21 @@ public class ConnectionSettings {
*/
private
boolean
compression
;
private
ProxyType
proxyType
;
private
String
proxyHost
;
private
int
proxyPort
;
private
String
proxyUser
;
private
String
proxyPassword
;
public
ConnectionSettings
(
AccountProtocol
protocol
,
String
userName
,
String
serverName
,
String
resource
,
boolean
custom
,
String
host
,
int
port
,
String
password
,
boolean
saslEnabled
,
TLSMode
tlsMode
,
boolean
compression
)
{
boolean
compression
,
ProxyType
proxyType
,
String
proxyHost
,
int
proxyPort
,
String
proxyUser
,
String
proxyPassword
)
{
super
();
this
.
protocol
=
protocol
;
this
.
userName
=
userName
;
...
...
@@ -95,6 +108,11 @@ public class ConnectionSettings {
this
.
saslEnabled
=
saslEnabled
;
this
.
tlsMode
=
tlsMode
;
this
.
compression
=
compression
;
this
.
proxyType
=
proxyType
;
this
.
proxyHost
=
proxyHost
;
this
.
proxyPort
=
proxyPort
;
this
.
proxyUser
=
proxyUser
;
this
.
proxyPassword
=
proxyPassword
;
}
public
AccountProtocol
getProtocol
()
{
...
...
@@ -162,6 +180,26 @@ public class ConnectionSettings {
return
compression
;
}
public
ProxyType
getProxyType
()
{
return
proxyType
;
}
public
String
getProxyHost
()
{
return
proxyHost
;
}
public
int
getProxyPort
()
{
return
proxyPort
;
}
public
String
getProxyUser
()
{
return
proxyUser
;
}
public
String
getProxyPassword
()
{
return
proxyPassword
;
}
/**
* Updates options.
*
...
...
@@ -174,7 +212,9 @@ public class ConnectionSettings {
* @param compression
*/
public
void
update
(
boolean
custom
,
String
host
,
int
port
,
String
password
,
boolean
saslEnabled
,
TLSMode
tlsMode
,
boolean
compression
)
{
boolean
saslEnabled
,
TLSMode
tlsMode
,
boolean
compression
,
ProxyType
proxyType
,
String
proxyHost
,
int
proxyPort
,
String
proxyUser
,
String
proxyPassword
)
{
this
.
custom
=
custom
;
this
.
host
=
host
;
this
.
port
=
port
;
...
...
@@ -182,6 +222,11 @@ public class ConnectionSettings {
this
.
saslEnabled
=
saslEnabled
;
this
.
tlsMode
=
tlsMode
;
this
.
compression
=
compression
;
this
.
proxyType
=
proxyType
;
this
.
proxyHost
=
proxyHost
;
this
.
proxyPort
=
proxyPort
;
this
.
proxyUser
=
proxyUser
;
this
.
proxyPassword
=
proxyPassword
;
}
/**
...
...
src/com/xabber/android/data/connection/ConnectionThread.java
View file @
4efe2dbe
...
...
@@ -30,6 +30,8 @@ import org.jivesoftware.smack.XMPPException;
import
org.jivesoftware.smack.filter.PacketFilter
;
import
org.jivesoftware.smack.packet.Packet
;
import
org.jivesoftware.smack.packet.StreamError
;
import
org.jivesoftware.smack.proxy.ProxyInfo
;
import
org.jivesoftware.smack.proxy.ProxyInfo.ProxyType
;
import
org.xbill.DNS.Record
;
import
com.xabber.android.data.Application
;
...
...
@@ -92,6 +94,16 @@ public class ConnectionThread implements
private
final
boolean
compression
;
private
final
ProxyType
proxyType
;
private
final
String
proxyHost
;
private
final
int
proxyPort
;
private
final
String
proxyUser
;
private
final
String
proxyPassword
;
private
boolean
started
;
public
ConnectionThread
(
final
ConnectionItem
connectionItem
)
{
...
...
@@ -125,6 +137,11 @@ public class ConnectionThread implements
+
connectionSettings
.
getServerName
();
else
login
=
connectionSettings
.
getUserName
();
proxyType
=
connectionSettings
.
getProxyType
();
proxyHost
=
connectionSettings
.
getProxyHost
();
proxyPort
=
connectionSettings
.
getProxyPort
();
proxyUser
=
connectionSettings
.
getProxyUser
();
proxyPassword
=
connectionSettings
.
getProxyPassword
();
started
=
false
;
}
...
...
@@ -262,8 +279,10 @@ public class ConnectionThread implements
*/
private
void
onReady
(
final
InetAddress
address
,
final
int
port
)
{
LogManager
.
i
(
this
,
"Use "
+
address
);
ProxyInfo
proxy
=
new
ProxyInfo
(
proxyType
,
proxyHost
,
proxyPort
,
proxyUser
,
proxyPassword
);
ConnectionConfiguration
connectionConfiguration
=
new
ConnectionConfiguration
(
address
.
getHostAddress
(),
port
,
serverName
);
address
.
getHostAddress
(),
port
,
serverName
,
proxy
);
if
(
Application
.
SDK_INT
>=
14
)
{
connectionConfiguration
.
setTruststoreType
(
"AndroidCAStore"
);
connectionConfiguration
.
setTruststorePassword
(
null
);
...
...
src/com/xabber/android/ui/AccountEditor.java
View file @
4efe2dbe
...
...
@@ -17,6 +17,8 @@ package com.xabber.android.ui;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.jivesoftware.smack.proxy.ProxyInfo.ProxyType
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.os.Bundle
;
...
...
@@ -129,13 +131,30 @@ public class AccountEditor extends BaseSettingsActivity implements
if
(
getString
(
R
.
string
.
account_tls_mode_key
)
.
equals
(
preference
.
getKey
())
||
getString
(
R
.
string
.
account_archive_mode_key
).
equals
(
preference
.
getKey
())
||
getString
(
R
.
string
.
account_proxy_type_key
).
equals
(
preference
.
getKey
()))
preference
.
setSummary
((
String
)
newValue
);
else
if
(!
getString
(
R
.
string
.
account_password_key
).
equals
(
preference
.
getKey
())
&&
!
getString
(
R
.
string
.
account_proxy_password_key
).
equals
(
preference
.
getKey
())
&&
!
getString
(
R
.
string
.
account_priority_key
).
equals
(
preference
.
getKey
()))
super
.
onPreferenceChange
(
preference
,
newValue
);
if
(
getString
(
R
.
string
.
account_proxy_type_key
).
equals
(
preference
.
getKey
()))
{
boolean
enabled
=
!
getString
(
R
.
string
.
account_proxy_type_none
)
.
equals
(
newValue
);
for
(
int
id
:
new
Integer
[]
{
R
.
string
.
account_proxy_host_key
,
R
.
string
.
account_proxy_port_key
,
R
.
string
.
account_proxy_user_key
,
R
.
string
.
account_proxy_password_key
,
})
{
Preference
proxyPreference
=
findPreference
(
getString
(
id
));
if
(
proxyPreference
!=
null
)
proxyPreference
.
setEnabled
(
enabled
);
}
}
return
true
;
}
...
...
@@ -190,6 +209,19 @@ public class AccountEditor extends BaseSettingsActivity implements
.
getTlsMode
().
ordinal
()));
putValue
(
source
,
R
.
string
.
account_compression_key
,
accountItem
.
getConnectionSettings
().
useCompression
());
putValue
(
source
,
R
.
string
.
account_proxy_type_key
,
Integer
.
valueOf
(
accountItem
.
getConnectionSettings
()
.
getProxyType
().
ordinal
()));
putValue
(
source
,
R
.
string
.
account_proxy_host_key
,
accountItem
.
getConnectionSettings
().
getProxyHost
());
putValue
(
source
,
R
.
string
.
account_proxy_port_key
,
accountItem
.
getConnectionSettings
().
getProxyPort
());
putValue
(
source
,
R
.
string
.
account_proxy_user_key
,
accountItem
.
getConnectionSettings
().
getProxyUser
());
putValue
(
source
,
R
.
string
.
account_proxy_password_key
,
accountItem
.
getConnectionSettings
().
getProxyPassword
());
putValue
(
source
,
R
.
string
.
account_syncable_key
,
accountItem
.
isSyncable
());
putValue
(
source
,
R
.
string
.
account_archive_mode_key
,
...
...
@@ -226,6 +258,12 @@ public class AccountEditor extends BaseSettingsActivity implements
TLSMode
.
values
()[
getInt
(
result
,
R
.
string
.
account_tls_mode_key
)],
getBoolean
(
result
,
R
.
string
.
account_compression_key
),
ProxyType
.
values
()[
getInt
(
result
,
R
.
string
.
account_proxy_type_key
)],
getString
(
result
,
R
.
string
.
account_proxy_host_key
),
getInt
(
result
,
R
.
string
.
account_proxy_port_key
),
getString
(
result
,
R
.
string
.
account_proxy_user_key
),
getString
(
result
,
R
.
string
.
account_proxy_password_key
),
getBoolean
(
result
,
R
.
string
.
account_syncable_key
),
ArchiveMode
.
values
()[
getInt
(
result
,
R
.
string
.
account_archive_mode_key
)]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment