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
4dfd2422
Commit
4dfd2422
authored
Mar 03, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AccountTable: write methods now takes AccountItem.
parent
d60f55f1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
74 deletions
+36
-74
AccountManager.java
.../java/com/xabber/android/data/account/AccountManager.java
+1
-34
AccountTable.java
...in/java/com/xabber/android/data/account/AccountTable.java
+35
-40
No files found.
app/src/main/java/com/xabber/android/data/account/AccountManager.java
View file @
4dfd2422
...
...
@@ -278,43 +278,10 @@ public class AccountManager implements OnLoadListener, OnWipeListener {
* @param accountItem
*/
void
requestToWriteAccount
(
final
AccountItem
accountItem
)
{
ConnectionSettings
connectionSettings
=
accountItem
.
getConnectionSettings
();
final
AccountProtocol
protocol
=
connectionSettings
.
getProtocol
();
final
boolean
custom
=
connectionSettings
.
isCustom
();
final
String
host
=
connectionSettings
.
getHost
();
final
int
port
=
connectionSettings
.
getPort
();
final
String
serverName
=
connectionSettings
.
getServerName
();
final
String
userName
=
connectionSettings
.
getUserName
();
final
String
resource
=
connectionSettings
.
getResource
();
final
boolean
storePassword
=
accountItem
.
isStorePassword
();
final
String
password
=
connectionSettings
.
getPassword
();
final
int
colorIndex
=
accountItem
.
getColorIndex
();
final
int
priority
=
accountItem
.
getPriority
();
final
StatusMode
statusMode
=
accountItem
.
getRawStatusMode
();
final
String
statusText
=
accountItem
.
getStatusText
();
final
boolean
enabled
=
accountItem
.
isEnabled
();
final
boolean
saslEnabled
=
connectionSettings
.
isSaslEnabled
();
final
TLSMode
tlsMode
=
connectionSettings
.
getTlsMode
();
final
boolean
compression
=
connectionSettings
.
useCompression
();
final
ProxyType
proxyType
=
connectionSettings
.
getProxyType
();
final
String
proxyHost
=
connectionSettings
.
getProxyHost
();
final
int
proxyPort
=
connectionSettings
.
getProxyPort
();
final
String
proxyUser
=
connectionSettings
.
getProxyUser
();
final
String
proxyPassword
=
connectionSettings
.
getProxyPassword
();
final
boolean
syncable
=
accountItem
.
isSyncable
();
final
KeyPair
keyPair
=
accountItem
.
getKeyPair
();
final
Date
lastSync
=
accountItem
.
getLastSync
();
final
ArchiveMode
archiveMode
=
accountItem
.
getArchiveMode
();
Application
.
getInstance
().
runInBackground
(
new
Runnable
()
{
@Override
public
void
run
()
{
accountItem
.
setId
(
AccountTable
.
getInstance
().
write
(
accountItem
.
getId
(),
protocol
,
custom
,
host
,
port
,
serverName
,
userName
,
resource
,
storePassword
,
password
,
colorIndex
,
priority
,
statusMode
,
statusText
,
enabled
,
saslEnabled
,
tlsMode
,
compression
,
proxyType
,
proxyHost
,
proxyPort
,
proxyUser
,
proxyPassword
,
syncable
,
keyPair
,
lastSync
,
archiveMode
));
accountItem
.
setId
(
AccountTable
.
getInstance
().
write
(
accountItem
.
getId
(),
accountItem
));
}
});
}
...
...
app/src/main/java/com/xabber/android/data/account/AccountTable.java
View file @
4dfd2422
...
...
@@ -24,6 +24,7 @@ import android.provider.BaseColumns;
import
com.xabber.android.data.AbstractTable
;
import
com.xabber.android.data.Application
;
import
com.xabber.android.data.DatabaseManager
;
import
com.xabber.android.data.connection.ConnectionSettings
;
import
com.xabber.android.data.connection.ProxyType
;
import
com.xabber.android.data.connection.TLSMode
;
import
com.xabber.androiddev.R
;
...
...
@@ -301,47 +302,41 @@ class AccountTable extends AbstractTable {
}
}
/**
* Adds or updates account.
*
* @return Assigned id.
*/
long
write
(
Long
id
,
AccountProtocol
protocol
,
boolean
custom
,
String
host
,
int
port
,
String
serverName
,
String
userName
,
String
resource
,
boolean
storePassword
,
String
password
,
int
colorIndex
,
int
priority
,
StatusMode
statusMode
,
String
statusText
,
boolean
enabled
,
boolean
saslEnabled
,
TLSMode
tlsMode
,
boolean
compression
,
ProxyType
proxyType
,
String
proxyHost
,
int
proxyPort
,
String
proxyUser
,
String
proxyPassword
,
boolean
syncable
,
KeyPair
keyPair
,
Date
lastSync
,
ArchiveMode
archiveMode
)
{
public
long
write
(
Long
id
,
AccountItem
accountItem
)
{
ConnectionSettings
connectionSettings
=
accountItem
.
getConnectionSettings
();
ContentValues
values
=
new
ContentValues
();
values
.
put
(
Fields
.
PROTOCOL
,
protocol
.
name
());
values
.
put
(
Fields
.
CUSTOM
,
custom
?
1
:
0
);
values
.
put
(
Fields
.
HOST
,
host
);
values
.
put
(
Fields
.
PORT
,
port
);
values
.
put
(
Fields
.
SERVER_NAME
,
serverName
);
values
.
put
(
Fields
.
USER_NAME
,
userName
);
if
(!
storePassword
)
{
values
.
put
(
Fields
.
PROTOCOL
,
connectionSettings
.
getProtocol
().
name
());
values
.
put
(
Fields
.
CUSTOM
,
connectionSettings
.
isCustom
()
?
1
:
0
);
values
.
put
(
Fields
.
HOST
,
connectionSettings
.
getHost
());
values
.
put
(
Fields
.
PORT
,
connectionSettings
.
getPort
());
values
.
put
(
Fields
.
SERVER_NAME
,
connectionSettings
.
getServerName
());
values
.
put
(
Fields
.
USER_NAME
,
connectionSettings
.
getUserName
());
String
password
=
connectionSettings
.
getPassword
();
if
(!
accountItem
.
isStorePassword
())
{
password
=
AccountItem
.
UNDEFINED_PASSWORD
;
}
values
.
put
(
Fields
.
PASSWORD
,
password
);
values
.
put
(
Fields
.
RESOURCE
,
resource
);
values
.
put
(
Fields
.
COLOR_INDEX
,
colorIndex
);
values
.
put
(
Fields
.
PRIORITY
,
priority
);
values
.
put
(
Fields
.
STATUS_MODE
,
statusMode
.
ordinal
());
values
.
put
(
Fields
.
STATUS_TEXT
,
statusText
);
values
.
put
(
Fields
.
ENABLED
,
enabled
?
1
:
0
);
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
);
values
.
put
(
Fields
.
RESOURCE
,
connectionSettings
.
getResource
());
values
.
put
(
Fields
.
COLOR_INDEX
,
accountItem
.
getColorIndex
());
values
.
put
(
Fields
.
PRIORITY
,
accountItem
.
getPriority
());
values
.
put
(
Fields
.
STATUS_MODE
,
accountItem
.
getRawStatusMode
().
ordinal
());
values
.
put
(
Fields
.
STATUS_TEXT
,
accountItem
.
getStatusText
());
values
.
put
(
Fields
.
ENABLED
,
accountItem
.
isEnabled
()
?
1
:
0
);
values
.
put
(
Fields
.
SASL_ENABLED
,
connectionSettings
.
isSaslEnabled
()
?
1
:
0
);
values
.
put
(
Fields
.
TLS_MODE
,
connectionSettings
.
getTlsMode
().
ordinal
());
values
.
put
(
Fields
.
COMPRESSION
,
connectionSettings
.
useCompression
()
?
1
:
0
);
values
.
put
(
Fields
.
PROXY_TYPE
,
connectionSettings
.
getProxyType
().
ordinal
());
values
.
put
(
Fields
.
PROXY_HOST
,
connectionSettings
.
getProxyHost
());
values
.
put
(
Fields
.
PROXY_PORT
,
connectionSettings
.
getProxyPort
());
values
.
put
(
Fields
.
PROXY_USER
,
connectionSettings
.
getProxyUser
());
values
.
put
(
Fields
.
PROXY_PASSWORD
,
connectionSettings
.
getProxyPassword
());
values
.
put
(
Fields
.
SYNCABLE
,
accountItem
.
isSyncable
()
?
1
:
0
);
values
.
put
(
Fields
.
STORE_PASSWORD
,
accountItem
.
isStorePassword
()
?
1
:
0
);
final
KeyPair
keyPair
=
accountItem
.
getKeyPair
();
if
(
keyPair
==
null
)
{
values
.
putNull
(
Fields
.
PUBLIC_KEY
);
values
.
putNull
(
Fields
.
PRIVATE_KEY
);
...
...
@@ -355,12 +350,12 @@ class AccountTable extends AbstractTable {
values
.
put
(
Fields
.
PUBLIC_KEY
,
publicKeyBytes
);
values
.
put
(
Fields
.
PRIVATE_KEY
,
privateKeyBytes
);
}
if
(
lastSync
==
null
)
{
if
(
accountItem
.
getLastSync
()
==
null
)
{
values
.
putNull
(
Fields
.
LAST_SYNC
);
}
else
{
values
.
put
(
Fields
.
LAST_SYNC
,
lastSync
.
getTime
());
values
.
put
(
Fields
.
LAST_SYNC
,
accountItem
.
getLastSync
()
.
getTime
());
}
values
.
put
(
Fields
.
ARCHIVE_MODE
,
a
rchiveMode
.
ordinal
());
values
.
put
(
Fields
.
ARCHIVE_MODE
,
a
ccountItem
.
getArchiveMode
()
.
ordinal
());
SQLiteDatabase
db
=
databaseManager
.
getWritableDatabase
();
if
(
id
==
null
)
{
return
db
.
insert
(
NAME
,
Fields
.
USER_NAME
,
values
);
...
...
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