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
93a98040
Commit
93a98040
authored
Jul 29, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
VCardManager rewritten to use Smack methods to get vCards.
Unused code from xmpp/vcard removed.
parent
1866beba
Changes
50
Hide whitespace changes
Inline
Side-by-side
Showing
50 changed files
with
168 additions
and
2565 deletions
+168
-2565
AvatarManager.java
...m/xabber/android/data/extension/avatar/AvatarManager.java
+1
-1
OnVCardListener.java
.../xabber/android/data/extension/vcard/OnVCardListener.java
+1
-1
VCardManager.java
...com/xabber/android/data/extension/vcard/VCardManager.java
+104
-152
VCardRequest.java
...com/xabber/android/data/extension/vcard/VCardRequest.java
+0
-55
SyncManager.java
...main/java/com/xabber/android/data/roster/SyncManager.java
+1
-1
ContactVcardViewerFragment.java
...ava/com/xabber/android/ui/ContactVcardViewerFragment.java
+61
-62
AbstractBinaryData.java
...c/main/java/com/xabber/xmpp/vcard/AbstractBinaryData.java
+0
-64
AbstractData.java
app/src/main/java/com/xabber/xmpp/vcard/AbstractData.java
+0
-37
AbstractDataProvider.java
...main/java/com/xabber/xmpp/vcard/AbstractDataProvider.java
+0
-91
AbstractExternalData.java
...main/java/com/xabber/xmpp/vcard/AbstractExternalData.java
+0
-47
AbstractTypedData.java
...rc/main/java/com/xabber/xmpp/vcard/AbstractTypedData.java
+0
-54
AbstractTypedDataProvider.java
...java/com/xabber/xmpp/vcard/AbstractTypedDataProvider.java
+0
-44
AbstractTypedDataWithValue.java
...ava/com/xabber/xmpp/vcard/AbstractTypedDataWithValue.java
+0
-52
AbstractTypedDataWithValueProvider.java
...xabber/xmpp/vcard/AbstractTypedDataWithValueProvider.java
+0
-40
Address.java
app/src/main/java/com/xabber/xmpp/vcard/Address.java
+0
-58
AddressProvider.java
app/src/main/java/com/xabber/xmpp/vcard/AddressProvider.java
+0
-59
BinaryLogo.java
app/src/main/java/com/xabber/xmpp/vcard/BinaryLogo.java
+0
-24
BinaryPhoto.java
app/src/main/java/com/xabber/xmpp/vcard/BinaryPhoto.java
+0
-24
BinarySound.java
app/src/main/java/com/xabber/xmpp/vcard/BinarySound.java
+0
-24
CategoriesInflater.java
...c/main/java/com/xabber/xmpp/vcard/CategoriesInflater.java
+0
-47
Classification.java
app/src/main/java/com/xabber/xmpp/vcard/Classification.java
+0
-25
ClassificationInflater.java
...in/java/com/xabber/xmpp/vcard/ClassificationInflater.java
+0
-50
DataHolder.java
app/src/main/java/com/xabber/xmpp/vcard/DataHolder.java
+0
-52
Email.java
app/src/main/java/com/xabber/xmpp/vcard/Email.java
+0
-36
EmailProvider.java
app/src/main/java/com/xabber/xmpp/vcard/EmailProvider.java
+0
-46
ExternalLogo.java
app/src/main/java/com/xabber/xmpp/vcard/ExternalLogo.java
+0
-24
ExternalPhoto.java
app/src/main/java/com/xabber/xmpp/vcard/ExternalPhoto.java
+0
-24
ExternalSound.java
app/src/main/java/com/xabber/xmpp/vcard/ExternalSound.java
+0
-24
Geo.java
app/src/main/java/com/xabber/xmpp/vcard/Geo.java
+0
-62
GeoProvider.java
app/src/main/java/com/xabber/xmpp/vcard/GeoProvider.java
+0
-54
Key.java
app/src/main/java/com/xabber/xmpp/vcard/Key.java
+0
-68
KeyProvider.java
app/src/main/java/com/xabber/xmpp/vcard/KeyProvider.java
+0
-61
Label.java
app/src/main/java/com/xabber/xmpp/vcard/Label.java
+0
-57
LabelProvider.java
app/src/main/java/com/xabber/xmpp/vcard/LabelProvider.java
+0
-56
Logo.java
app/src/main/java/com/xabber/xmpp/vcard/Logo.java
+0
-23
LogoHolderProvider.java
...c/main/java/com/xabber/xmpp/vcard/LogoHolderProvider.java
+0
-45
NameInflater.java
app/src/main/java/com/xabber/xmpp/vcard/NameInflater.java
+0
-49
NameProperty.java
app/src/main/java/com/xabber/xmpp/vcard/NameProperty.java
+0
-29
Organization.java
app/src/main/java/com/xabber/xmpp/vcard/Organization.java
+0
-65
OrganizationProvider.java
...main/java/com/xabber/xmpp/vcard/OrganizationProvider.java
+0
-54
PhoneticSound.java
app/src/main/java/com/xabber/xmpp/vcard/PhoneticSound.java
+0
-52
Photo.java
app/src/main/java/com/xabber/xmpp/vcard/Photo.java
+0
-23
PhotoHolderProvider.java
.../main/java/com/xabber/xmpp/vcard/PhotoHolderProvider.java
+0
-46
Sound.java
app/src/main/java/com/xabber/xmpp/vcard/Sound.java
+0
-23
SoundHolderProvider.java
.../main/java/com/xabber/xmpp/vcard/SoundHolderProvider.java
+0
-85
Telephone.java
app/src/main/java/com/xabber/xmpp/vcard/Telephone.java
+0
-37
TelephoneProvider.java
...rc/main/java/com/xabber/xmpp/vcard/TelephoneProvider.java
+0
-46
VCard.java
app/src/main/java/com/xabber/xmpp/vcard/VCard.java
+0
-303
VCardProvider.java
app/src/main/java/com/xabber/xmpp/vcard/VCardProvider.java
+0
-102
smack.providers
app/src/main/res/raw/smack.providers
+0
-7
No files found.
app/src/main/java/com/xabber/android/data/extension/avatar/AvatarManager.java
View file @
93a98040
...
...
@@ -476,7 +476,7 @@ public class AvatarManager implements OnLoadListener, OnLowMemoryListener, OnPac
String
hash
,
byte
[]
value
,
Bitmap
bitmap
)
{
if
(
value
==
null
)
{
if
(
SettingsManager
.
connectionLoadVCard
())
{
VCardManager
.
getInstance
().
request
(
account
,
bareAddress
,
hash
);
VCardManager
.
getInstance
().
request
(
account
,
bareAddress
);
}
}
else
{
bitmaps
.
put
(
hash
,
bitmap
==
null
?
EMPTY_BITMAP
:
bitmap
);
...
...
app/src/main/java/com/xabber/android/data/extension/vcard/OnVCardListener.java
View file @
93a98040
...
...
@@ -15,7 +15,7 @@
package
com
.
xabber
.
android
.
data
.
extension
.
vcard
;
import
com.xabber.android.data.BaseUIListener
;
import
com.xabber.xmpp.vcard
.VCard
;
import
org.jivesoftware.smackx.vcardtemp.packet
.VCard
;
/**
* Listener for vCard to be received.
...
...
app/src/main/java/com/xabber/android/data/extension/vcard/VCardManager.java
View file @
93a98040
...
...
@@ -14,31 +14,16 @@
*/
package
com
.
xabber
.
android
.
data
.
extension
.
vcard
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.Set
;
import
org.jivesoftware.smack.packet.IQ
;
import
org.jivesoftware.smack.packet.IQ.Type
;
import
org.jivesoftware.smack.packet.Presence
;
import
org.jivesoftware.smack.packet.Stanza
;
import
android.database.Cursor
;
import
com.xabber.android.data.Application
;
import
com.xabber.android.data.
NetworkException
;
import
com.xabber.android.data.
LogManager
;
import
com.xabber.android.data.OnLoadListener
;
import
com.xabber.android.data.SettingsManager
;
import
com.xabber.android.data.account.AccountItem
;
import
com.xabber.android.data.account.AccountManager
;
import
com.xabber.android.data.account.OnAccountRemovedListener
;
import
com.xabber.android.data.connection.ConnectionItem
;
import
com.xabber.android.data.connection.ConnectionManager
;
import
com.xabber.android.data.connection.OnDisconnectListener
;
import
com.xabber.android.data.connection.OnPacketListener
;
import
com.xabber.android.data.extension.avatar.AvatarManager
;
import
com.xabber.android.data.roster.OnRosterChangedListener
;
...
...
@@ -47,7 +32,19 @@ import com.xabber.android.data.roster.RosterContact;
import
com.xabber.android.data.roster.RosterManager
;
import
com.xabber.android.data.roster.StructuredName
;
import
com.xabber.xmpp.address.Jid
;
import
com.xabber.xmpp.vcard.VCard
;
import
com.xabber.xmpp.vcard.VCardProperty
;
import
org.jivesoftware.smack.SmackException
;
import
org.jivesoftware.smack.XMPPConnection
;
import
org.jivesoftware.smack.XMPPException
;
import
org.jivesoftware.smack.packet.IQ.Type
;
import
org.jivesoftware.smack.packet.Presence
;
import
org.jivesoftware.smack.packet.Stanza
;
import
org.jivesoftware.smackx.vcardtemp.packet.VCard
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* Manage vCards and there requests.
...
...
@@ -55,22 +52,11 @@ import com.xabber.xmpp.vcard.VCard;
* @author alexander.ivanov
*/
public
class
VCardManager
implements
OnLoadListener
,
OnPacketListener
,
OnDisconnectListener
,
OnRosterReceivedListener
,
OnAccountRemovedListener
{
OnRosterReceivedListener
,
OnAccountRemovedListener
{
private
static
final
StructuredName
EMPTY_STRUCTURED_NAME
=
new
StructuredName
(
null
,
null
,
null
,
null
,
null
);
/**
* Sent requests.
*/
private
final
Collection
<
VCardRequest
>
requests
;
/**
* List of invalid avatar's hashes (hashes without actual avatars).
*/
private
final
Set
<
String
>
invalidHashes
;
/**
* Nick and formatted names for the users.
*/
...
...
@@ -94,15 +80,13 @@ public class VCardManager implements OnLoadListener, OnPacketListener,
}
private
VCardManager
()
{
requests
=
new
ArrayList
<
VCardRequest
>();
invalidHashes
=
new
HashSet
<
String
>();
names
=
new
HashMap
<
String
,
StructuredName
>();
accountRequested
=
new
ArrayList
<
String
>();
names
=
new
HashMap
<>();
accountRequested
=
new
ArrayList
<>();
}
@Override
public
void
onLoad
()
{
final
Map
<
String
,
StructuredName
>
names
=
new
HashMap
<
String
,
StructuredName
>();
final
Map
<
String
,
StructuredName
>
names
=
new
HashMap
<>();
Cursor
cursor
=
VCardTable
.
getInstance
().
list
();
try
{
if
(
cursor
.
moveToFirst
())
{
...
...
@@ -134,31 +118,19 @@ public class VCardManager implements OnLoadListener, OnPacketListener,
@Override
public
void
onRosterReceived
(
AccountItem
accountItem
)
{
String
account
=
accountItem
.
getAccount
();
if
(!
accountRequested
.
contains
(
account
)
&&
SettingsManager
.
connectionLoadVCard
())
{
if
(!
accountRequested
.
contains
(
account
)
&&
SettingsManager
.
connectionLoadVCard
())
{
String
bareAddress
=
Jid
.
getBareAddress
(
accountItem
.
getRealJid
());
if
(
bareAddress
!=
null
)
{
request
(
account
,
bareAddress
,
null
);
request
(
account
,
bareAddress
);
accountRequested
.
add
(
account
);
}
}
// Request vCards for new contacts.
for
(
RosterContact
contact
:
RosterManager
.
getInstance
().
getContacts
())
if
(
account
.
equals
(
contact
.
getUser
())
&&
!
names
.
containsKey
(
contact
.
getUser
()))
request
(
account
,
contact
.
getUser
(),
null
);
}
@Override
public
void
onDisconnect
(
ConnectionItem
connection
)
{
if
(!(
connection
instanceof
AccountItem
))
return
;
String
account
=
((
AccountItem
)
connection
).
getAccount
();
Iterator
<
VCardRequest
>
iterator
=
requests
.
iterator
();
while
(
iterator
.
hasNext
())
{
if
(
iterator
.
next
().
getAccount
().
equals
(
account
))
iterator
.
remove
();
for
(
RosterContact
contact
:
RosterManager
.
getInstance
().
getContacts
())
{
if
(
account
.
equals
(
contact
.
getUser
())
&&
!
names
.
containsKey
(
contact
.
getUser
()))
{
request
(
account
,
contact
.
getUser
());
}
}
}
...
...
@@ -169,36 +141,9 @@ public class VCardManager implements OnLoadListener, OnPacketListener,
/**
* Requests vCard.
*
* @param account
* @param bareAddress
* @param hash avatar's hash that was intent to request vCard. Can be
* <code>null</code>.
*/
public
void
request
(
String
account
,
String
bareAddress
,
String
hash
)
{
if
(
hash
!=
null
&&
invalidHashes
.
contains
(
hash
))
return
;
// User can change avatar before first request will be completed.
for
(
VCardRequest
check
:
requests
)
if
(
check
.
getUser
().
equals
(
bareAddress
))
{
if
(
hash
!=
null
)
check
.
addHash
(
hash
);
return
;
}
VCard
packet
=
new
VCard
();
packet
.
setTo
(
bareAddress
);
packet
.
setType
(
Type
.
get
);
VCardRequest
request
=
new
VCardRequest
(
account
,
bareAddress
,
packet
.
getPacketID
());
requests
.
add
(
request
);
if
(
hash
!=
null
)
request
.
addHash
(
hash
);
try
{
ConnectionManager
.
getInstance
().
sendStanza
(
account
,
packet
);
}
catch
(
NetworkException
e
)
{
requests
.
remove
(
request
);
onVCardFailed
(
account
,
bareAddress
);
}
public
void
request
(
String
account
,
String
bareAddress
)
{
requestVCard
(
account
,
bareAddress
);
}
/**
...
...
@@ -225,96 +170,103 @@ public class VCardManager implements OnLoadListener, OnPacketListener,
* @param bareAddress
* @return <code>null</code> if there is no info.
*/
public
StructuredName
getStructu
c
edName
(
String
bareAddress
)
{
public
StructuredName
getStructu
r
edName
(
String
bareAddress
)
{
return
names
.
get
(
bareAddress
);
}
private
void
onVCardReceived
(
final
String
account
,
final
String
bareAddress
,
final
VCard
vCard
)
{
for
(
OnVCardListener
listener
:
Application
.
getInstance
()
.
getUIListeners
(
OnVCardListener
.
class
))
listener
.
onVCardReceived
(
account
,
bareAddress
,
vCard
);
private
void
onVCardReceived
(
final
String
account
,
final
String
bareAddress
,
final
VCard
vCard
)
{
final
StructuredName
name
;
if
(
vCard
.
getType
()
==
Type
.
error
)
{
onVCardFailed
(
account
,
bareAddress
);
if
(
names
.
containsKey
(
bareAddress
))
{
return
;
}
name
=
EMPTY_STRUCTURED_NAME
;
}
else
{
for
(
OnVCardListener
listener
:
Application
.
getInstance
().
getUIListeners
(
OnVCardListener
.
class
))
{
listener
.
onVCardReceived
(
account
,
bareAddress
,
vCard
);
}
String
hash
=
vCard
.
getAvatarHash
();
AvatarManager
.
getInstance
().
onAvatarReceived
(
bareAddress
,
hash
,
vCard
.
getAvatar
());
name
=
new
StructuredName
(
vCard
.
getNickName
(),
vCard
.
getField
(
VCardProperty
.
FN
.
name
()),
vCard
.
getFirstName
(),
vCard
.
getMiddleName
(),
vCard
.
getLastName
());
}
names
.
put
(
bareAddress
,
name
);
for
(
RosterContact
rosterContact
:
RosterManager
.
getInstance
().
getContacts
())
{
if
(
rosterContact
.
getUser
().
equals
(
bareAddress
))
{
for
(
OnRosterChangedListener
listener
:
Application
.
getInstance
()
.
getManagers
(
OnRosterChangedListener
.
class
))
{
listener
.
onContactStructuredInfoChanged
(
rosterContact
,
name
);
}
}
}
Application
.
getInstance
().
runInBackground
(
new
Runnable
()
{
@Override
public
void
run
()
{
VCardTable
.
getInstance
().
write
(
bareAddress
,
name
);
}
});
if
(
vCard
.
getFrom
()
==
null
)
{
// account it self
AccountManager
.
getInstance
().
onAccountChanged
(
account
);
}
else
{
RosterManager
.
getInstance
().
onContactChanged
(
account
,
bareAddress
);
}
}
private
void
onVCardFailed
(
final
String
account
,
final
String
bareAddress
)
{
for
(
OnVCardListener
listener
:
Application
.
getInstance
()
.
getUIListeners
(
OnVCardListener
.
class
))
for
(
OnVCardListener
listener
:
Application
.
getInstance
().
getUIListeners
(
OnVCardListener
.
class
))
{
listener
.
onVCardFailed
(
account
,
bareAddress
);
}
}
@Override
public
void
onPacket
(
ConnectionItem
connection
,
final
String
bareAddress
,
Stanza
packet
)
{
if
(!(
connection
instanceof
AccountItem
))
if
(!(
connection
instanceof
AccountItem
))
{
return
;
}
String
account
=
((
AccountItem
)
connection
).
getAccount
();
if
(
packet
instanceof
Presence
&&
((
Presence
)
packet
).
getType
()
!=
Presence
.
Type
.
error
)
{
if
(
bareAddress
==
null
)
if
(
packet
instanceof
Presence
&&
((
Presence
)
packet
).
getType
()
!=
Presence
.
Type
.
error
)
{
if
(
bareAddress
==
null
)
{
return
;
}
// Request vCard for new users
if
(!
names
.
containsKey
(
bareAddress
))
if
(
SettingsManager
.
connectionLoadVCard
())
request
(
account
,
bareAddress
,
null
);
}
else
if
(
packet
instanceof
IQ
)
{
IQ
iq
=
(
IQ
)
packet
;
if
(
iq
.
getType
()
!=
Type
.
error
&&
!(
packet
instanceof
VCard
))
return
;
String
packetId
=
iq
.
getPacketID
();
VCardRequest
request
=
null
;
Iterator
<
VCardRequest
>
iterator
=
requests
.
iterator
();
while
(
iterator
.
hasNext
())
{
VCardRequest
check
=
iterator
.
next
();
if
(
check
.
getPacketId
().
equals
(
packetId
))
{
request
=
check
;
iterator
.
remove
();
break
;
if
(!
names
.
containsKey
(
bareAddress
))
{
if
(
SettingsManager
.
connectionLoadVCard
())
{
request
(
account
,
bareAddress
);
}
}
if
(
request
==
null
||
!
request
.
getUser
().
equals
(
bareAddress
))
return
;
final
StructuredName
name
;
if
(
iq
.
getType
()
==
Type
.
error
)
{
onVCardFailed
(
account
,
bareAddress
);
invalidHashes
.
addAll
(
request
.
getHashes
());
if
(
names
.
containsKey
(
bareAddress
))
return
;
name
=
EMPTY_STRUCTURED_NAME
;
}
else
if
(
packet
instanceof
VCard
)
{
VCard
vCard
=
(
VCard
)
packet
;
onVCardReceived
(
account
,
bareAddress
,
vCard
);
String
hash
=
vCard
.
getAvatarHash
();
for
(
String
check
:
request
.
getHashes
())
if
(!
check
.
equals
(
hash
))
invalidHashes
.
add
(
check
);
AvatarManager
.
getInstance
().
onAvatarReceived
(
bareAddress
,
hash
,
vCard
.
getAvatar
());
name
=
new
StructuredName
(
vCard
.
getNickName
(),
vCard
.
getFormattedName
(),
vCard
.
getFirstName
(),
vCard
.
getMiddleName
(),
vCard
.
getLastName
());
}
else
throw
new
IllegalStateException
();
names
.
put
(
bareAddress
,
name
);
for
(
RosterContact
rosterContact
:
RosterManager
.
getInstance
()
.
getContacts
())
if
(
rosterContact
.
getUser
().
equals
(
bareAddress
))
for
(
OnRosterChangedListener
listener
:
Application
.
getInstance
().
getManagers
(
OnRosterChangedListener
.
class
))
listener
.
onContactStructuredInfoChanged
(
rosterContact
,
name
);
Application
.
getInstance
().
runInBackground
(
new
Runnable
()
{
@Override
public
void
run
()
{
VCardTable
.
getInstance
().
write
(
bareAddress
,
name
);
}
}
private
void
requestVCard
(
final
String
account
,
final
String
user
)
{
final
XMPPConnection
xmppConnection
=
AccountManager
.
getInstance
().
getAccount
(
account
).
getConnectionThread
().
getXMPPConnection
();
final
org
.
jivesoftware
.
smackx
.
vcardtemp
.
VCardManager
vCardManager
=
org
.
jivesoftware
.
smackx
.
vcardtemp
.
VCardManager
.
getInstanceFor
(
xmppConnection
);
final
Thread
thread
=
new
Thread
(
"Get vCard user "
+
user
+
" for account "
+
account
)
{
@Override
public
void
run
()
{
VCard
vCard
=
null
;
try
{
vCard
=
vCardManager
.
loadVCard
(
user
);
}
catch
(
SmackException
.
NoResponseException
|
XMPPException
.
XMPPErrorException
|
SmackException
.
NotConnectedException
e
)
{
LogManager
.
w
(
this
,
"Error getting vCard: "
+
e
.
getMessage
());
}
});
if
(
iq
.
getFrom
()
==
null
)
{
// account it self
AccountManager
.
getInstance
().
onAccountChanged
(
account
);
}
else
{
RosterManager
.
getInstance
().
onContactChanged
(
account
,
bareAddress
);
final
VCard
finalVCard
=
vCard
;
Application
.
getInstance
().
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
finalVCard
==
null
)
{
onVCardFailed
(
account
,
user
);
}
else
{
onVCardReceived
(
account
,
user
,
finalVCard
);
}
}
});
}
}
};
thread
.
start
();
}
}
app/src/main/java/com/xabber/android/data/extension/vcard/VCardRequest.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
android
.
data
.
extension
.
vcard
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.HashSet
;
import
com.xabber.android.data.entity.BaseEntity
;
/**
* Store information about vCard request for specified user.
*
* @author alexander.ivanov
*/
class
VCardRequest
extends
BaseEntity
{
private
final
String
packetId
;
/**
* List of intent avatar's hashes.
*/
private
final
HashSet
<
String
>
hashes
;
public
VCardRequest
(
String
account
,
String
bareAddress
,
String
packetId
)
{
super
(
account
,
bareAddress
);
this
.
packetId
=
packetId
;
this
.
hashes
=
new
HashSet
<
String
>();
}
public
String
getPacketId
()
{
return
packetId
;
}
public
Collection
<
String
>
getHashes
()
{
return
Collections
.
unmodifiableCollection
(
hashes
);
}
public
void
addHash
(
String
hash
)
{
hashes
.
add
(
hash
);
}
}
\ No newline at end of file
app/src/main/java/com/xabber/android/data/roster/SyncManager.java
View file @
93a98040
...
...
@@ -1055,7 +1055,7 @@ public class SyncManager implements OnLoadListener, OnUnloadListener,
nickNamesForContacts
.
put
(
rosterContact
,
rosterContact
.
getRealName
());
StructuredName
structuredName
=
VCardManager
.
getInstance
()
.
getStructu
c
edName
(
rosterContact
.
getUser
());
.
getStructu
r
edName
(
rosterContact
.
getUser
());
if
(
structuredName
!=
null
)
structuredNamesForContacts
.
put
(
rosterContact
,
structuredName
);
...
...
app/src/main/java/com/xabber/android/ui/ContactVcardViewerFragment.java
View file @
93a98040
...
...
@@ -25,19 +25,14 @@ import com.xabber.android.data.extension.vcard.VCardManager;
import
com.xabber.android.data.roster.OnContactChangedListener
;
import
com.xabber.android.data.roster.PresenceManager
;
import
com.xabber.android.data.roster.ResourceItem
;
import
com.xabber.xmpp.vcard.Address
;
import
com.xabber.xmpp.vcard.AddressProperty
;
import
com.xabber.xmpp.vcard.AddressType
;
import
com.xabber.xmpp.vcard.Email
;
import
com.xabber.xmpp.vcard.EmailType
;
import
com.xabber.xmpp.vcard.NameProperty
;
import
com.xabber.xmpp.vcard.Organization
;
import
com.xabber.xmpp.vcard.Telephone
;
import
com.xabber.xmpp.vcard.TelephoneType
;
import
com.xabber.xmpp.vcard.VCard
;
import
com.xabber.xmpp.vcard.VCardProperty
;
import
com.xabber.xmpp.vcard.VCardProvider
;
import
org.jivesoftware.smackx.vcardtemp.packet.VCard
;
import
org.jivesoftware.smackx.vcardtemp.provider.VCardProvider
;
import
org.xmlpull.v1.XmlPullParser
;
import
org.xmlpull.v1.XmlPullParserFactory
;
...
...
@@ -46,7 +41,7 @@ import java.util.ArrayList;
import
java.util.Collection
;
import
java.util.List
;
public
class
ContactVcardViewerFragment
extends
Fragment
implements
On
VCardListener
,
OnContactChangedListener
,
OnAccountChange
dListener
{
public
class
ContactVcardViewerFragment
extends
Fragment
implements
On
ContactChangedListener
,
OnAccountChangedListener
,
OnVCar
dListener
{
public
static
final
String
ARGUMENT_ACCOUNT
=
"com.xabber.android.ui.ContactVcardViewerFragment.ARGUMENT_ACCOUNT"
;
public
static
final
String
ARGUMENT_USER
=
"com.xabber.android.ui.ContactVcardViewerFragment.ARGUMENT_USER"
;
private
static
final
String
SAVED_VCARD
=
"com.xabber.android.ui.ContactVcardViewerFragment.SAVED_VCARD"
;
...
...
@@ -91,13 +86,13 @@ public class ContactVcardViewerFragment extends Fragment implements OnVCardListe
if
(
eventType
!=
XmlPullParser
.
START_TAG
)
{
throw
new
IllegalStateException
(
String
.
valueOf
(
eventType
));
}
if
(!
VCard
.
ELEMENT
_NAME
.
equals
(
parser
.
getName
()))
{
if
(!
VCard
.
ELEMENT
.
equals
(
parser
.
getName
()))
{
throw
new
IllegalStateException
(
parser
.
getName
());
}
if
(!
VCard
.
NAMESPACE
.
equals
(
parser
.
getNamespace
()))
{
throw
new
IllegalStateException
(
parser
.
getNamespace
());
}
vCard
=
(
VCard
)
(
new
VCardProvider
()).
parse
(
parser
);
vCard
=
(
new
VCardProvider
()).
parse
(
parser
);
}
catch
(
Exception
e
)
{
LogManager
.
exception
(
this
,
e
);
}
...
...
@@ -124,7 +119,7 @@ public class ContactVcardViewerFragment extends Fragment implements OnVCardListe
Application
.
getInstance
().
addUIListener
(
OnContactChangedListener
.
class
,
this
);
Application
.
getInstance
().
addUIListener
(
OnAccountChangedListener
.
class
,
this
);
if
(
vCard
==
null
&&
!
vCardError
)
{
VCardManager
.
getInstance
().
request
(
account
,
user
,
null
);
VCardManager
.
getInstance
().
request
(
account
,
user
);
}
updateContact
(
account
,
user
);
...
...
@@ -292,13 +287,13 @@ public class ContactVcardViewerFragment extends Fragment implements OnVCardListe
addNameInfo
(
vCard
);
List
<
View
>
birthDayList
=
new
ArrayList
<>();
addItem
(
birthDayList
,
contactInfoItems
,
getString
(
R
.
string
.
vcard_birth_date
),
vCard
.
getField
(
VCardProperty
.
BDAY
));
addItem
(
birthDayList
,
contactInfoItems
,
getString
(
R
.
string
.
vcard_birth_date
),
vCard
.
getField
(
VCardProperty
.
BDAY
.
toString
()
));
addItemGroup
(
birthDayList
,
contactInfoItems
,
R
.
drawable
.
ic_vcard_birthday_24dp
);
addOrganizationInfo
(
vCard
);
List
<
View
>
webList
=
new
ArrayList
<>();
addItem
(
webList
,
contactInfoItems
,
getString
(
R
.
string
.
vcard_url
),
vCard
.
getField
(
VCardProperty
.
URL
));
addItem
(
webList
,
contactInfoItems
,
getString
(
R
.
string
.
vcard_url
),
vCard
.
getField
(
VCardProperty
.
URL
.
toString
()
));
addItemGroup
(
webList
,
contactInfoItems
,
R
.
drawable
.
ic_vcard_web_24dp
);
addAdditionalInfo
(
vCard
);
...
...
@@ -309,13 +304,15 @@ public class ContactVcardViewerFragment extends Fragment implements OnVCardListe
private
void
addEmails
(
VCard
vCard
)
{
List
<
View
>
emailList
=
new
ArrayList
<>();
for
(
Email
email
:
vCard
.
getEmails
())
{
String
types
=
null
;
for
(
EmailType
type
:
email
.
getTypes
())
{
types
=
addString
(
types
,
getString
(
VcardMaps
.
getEmailTypeMap
().
get
(
type
)),
", "
);
}
addItem
(
emailList
,
contactInfoItems
,
types
,
email
.
getValue
());
String
emailHome
=
vCard
.
getEmailHome
();
if
(!
""
.
equals
(
emailHome
))
{
addItem
(
emailList
,
contactInfoItems
,
getString
(
VcardMaps
.
getEmailTypeMap
().
get
(
EmailType
.
HOME
)),
emailHome
);
}
String
emailWork
=
vCard
.
getEmailWork
();
if
(!
""
.
equals
(
emailWork
))
{
addItem
(
emailList
,
contactInfoItems
,
getString
(
VcardMaps
.
getEmailTypeMap
().
get
(
EmailType
.
WORK
)),
emailWork
);
}
addItemGroup
(
emailList
,
contactInfoItems
,
R
.
drawable
.
ic_vcard_email_24dp
);
...
...
@@ -323,13 +320,27 @@ public class ContactVcardViewerFragment extends Fragment implements OnVCardListe
private
void
addPhones
(
VCard
vCard
)
{
List
<
View
>
phoneList
=
new
ArrayList
<>();
for
(
Telephone
telephone
:
vCard
.
getTelephones
())
{
String
types
=
null
;
for
(
TelephoneType
type
:
telephone
.
getTypes
())
{
for
(
TelephoneType
type
:
TelephoneType
.
values
())
{
String
types
=
getString
(
VcardMaps
.
getTelephoneTypeMap
().
get
(
TelephoneType
.
HOME
));
String
phoneHome
=
vCard
.
getPhoneHome
(
type
.
name
());
if
(!
""
.
equals
(
phoneHome
))
{
types
=
addString
(
types
,
getString
(
VcardMaps
.
getTelephoneTypeMap
().
get
(
type
)),
", "
);
addItem
(
phoneList
,
contactInfoItems
,
types
,
phoneHome
);
}
}
for
(
TelephoneType
type
:
TelephoneType
.
values
())
{
String
types
=
getString
(
VcardMaps
.
getTelephoneTypeMap
().
get
(
TelephoneType
.
WORK
));
String
phoneHome
=
vCard
.
getPhoneWork
(
type
.
name
());
addItem
(
phoneList
,
contactInfoItems
,
types
,
telephone
.
getValue
());
if
(!
""
.
equals
(
phoneHome
))
{
types
=
addString
(
types
,
getString
(
VcardMaps
.
getTelephoneTypeMap
().
get
(
type
)),
", "
);
addItem
(
phoneList
,
contactInfoItems
,
types
,
phoneHome
);
}
}
addItemGroup
(
phoneList
,
contactInfoItems
,
R
.
drawable
.
ic_vcard_phone_24dp
);
...
...
@@ -338,53 +349,40 @@ public class ContactVcardViewerFragment extends Fragment implements OnVCardListe
private
void
addAddresses
(
VCard
vCard
)
{
List
<
View
>
addressList
=
new
ArrayList
<>();
for
(
Address
address
:
vCard
.
getAddresses
())
{
String
types
=
null
;
for
(
AddressType
type
:
address
.
getTypes
())
{
types
=
addString
(
types
,
getString
(
VcardMaps
.
getAddressTypeMap
().
get
(
type
)),
", "
);
}
String
homeAddress
=
null
;
for
(
AddressProperty
property
:
AddressProperty
.
values
())
{
homeAddress
=
addString
(
homeAddress
,
vCard
.
getAddressFieldHome
(
property
.
name
()),
"\n"
);
}
String
value
=
null
;
for
(
AddressProperty
property
:
AddressProperty
.
values
())
{
value
=
addString
(
value
,
address
.
getProperties
().
get
(
property
),
"\n"
);
}
addItem
(
addressList
,
contactInfoItems
,
getString
(
VcardMaps
.
getAddressTypeMap
().
get
(
AddressType
.
HOME
)),
homeAddress
);
addItem
(
addressList
,
contactInfoItems
,
types
,
value
);
String
workAddress
=
null
;
for
(
AddressProperty
property
:
AddressProperty
.
values
())
{
workAddress
=
addString
(
workAddress
,
vCard
.
getAddressFieldWork
(
property
.
name
()),
"\n"
);
}
addItem
(
addressList
,
contactInfoItems
,
getString
(
VcardMaps
.
getAddressTypeMap
().
get
(
AddressType
.
WORK
)),
workAddress
);
addItemGroup
(
addressList
,
contactInfoItems
,
R
.
drawable
.
ic_vcard_address_24dp
);
}
private
void
addAdditionalInfo
(
VCard
vCard
)
{
String
categories
=
null
;
for
(
String
category
:
vCard
.
getCategories
())
{
categories
=
addString
(
categories
,
category
,
"\n"
);
}
List
<
View
>
notesList
=
new
ArrayList
<>();
addItem
(
notesList
,
contactInfoItems
,
getString
(
R
.
string
.
vcard_categories
),
categories
);
addItem
(
notesList
,
contactInfoItems
,
getString
(
R
.
string
.
vcard_note
),
vCard
.
getField
(
VCardProperty
.
NOTE
));
addItem
(
notesList
,
contactInfoItems
,
getString
(
R
.
string
.
vcard_decsription
),
vCard
.
getField
(
VCardProperty
.
DESC
));
addItem
(
notesList
,
contactInfoItems
,
getString
(
R
.
string
.
vcard_note
),
vCard
.
getField
(
VCardProperty
.
NOTE
.
name
()));
addItem
(
notesList
,
contactInfoItems
,
getString
(
R
.
string
.
vcard_decsription
),
vCard
.
getField
(
VCardProperty
.
DESC
.
name
()));
addItemGroup
(
notesList
,
contactInfoItems
,
R
.
drawable
.
ic_vcard_notes_24dp
);
}
private
void
addOrganizationInfo
(
VCard
vCard
)
{
List
<
View
>
organizationList
=
new
ArrayList
<>();
addItem
(
organizationList
,
contactInfoItems
,
getString
(
R
.
string
.
vcard_title
),
vCard
.
getField
(
VCardProperty
.
TITLE
));
addItem
(
organizationList
,
contactInfoItems
,
getString
(
R
.
string
.
vcard_role
),
vCard
.
getField
(
VCardProperty
.
ROLE
));
List
<
Organization
>
organizations
=
vCard
.
getOrganizations
();
String
organization
;
if
(
organizations
.
isEmpty
())
{
organization
=
null
;
}
else
{
organization
=
organizations
.
get
(
0
).
getName
();
for
(
String
unit
:
organizations
.
get
(
0
).
getUnits
())
{
organization
=
addString
(
organization
,
unit
,
"\n"
);
}
}
addItem
(
organizationList
,
contactInfoItems
,
getString
(
R
.
string
.
vcard_organization
),
organization
);
addItem
(
organizationList
,
contactInfoItems
,
getString
(
R
.
string
.
vcard_title
),
vCard
.
getField
(
VCardProperty
.
TITLE
.
toString
()));
addItem
(
organizationList
,
contactInfoItems
,
getString
(
R
.
string
.
vcard_role
),
vCard
.
getField
(
VCardProperty
.
ROLE
.
toString
()));
String
organization
=
vCard
.
getOrganization
();
String
unit
=
vCard
.
getOrganizationUnit
();
addItem
(
organizationList
,
contactInfoItems
,
getString
(
R
.
string
.
vcard_organization
),
addString
(
organization
,
unit
,
"\n"
));
addItemGroup
(
organizationList
,
contactInfoItems
,
R
.
drawable
.
ic_vcard_job_title_24dp
);
}
...
...
@@ -392,13 +390,14 @@ public class ContactVcardViewerFragment extends Fragment implements OnVCardListe
private
void
addNameInfo
(
VCard
vCard
)
{
List
<
View
>
nameList
=
new
ArrayList
<>();
addItem
(
nameList
,
contactInfoItems
,
getString
(
R
.
string
.
vcard_nick_name
),
vCard
.
getField
(
VCardProperty
.
NICKNAME
));
addItem
(
nameList
,
contactInfoItems
,
getString
(
R
.
string
.
vcard_formatted_name
),
vCard
.
getFormattedName
());
addItem
(
nameList
,
contactInfoItems
,
getString
(
R
.
string
.
vcard_prefix_name
),
vCard
.
getField
(
NameProperty
.
PREFIX
));
addItem
(
nameList
,
contactInfoItems
,
getString
(
R
.
string
.
vcard_given_name
),
vCard
.
getField
(
NameProperty
.
GIVEN
));
addItem
(
nameList
,
contactInfoItems
,
getString
(
R
.
string
.
vcard_middle_name
),
vCard
.
getField
(
NameProperty
.
MIDDLE
));
addItem
(
nameList
,
contactInfoItems
,
getString
(
R
.
string
.
vcard_family_name
),
vCard
.
getField
(
NameProperty
.
FAMILY
));
addItem
(
nameList
,
contactInfoItems
,
getString
(
R
.
string
.
vcard_suffix_name
),
vCard
.
getField
(
NameProperty
.
SUFFIX
));
addItem
(
nameList
,
contactInfoItems
,
getString
(
R
.
string
.
vcard_nick_name
),
vCard
.
getField
(
VCardProperty
.
NICKNAME
.
name
()));
addItem
(
nameList
,
contactInfoItems
,
getString
(
R
.
string
.
vcard_formatted_name
),
vCard
.
getField
(
VCardProperty
.
FN
.
name
()));
addItem
(
nameList
,
contactInfoItems
,
getString
(
R
.
string
.
vcard_prefix_name
),
vCard
.
getPrefix
());
addItem
(
nameList
,
contactInfoItems
,
getString
(
R
.
string
.
vcard_given_name
),
vCard
.
getFirstName
());
addItem
(
nameList
,
contactInfoItems
,
getString
(
R
.
string
.
vcard_middle_name
),
vCard
.
getMiddleName
());
addItem
(
nameList
,
contactInfoItems
,
getString
(
R
.
string
.
vcard_family_name
),
vCard
.
getLastName
());
addItem
(
nameList
,
contactInfoItems
,
getString
(
R
.
string
.
vcard_suffix_name
),
vCard
.
getSuffix
());
addItemGroup
(
nameList
,
contactInfoItems
,
R
.
drawable
.
ic_vcard_contact_info_24dp
);
}
...
...
app/src/main/java/com/xabber/xmpp/vcard/AbstractBinaryData.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
com.xabber.xmpp.SerializerUtils
;
import
org.jivesoftware.smack.util.stringencoder.Base64
;
import
org.xmlpull.v1.XmlSerializer
;
import
java.io.IOException
;
public
abstract
class
AbstractBinaryData
extends
AbstractData
{
/**
* Limit received encoded data size.
*/
public
static
final
int
MAX_ENCODED_DATA_SIZE
=
256
*
1024
;
public
static
final
String
TYPE_NAME
=
"TYPE"
;
public
static
final
String
BINVAL_NAME
=
"BINVAL"
;
private
String
type
;
private
byte
[]
data
;
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
byte
[]
getData
()
{
return
data
;
}
public
void
setData
(
byte
[]
data
)
{
this
.
data
=
data
;
}
@Override
public
boolean
isValid
()
{
return
type
!=
null
&&
data
!=
null
;
}
@Override
protected
void
writeBody
(
XmlSerializer
serializer
)
throws
IOException
{
SerializerUtils
.
addTextTag
(
serializer
,
TYPE_NAME
,
type
);
SerializerUtils
.
addTextTag
(
serializer
,
BINVAL_NAME
,
Base64
.
encodeToString
(
data
));
}
}
app/src/main/java/com/xabber/xmpp/vcard/AbstractData.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
java.io.IOException
;
import
org.xmlpull.v1.XmlSerializer
;
import
com.xabber.xmpp.Instance
;
public
abstract
class
AbstractData
implements
Instance
{
@Override
public
void
serialize
(
XmlSerializer
serializer
)
throws
IOException
{
serializer
.
startTag
(
null
,
getElementName
());
writeBody
(
serializer
);
serializer
.
endTag
(
null
,
getElementName
());
}
public
abstract
String
getElementName
();
protected
abstract
void
writeBody
(
XmlSerializer
serializer
)
throws
IOException
;
}
app/src/main/java/com/xabber/xmpp/vcard/AbstractDataProvider.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
com.xabber.xmpp.AbstractProvider
;
import
com.xabber.xmpp.Instance
;
import
com.xabber.xmpp.ProviderUtils
;
import
org.jivesoftware.smack.util.stringencoder.Base64
;
import
org.xmlpull.v1.XmlPullParser
;
import
org.xmlpull.v1.XmlPullParserException
;
import
java.io.IOException
;
abstract
class
AbstractDataProvider
<
T
extends
Instance
,
Inner
extends
DataHolder
<
T
>>
extends
AbstractProvider
<
Inner
>
{
@Override
protected
boolean
parseInner
(
XmlPullParser
parser
,
Inner
instance
)
throws
IOException
,
XmlPullParserException
{
if
(
super
.
parseInner
(
parser
,
instance
))
return
true
;
if
(
instance
.
getPayload
()
==
null
)
if
(!
createPayload
(
parser
,
instance
))
return
false
;
return
inflatePayload
(
parser
,
instance
);
}
protected
boolean
createPayload
(
XmlPullParser
parser
,
Inner
instance
)
{
if
(
AbstractBinaryData
.
TYPE_NAME
.
equals
(
parser
.
getName
())
||
AbstractBinaryData
.
BINVAL_NAME
.
equals
(
parser
.
getName
()))
instance
.
setPayload
(
createBinaryData
());
else
if
(
AbstractExternalData
.
EXTVAL_NAME
.
equals
(
parser
.
getName
()))
instance
.
setPayload
(
createExternalData
());
else
return
false
;
return
true
;
}
protected
abstract
T
createBinaryData
();
protected
abstract
T
createExternalData
();
protected
boolean
inflatePayload
(
XmlPullParser
parser
,
Inner
instance
)
throws
IOException
,
XmlPullParserException
{
if
(
instance
.
getPayload
()
instanceof
AbstractBinaryData
)
return
inflateBinaryData
(
parser
,
(
AbstractBinaryData
)
instance
.
getPayload
());
else
if
(
instance
.
getPayload
()
instanceof
AbstractExternalData
)
return
inflateExternalData
(
parser
,
(
AbstractExternalData
)
instance
.
getPayload
());
else
return
false
;
}
protected
boolean
inflateBinaryData
(
XmlPullParser
parser
,
AbstractBinaryData
payload
)
throws
IOException
,
XmlPullParserException
{
if
(
AbstractBinaryData
.
TYPE_NAME
.
equals
(
parser
.
getName
()))
payload
.
setType
(
ProviderUtils
.
parseText
(
parser
));
else
if
(
AbstractBinaryData
.
BINVAL_NAME
.
equals
(
parser
.
getName
()))
{
String
value
;
try
{
value
=
ProviderUtils
.
parseText
(
parser
,
AbstractBinaryData
.
MAX_ENCODED_DATA_SIZE
);
}
catch
(
Exception
e
)
{
return
true
;
}
payload
.
setData
(
Base64
.
decode
(
value
));
}
else
return
false
;
return
true
;
}
protected
boolean
inflateExternalData
(
XmlPullParser
parser
,
AbstractExternalData
payload
)
throws
IOException
,
XmlPullParserException
{
if
(
AbstractExternalData
.
EXTVAL_NAME
.
equals
(
parser
.
getName
()))
payload
.
setValue
(
ProviderUtils
.
parseText
(
parser
));
else
return
false
;
return
true
;
}
}
\ No newline at end of file
app/src/main/java/com/xabber/xmpp/vcard/AbstractExternalData.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
java.io.IOException
;
import
org.xmlpull.v1.XmlSerializer
;
import
com.xabber.xmpp.SerializerUtils
;
public
abstract
class
AbstractExternalData
extends
AbstractData
{
public
static
final
String
EXTVAL_NAME
=
"EXTVAL"
;
private
String
value
;
public
String
getValue
()
{
return
value
;
}
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
}
@Override
public
boolean
isValid
()
{
return
value
!=
null
;
}
@Override
protected
void
writeBody
(
XmlSerializer
serializer
)
throws
IOException
{
SerializerUtils
.
addTextTag
(
serializer
,
EXTVAL_NAME
,
value
);
}
}
app/src/main/java/com/xabber/xmpp/vcard/AbstractTypedData.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
java.io.IOException
;
import
java.util.HashSet
;
import
java.util.Set
;
import
org.xmlpull.v1.XmlSerializer
;
import
com.xabber.xmpp.Instance
;
public
abstract
class
AbstractTypedData
<
Type
extends
Enum
<?>>
implements
Instance
{
protected
final
Set
<
Type
>
types
;
public
AbstractTypedData
()
{
types
=
new
HashSet
<
Type
>();
}
@Override
public
void
serialize
(
XmlSerializer
serializer
)
throws
IOException
{
serializer
.
startTag
(
null
,
getElementName
());
for
(
Type
type
:
types
)
{
serializer
.
startTag
(
null
,
type
.
toString
());
serializer
.
endTag
(
null
,
type
.
toString
());
}
writeBody
(
serializer
);
serializer
.
endTag
(
null
,
getElementName
());
}
protected
abstract
String
getElementName
();
protected
abstract
void
writeBody
(
XmlSerializer
serializer
)
throws
IOException
;
public
Set
<
Type
>
getTypes
()
{
return
types
;
}
}
app/src/main/java/com/xabber/xmpp/vcard/AbstractTypedDataProvider.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
org.xmlpull.v1.XmlPullParser
;
import
org.xmlpull.v1.XmlPullParserException
;
import
com.xabber.xmpp.AbstractProvider
;
import
com.xabber.xmpp.ProviderUtils
;
import
java.io.IOException
;
abstract
class
AbstractTypedDataProvider
<
Type
extends
Enum
<?>,
Instance
extends
AbstractTypedData
<
Type
>>
extends
AbstractProvider
<
Instance
>
{
@Override
protected
boolean
parseInner
(
XmlPullParser
parser
,
Instance
instance
)
throws
IOException
,
XmlPullParserException
{
if
(
super
.
parseInner
(
parser
,
instance
))
return
true
;
String
name
=
parser
.
getName
();
for
(
Type
type
:
getTypes
())
if
(
type
.
toString
().
equals
(
name
))
{
instance
.
getTypes
().
add
(
type
);
ProviderUtils
.
skipTag
(
parser
);
return
true
;
}
return
false
;
}
protected
abstract
Type
[]
getTypes
();
}
app/src/main/java/com/xabber/xmpp/vcard/AbstractTypedDataWithValue.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
java.io.IOException
;
import
org.xmlpull.v1.XmlSerializer
;
import
com.xabber.xmpp.SerializerUtils
;
public
abstract
class
AbstractTypedDataWithValue
<
Type
extends
Enum
<?>>
extends
AbstractTypedData
<
Type
>
{
private
String
value
;
public
AbstractTypedDataWithValue
()
{
super
();
}
public
String
getValue
()
{
return
value
;
}
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
}
protected
abstract
String
getValueName
();
@Override
protected
void
writeBody
(
XmlSerializer
serializer
)
throws
IOException
{
SerializerUtils
.
addTextTag
(
serializer
,
getValueName
(),
value
);
}
@Override
public
boolean
isValid
()
{
return
value
!=
null
;
}
}
app/src/main/java/com/xabber/xmpp/vcard/AbstractTypedDataWithValueProvider.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
org.xmlpull.v1.XmlPullParser
;
import
org.xmlpull.v1.XmlPullParserException
;
import
com.xabber.xmpp.ProviderUtils
;
import
java.io.IOException
;
public
abstract
class
AbstractTypedDataWithValueProvider
<
Type
extends
Enum
<?>,
Instance
extends
AbstractTypedDataWithValue
<
Type
>>
extends
AbstractTypedDataProvider
<
Type
,
Instance
>
{
@Override
protected
boolean
parseInner
(
XmlPullParser
parser
,
Instance
instance
)
throws
IOException
,
XmlPullParserException
{
if
(
super
.
parseInner
(
parser
,
instance
))
return
true
;
if
(
getValueName
().
equals
(
parser
.
getName
()))
{
instance
.
setValue
(
ProviderUtils
.
parseText
(
parser
));
return
true
;
}
return
false
;
}
protected
abstract
String
getValueName
();
}
app/src/main/java/com/xabber/xmpp/vcard/Address.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
org.xmlpull.v1.XmlSerializer
;
import
com.xabber.xmpp.SerializerUtils
;
public
class
Address
extends
AbstractTypedData
<
AddressType
>
{
public
static
final
String
ELEMENT_NAME
=
"ADR"
;
protected
final
Map
<
AddressProperty
,
String
>
properties
;
public
Address
()
{
super
();
properties
=
new
HashMap
<
AddressProperty
,
String
>();
}
public
Map
<
AddressProperty
,
String
>
getProperties
()
{
return
properties
;
}
@Override
protected
String
getElementName
()
{
return
ELEMENT_NAME
;
}
@Override
protected
void
writeBody
(
XmlSerializer
serializer
)
throws
IOException
{
for
(
Entry
<
AddressProperty
,
String
>
entry
:
properties
.
entrySet
())
SerializerUtils
.
addTextTag
(
serializer
,
entry
.
getKey
().
toString
(),
entry
.
getValue
());
}
@Override
public
boolean
isValid
()
{
return
AddressType
.
isValid
(
types
);
}
}
app/src/main/java/com/xabber/xmpp/vcard/AddressProvider.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
org.xmlpull.v1.XmlPullParser
;
import
org.xmlpull.v1.XmlPullParserException
;
import
com.xabber.xmpp.ProviderUtils
;
import
java.io.IOException
;
class
AddressProvider
extends
AbstractTypedDataProvider
<
AddressType
,
Address
>
{
@Override
protected
boolean
parseInner
(
XmlPullParser
parser
,
Address
instance
)
throws
IOException
,
XmlPullParserException
{
if
(
super
.
parseInner
(
parser
,
instance
))
return
true
;
String
name
=
parser
.
getName
();
for
(
AddressProperty
key
:
AddressProperty
.
values
())
if
(
key
.
toString
().
equals
(
name
))
{
instance
.
getProperties
().
put
(
key
,
ProviderUtils
.
parseText
(
parser
));
return
true
;
}
return
false
;
}
@Override
protected
AddressType
[]
getTypes
()
{
return
AddressType
.
values
();
}
@Override
protected
Address
createInstance
(
XmlPullParser
parser
)
{
return
new
Address
();
}
private
AddressProvider
()
{
}
private
static
final
AddressProvider
instance
=
new
AddressProvider
();
public
static
AddressProvider
getInstance
()
{
return
instance
;
}
}
app/src/main/java/com/xabber/xmpp/vcard/BinaryLogo.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
public
class
BinaryLogo
extends
AbstractBinaryData
implements
Logo
{
@Override
public
String
getElementName
()
{
return
Logo
.
ELEMENT_NAME
;
}
}
app/src/main/java/com/xabber/xmpp/vcard/BinaryPhoto.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
public
class
BinaryPhoto
extends
AbstractBinaryData
implements
Photo
{
@Override
public
String
getElementName
()
{
return
Photo
.
ELEMENT_NAME
;
}
}
app/src/main/java/com/xabber/xmpp/vcard/BinarySound.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
public
class
BinarySound
extends
AbstractBinaryData
implements
Sound
{
@Override
public
String
getElementName
()
{
return
Sound
.
ELEMENT_NAME
;
}
}
app/src/main/java/com/xabber/xmpp/vcard/CategoriesInflater.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
org.xmlpull.v1.XmlPullParser
;
import
org.xmlpull.v1.XmlPullParserException
;
import
com.xabber.xmpp.AbstractInflater
;
import
com.xabber.xmpp.ProviderUtils
;
import
java.io.IOException
;
class
CategoriesInflater
extends
AbstractInflater
<
VCard
>
{
@Override
protected
boolean
parseInner
(
XmlPullParser
parser
,
VCard
instance
)
throws
IOException
,
XmlPullParserException
{
if
(
super
.
parseInner
(
parser
,
instance
))
return
true
;
if
(
VCard
.
KEYWORD_NAME
.
equals
(
parser
.
getName
()))
instance
.
getCategories
().
add
(
ProviderUtils
.
parseText
(
parser
));
else
return
false
;
return
true
;
}
private
CategoriesInflater
()
{
}
private
static
final
CategoriesInflater
instance
=
new
CategoriesInflater
();
public
static
CategoriesInflater
getInstance
()
{
return
instance
;
}
}
app/src/main/java/com/xabber/xmpp/vcard/Classification.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
public
enum
Classification
{
PUBLIC
,
PRIVATE
,
CONFIDENTIAL
}
app/src/main/java/com/xabber/xmpp/vcard/ClassificationInflater.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
org.xmlpull.v1.XmlPullParser
;
import
org.xmlpull.v1.XmlPullParserException
;
import
com.xabber.xmpp.AbstractInflater
;
import
com.xabber.xmpp.ProviderUtils
;
import
java.io.IOException
;
class
ClassificationInflater
extends
AbstractInflater
<
VCard
>
{
@Override
protected
boolean
parseInner
(
XmlPullParser
parser
,
VCard
instance
)
throws
IOException
,
XmlPullParserException
{
if
(
super
.
parseInner
(
parser
,
instance
))
return
true
;
String
name
=
parser
.
getName
();
for
(
Classification
value
:
Classification
.
values
())
if
(
value
.
toString
().
equals
(
name
))
{
instance
.
setClassification
(
value
);
ProviderUtils
.
skipTag
(
parser
);
return
true
;
}
return
false
;
}
private
ClassificationInflater
()
{
}
private
static
final
ClassificationInflater
instance
=
new
ClassificationInflater
();
public
static
ClassificationInflater
getInstance
()
{
return
instance
;
}
}
app/src/main/java/com/xabber/xmpp/vcard/DataHolder.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
java.io.IOException
;
import
org.xmlpull.v1.XmlSerializer
;
import
com.xabber.xmpp.Instance
;
/**
* Holder for the some object.
*
* @param <T>
* @author alexander.ivanov
*/
class
DataHolder
<
T
extends
Instance
>
implements
Instance
{
private
T
payload
;
@Override
public
boolean
isValid
()
{
return
payload
!=
null
&&
payload
.
isValid
();
}
public
T
getPayload
()
{
return
payload
;
}
public
void
setPayload
(
T
payload
)
{
this
.
payload
=
payload
;
}
@Override
public
void
serialize
(
XmlSerializer
serializer
)
throws
IOException
{
// TODO:
throw
new
UnsupportedOperationException
();
}
}
\ No newline at end of file
app/src/main/java/com/xabber/xmpp/vcard/Email.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
public
class
Email
extends
AbstractTypedDataWithValue
<
EmailType
>
{
public
static
final
String
ELEMENT_NAME
=
"EMAIL"
;
public
static
final
String
USERID_NAME
=
"USERID"
;
public
Email
()
{
super
();
}
@Override
protected
String
getElementName
()
{
return
ELEMENT_NAME
;
}
@Override
protected
String
getValueName
()
{
return
USERID_NAME
;
}
}
app/src/main/java/com/xabber/xmpp/vcard/EmailProvider.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
org.xmlpull.v1.XmlPullParser
;
class
EmailProvider
extends
AbstractTypedDataWithValueProvider
<
EmailType
,
Email
>
{
@Override
protected
String
getValueName
()
{
return
Email
.
USERID_NAME
;
}
@Override
protected
EmailType
[]
getTypes
()
{
return
EmailType
.
values
();
}
@Override
protected
Email
createInstance
(
XmlPullParser
parser
)
{
return
new
Email
();
}
private
EmailProvider
()
{
}
private
static
final
EmailProvider
instance
=
new
EmailProvider
();
public
static
EmailProvider
getInstance
()
{
return
instance
;
}
}
app/src/main/java/com/xabber/xmpp/vcard/ExternalLogo.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
public
class
ExternalLogo
extends
AbstractExternalData
implements
Logo
{
@Override
public
String
getElementName
()
{
return
Logo
.
ELEMENT_NAME
;
}
}
app/src/main/java/com/xabber/xmpp/vcard/ExternalPhoto.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
public
class
ExternalPhoto
extends
AbstractExternalData
implements
Photo
{
@Override
public
String
getElementName
()
{
return
Photo
.
ELEMENT_NAME
;
}
}
app/src/main/java/com/xabber/xmpp/vcard/ExternalSound.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
public
class
ExternalSound
extends
AbstractExternalData
implements
Sound
{
@Override
public
String
getElementName
()
{
return
Sound
.
ELEMENT_NAME
;
}
}
app/src/main/java/com/xabber/xmpp/vcard/Geo.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
java.io.IOException
;
import
org.xmlpull.v1.XmlSerializer
;
import
com.xabber.xmpp.Instance
;
import
com.xabber.xmpp.SerializerUtils
;
public
class
Geo
implements
Instance
{
public
static
final
String
ELEMENT_NAME
=
"GEO"
;
public
static
final
String
LAT_NAME
=
"LAT"
;
public
static
final
String
LON_NAME
=
"LON"
;
private
String
lat
;
private
String
lon
;
public
String
getLat
()
{
return
lat
;
}
public
void
setLat
(
String
lat
)
{
this
.
lat
=
lat
;
}
public
String
getLon
()
{
return
lon
;
}
public
void
setLon
(
String
lon
)
{
this
.
lon
=
lon
;
}
@Override
public
boolean
isValid
()
{
return
lat
!=
null
&&
lon
!=
null
;
}
@Override
public
void
serialize
(
XmlSerializer
serializer
)
throws
IOException
{
serializer
.
startTag
(
null
,
ELEMENT_NAME
);
SerializerUtils
.
addTextTag
(
serializer
,
LAT_NAME
,
lat
);
SerializerUtils
.
addTextTag
(
serializer
,
LON_NAME
,
lon
);
serializer
.
endTag
(
null
,
ELEMENT_NAME
);
}
}
app/src/main/java/com/xabber/xmpp/vcard/GeoProvider.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
org.xmlpull.v1.XmlPullParser
;
import
org.xmlpull.v1.XmlPullParserException
;
import
com.xabber.xmpp.AbstractProvider
;
import
com.xabber.xmpp.ProviderUtils
;
import
java.io.IOException
;
class
GeoProvider
extends
AbstractProvider
<
Geo
>
{
@Override
protected
boolean
parseInner
(
XmlPullParser
parser
,
Geo
instance
)
throws
IOException
,
XmlPullParserException
{
if
(
super
.
parseInner
(
parser
,
instance
))
return
true
;
if
(
Geo
.
LAT_NAME
.
equals
(
parser
.
getName
()))
instance
.
setLat
(
ProviderUtils
.
parseText
(
parser
));
else
if
(
Geo
.
LON_NAME
.
equals
(
parser
.
getName
()))
instance
.
setLon
(
ProviderUtils
.
parseText
(
parser
));
else
return
false
;
return
true
;
}
@Override
protected
Geo
createInstance
(
XmlPullParser
parser
)
{
return
new
Geo
();
}
private
GeoProvider
()
{
}
private
static
final
GeoProvider
instance
=
new
GeoProvider
();
public
static
GeoProvider
getInstance
()
{
return
instance
;
}
}
app/src/main/java/com/xabber/xmpp/vcard/Key.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
java.io.IOException
;
import
org.xmlpull.v1.XmlSerializer
;
import
com.xabber.xmpp.Instance
;
import
com.xabber.xmpp.SerializerUtils
;
public
class
Key
implements
Instance
{
/**
* Limit received encoded data size.
*/
public
static
final
int
MAX_ENCODED_DATA_SIZE
=
64
*
1024
;
public
static
final
String
ELEMENT_NAME
=
"KEY"
;
public
static
final
String
TYPE_NAME
=
"TYPE"
;
public
static
final
String
CRED_NAME
=
"CRED"
;
private
String
type
;
private
String
encodedData
;
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
String
getEncodedData
()
{
return
encodedData
;
}
public
void
setEncodedData
(
String
encodedData
)
{
this
.
encodedData
=
encodedData
;
}
@Override
public
boolean
isValid
()
{
return
encodedData
!=
null
;
}
@Override
public
void
serialize
(
XmlSerializer
serializer
)
throws
IOException
{
serializer
.
startTag
(
null
,
ELEMENT_NAME
);
if
(
type
!=
null
)
SerializerUtils
.
addTextTag
(
serializer
,
TYPE_NAME
,
type
);
SerializerUtils
.
addTextTag
(
serializer
,
CRED_NAME
,
encodedData
);
serializer
.
endTag
(
null
,
ELEMENT_NAME
);
}
}
app/src/main/java/com/xabber/xmpp/vcard/KeyProvider.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
com.xabber.xmpp.AbstractProvider
;
import
com.xabber.xmpp.ProviderUtils
;
import
org.xmlpull.v1.XmlPullParser
;
import
org.xmlpull.v1.XmlPullParserException
;
import
java.io.IOException
;
class
KeyProvider
extends
AbstractProvider
<
Key
>
{
@Override
protected
boolean
parseInner
(
XmlPullParser
parser
,
Key
instance
)
throws
IOException
,
XmlPullParserException
{
if
(
super
.
parseInner
(
parser
,
instance
))
return
true
;
if
(
Key
.
TYPE_NAME
.
equals
(
parser
.
getName
()))
instance
.
setType
(
ProviderUtils
.
parseText
(
parser
));
else
if
(
Key
.
CRED_NAME
.
equals
(
parser
.
getName
()))
{
String
value
;
try
{
value
=
ProviderUtils
.
parseText
(
parser
,
Key
.
MAX_ENCODED_DATA_SIZE
);
}
catch
(
Exception
e
)
{
return
true
;
}
instance
.
setEncodedData
(
value
);
}
else
return
false
;
return
true
;
}
@Override
protected
Key
createInstance
(
XmlPullParser
parser
)
{
return
new
Key
();
}
private
KeyProvider
()
{
}
private
static
final
KeyProvider
instance
=
new
KeyProvider
();
public
static
KeyProvider
getInstance
()
{
return
instance
;
}
}
app/src/main/java/com/xabber/xmpp/vcard/Label.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.xmlpull.v1.XmlSerializer
;
import
com.xabber.xmpp.SerializerUtils
;
public
class
Label
extends
AbstractTypedData
<
AddressType
>
{
public
static
final
String
ELEMENT_NAME
=
"LABEL"
;
public
static
final
String
LINE_NAME
=
"LINE"
;
private
final
List
<
String
>
lines
;
public
Label
()
{
super
();
lines
=
new
ArrayList
<
String
>();
}
public
List
<
String
>
getLines
()
{
return
lines
;
}
@Override
protected
String
getElementName
()
{
return
ELEMENT_NAME
;
}
@Override
protected
void
writeBody
(
XmlSerializer
serializer
)
throws
IOException
{
for
(
String
line
:
lines
)
SerializerUtils
.
addTextTag
(
serializer
,
LINE_NAME
,
line
);
}
@Override
public
boolean
isValid
()
{
return
AddressType
.
isValid
(
types
)
&&
!
lines
.
isEmpty
();
}
}
app/src/main/java/com/xabber/xmpp/vcard/LabelProvider.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
org.xmlpull.v1.XmlPullParser
;
import
org.xmlpull.v1.XmlPullParserException
;
import
com.xabber.xmpp.ProviderUtils
;
import
java.io.IOException
;
class
LabelProvider
extends
AbstractTypedDataProvider
<
AddressType
,
Label
>
{
@Override
protected
boolean
parseInner
(
XmlPullParser
parser
,
Label
instance
)
throws
IOException
,
XmlPullParserException
{
if
(
super
.
parseInner
(
parser
,
instance
))
return
true
;
if
(
Label
.
LINE_NAME
.
equals
(
parser
.
getName
()))
{
instance
.
getLines
().
add
(
ProviderUtils
.
parseText
(
parser
));
return
true
;
}
return
false
;
}
@Override
protected
AddressType
[]
getTypes
()
{
return
AddressType
.
values
();
}
@Override
protected
Label
createInstance
(
XmlPullParser
parser
)
{
return
new
Label
();
}
private
LabelProvider
()
{
}
private
static
final
LabelProvider
instance
=
new
LabelProvider
();
public
static
LabelProvider
getInstance
()
{
return
instance
;
}
}
app/src/main/java/com/xabber/xmpp/vcard/Logo.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
com.xabber.xmpp.Instance
;
public
interface
Logo
extends
Instance
{
String
ELEMENT_NAME
=
"LOGO"
;
}
app/src/main/java/com/xabber/xmpp/vcard/LogoHolderProvider.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
org.xmlpull.v1.XmlPullParser
;
class
LogoHolderProvider
extends
AbstractDataProvider
<
Logo
,
DataHolder
<
Logo
>>
{
@Override
protected
Logo
createBinaryData
()
{
return
new
BinaryLogo
();
}
@Override
protected
Logo
createExternalData
()
{
return
new
ExternalLogo
();
}
@Override
protected
DataHolder
<
Logo
>
createInstance
(
XmlPullParser
parser
)
{
return
new
DataHolder
<
Logo
>();
}
private
LogoHolderProvider
()
{
}
private
static
final
LogoHolderProvider
instance
=
new
LogoHolderProvider
();
public
static
LogoHolderProvider
getInstance
()
{
return
instance
;
}
}
\ No newline at end of file
app/src/main/java/com/xabber/xmpp/vcard/NameInflater.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
org.xmlpull.v1.XmlPullParser
;
import
org.xmlpull.v1.XmlPullParserException
;
import
com.xabber.xmpp.AbstractInflater
;
import
com.xabber.xmpp.ProviderUtils
;
import
java.io.IOException
;
class
NameInflater
extends
AbstractInflater
<
VCard
>
{
@Override
protected
boolean
parseInner
(
XmlPullParser
parser
,
VCard
instance
)
throws
IOException
,
XmlPullParserException
{
if
(
super
.
parseInner
(
parser
,
instance
))
return
true
;
String
name
=
parser
.
getName
();
for
(
NameProperty
key
:
NameProperty
.
values
())
if
(
key
.
toString
().
equals
(
name
))
{
instance
.
getName
().
put
(
key
,
ProviderUtils
.
parseText
(
parser
));
return
true
;
}
return
false
;
}
private
NameInflater
()
{
}
private
static
final
NameInflater
instance
=
new
NameInflater
();
public
static
NameInflater
getInstance
()
{
return
instance
;
}
}
app/src/main/java/com/xabber/xmpp/vcard/NameProperty.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
public
enum
NameProperty
{
FAMILY
,
GIVEN
,
MIDDLE
,
PREFIX
,
SUFFIX
}
app/src/main/java/com/xabber/xmpp/vcard/Organization.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.xmlpull.v1.XmlSerializer
;
import
com.xabber.xmpp.Instance
;
import
com.xabber.xmpp.SerializerUtils
;
public
class
Organization
implements
Instance
{
public
static
final
String
ELEMENT_NAME
=
"ORG"
;
public
static
final
String
ORGNAME_NAME
=
"ORGNAME"
;
public
static
final
String
ORGUNIT_NAME
=
"ORGUNIT"
;
private
String
name
;
private
final
List
<
String
>
units
;
public
Organization
()
{
units
=
new
ArrayList
<
String
>();
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
List
<
String
>
getUnits
()
{
return
units
;
}
@Override
public
boolean
isValid
()
{
return
name
!=
null
;
}
@Override
public
void
serialize
(
XmlSerializer
serializer
)
throws
IOException
{
serializer
.
startTag
(
null
,
ELEMENT_NAME
);
SerializerUtils
.
addTextTag
(
serializer
,
ORGNAME_NAME
,
name
);
for
(
String
unit
:
units
)
SerializerUtils
.
addTextTag
(
serializer
,
ORGUNIT_NAME
,
unit
);
serializer
.
endTag
(
null
,
ELEMENT_NAME
);
}
}
app/src/main/java/com/xabber/xmpp/vcard/OrganizationProvider.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
org.xmlpull.v1.XmlPullParser
;
import
org.xmlpull.v1.XmlPullParserException
;
import
com.xabber.xmpp.AbstractProvider
;
import
com.xabber.xmpp.ProviderUtils
;
import
java.io.IOException
;
class
OrganizationProvider
extends
AbstractProvider
<
Organization
>
{
@Override
protected
boolean
parseInner
(
XmlPullParser
parser
,
Organization
instance
)
throws
IOException
,
XmlPullParserException
{
if
(
super
.
parseInner
(
parser
,
instance
))
return
true
;
if
(
Organization
.
ORGNAME_NAME
.
equals
(
parser
.
getName
()))
instance
.
setName
(
ProviderUtils
.
parseText
(
parser
));
else
if
(
Organization
.
ORGUNIT_NAME
.
equals
(
parser
.
getName
()))
instance
.
getUnits
().
add
(
ProviderUtils
.
parseText
(
parser
));
else
return
false
;
return
true
;
}
@Override
protected
Organization
createInstance
(
XmlPullParser
parser
)
{
return
new
Organization
();
}
private
OrganizationProvider
()
{
}
private
static
final
OrganizationProvider
instance
=
new
OrganizationProvider
();
public
static
OrganizationProvider
getInstance
()
{
return
instance
;
}
}
app/src/main/java/com/xabber/xmpp/vcard/PhoneticSound.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
java.io.IOException
;
import
org.xmlpull.v1.XmlSerializer
;
import
com.xabber.xmpp.SerializerUtils
;
public
class
PhoneticSound
extends
AbstractData
implements
Sound
{
public
static
final
String
PHONETIC_NAME
=
"PHONETIC"
;
private
String
value
;
public
String
getValue
()
{
return
value
;
}
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
}
@Override
public
boolean
isValid
()
{
return
value
!=
null
;
}
@Override
protected
void
writeBody
(
XmlSerializer
serializer
)
throws
IOException
{
SerializerUtils
.
addTextTag
(
serializer
,
PHONETIC_NAME
,
value
);
}
@Override
public
String
getElementName
()
{
return
Sound
.
ELEMENT_NAME
;
}
}
app/src/main/java/com/xabber/xmpp/vcard/Photo.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
com.xabber.xmpp.Instance
;
public
interface
Photo
extends
Instance
{
String
ELEMENT_NAME
=
"PHOTO"
;
}
app/src/main/java/com/xabber/xmpp/vcard/PhotoHolderProvider.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
org.xmlpull.v1.XmlPullParser
;
class
PhotoHolderProvider
extends
AbstractDataProvider
<
Photo
,
DataHolder
<
Photo
>>
{
@Override
protected
Photo
createBinaryData
()
{
return
new
BinaryPhoto
();
}
@Override
protected
Photo
createExternalData
()
{
return
new
ExternalPhoto
();
}
@Override
protected
DataHolder
<
Photo
>
createInstance
(
XmlPullParser
parser
)
{
return
new
DataHolder
<
Photo
>();
}
private
PhotoHolderProvider
()
{
}
private
static
final
PhotoHolderProvider
instance
=
new
PhotoHolderProvider
();
public
static
PhotoHolderProvider
getInstance
()
{
return
instance
;
}
}
\ No newline at end of file
app/src/main/java/com/xabber/xmpp/vcard/Sound.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
com.xabber.xmpp.Instance
;
public
interface
Sound
extends
Instance
{
String
ELEMENT_NAME
=
"SOUND"
;
}
app/src/main/java/com/xabber/xmpp/vcard/SoundHolderProvider.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
org.xmlpull.v1.XmlPullParser
;
import
org.xmlpull.v1.XmlPullParserException
;
import
com.xabber.xmpp.ProviderUtils
;
import
java.io.IOException
;
class
SoundHolderProvider
extends
AbstractDataProvider
<
Sound
,
DataHolder
<
Sound
>>
{
@Override
protected
boolean
createPayload
(
XmlPullParser
parser
,
DataHolder
<
Sound
>
instance
)
{
if
(
super
.
createPayload
(
parser
,
instance
))
return
true
;
if
(
PhoneticSound
.
PHONETIC_NAME
.
equals
(
parser
.
getName
()))
instance
.
setPayload
(
createPhoneticSound
());
else
return
false
;
return
true
;
}
@Override
protected
Sound
createBinaryData
()
{
return
new
BinarySound
();
}
@Override
protected
Sound
createExternalData
()
{
return
new
ExternalSound
();
}
protected
Sound
createPhoneticSound
()
{
return
new
PhoneticSound
();
}
@Override
protected
boolean
inflatePayload
(
XmlPullParser
parser
,
DataHolder
<
Sound
>
instance
)
throws
IOException
,
XmlPullParserException
{
if
(
super
.
inflatePayload
(
parser
,
instance
))
return
true
;
if
(
instance
.
getPayload
()
instanceof
PhoneticSound
)
return
inflatePhoneticSound
(
parser
,
(
PhoneticSound
)
instance
.
getPayload
());
else
return
false
;
}
protected
boolean
inflatePhoneticSound
(
XmlPullParser
parser
,
PhoneticSound
payload
)
throws
IOException
,
XmlPullParserException
{
if
(
PhoneticSound
.
PHONETIC_NAME
.
equals
(
parser
.
getName
()))
payload
.
setValue
(
ProviderUtils
.
parseText
(
parser
));
else
return
false
;
return
true
;
}
@Override
protected
DataHolder
<
Sound
>
createInstance
(
XmlPullParser
parser
)
{
return
new
DataHolder
<
Sound
>();
}
private
SoundHolderProvider
()
{
}
private
static
final
SoundHolderProvider
instance
=
new
SoundHolderProvider
();
public
static
SoundHolderProvider
getInstance
()
{
return
instance
;
}
}
\ No newline at end of file
app/src/main/java/com/xabber/xmpp/vcard/Telephone.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
public
class
Telephone
extends
AbstractTypedDataWithValue
<
TelephoneType
>
{
public
static
final
String
ELEMENT_NAME
=
"TEL"
;
public
static
final
String
NUMBER_NAME
=
"NUMBER"
;
public
Telephone
()
{
super
();
}
@Override
protected
String
getElementName
()
{
return
ELEMENT_NAME
;
}
@Override
protected
String
getValueName
()
{
return
NUMBER_NAME
;
}
}
app/src/main/java/com/xabber/xmpp/vcard/TelephoneProvider.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
org.xmlpull.v1.XmlPullParser
;
class
TelephoneProvider
extends
AbstractTypedDataWithValueProvider
<
TelephoneType
,
Telephone
>
{
@Override
protected
String
getValueName
()
{
return
Telephone
.
NUMBER_NAME
;
}
@Override
protected
TelephoneType
[]
getTypes
()
{
return
TelephoneType
.
values
();
}
@Override
protected
Telephone
createInstance
(
XmlPullParser
parser
)
{
return
new
Telephone
();
}
private
TelephoneProvider
()
{
}
private
static
final
TelephoneProvider
instance
=
new
TelephoneProvider
();
public
static
TelephoneProvider
getInstance
()
{
return
instance
;
}
}
app/src/main/java/com/xabber/xmpp/vcard/VCard.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
java.io.IOException
;
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
org.jivesoftware.smack.util.StringUtils
;
import
org.xmlpull.v1.XmlSerializer
;
import
com.xabber.xmpp.IQ
;
import
com.xabber.xmpp.SerializerUtils
;
/**
* vCard-temp
* <p/>
* http://xmpp.org/extensions/xep-0054.html
*
* @author alexander.ivanov
*/
public
class
VCard
extends
IQ
{
public
static
final
String
ELEMENT_NAME
=
"vCard"
;
public
static
final
String
NAMESPACE
=
"vcard-temp"
;
public
static
final
String
N_NAME
=
"N"
;
public
static
final
String
CLASS_NAME
=
"CLASS"
;
public
static
final
String
CATEGORIES_NAME
=
"CATEGORIES"
;
public
static
final
String
KEYWORD_NAME
=
"KEYWORD"
;
private
String
version
;
private
final
Map
<
NameProperty
,
String
>
name
;
private
final
Map
<
VCardProperty
,
String
>
properties
;
private
final
List
<
Photo
>
photos
;
private
final
List
<
Address
>
addresses
;
private
final
List
<
Label
>
labels
;
private
final
List
<
Telephone
>
telephones
;
private
final
List
<
Email
>
emails
;
private
final
List
<
Logo
>
logos
;
private
final
List
<
Sound
>
sounds
;
private
final
List
<
Geo
>
geos
;
private
final
List
<
Organization
>
organizations
;
private
final
List
<
String
>
categories
;
private
Classification
classification
;
private
final
List
<
Key
>
keys
;
// TODO: Agent
public
VCard
()
{
super
(
ELEMENT_NAME
,
NAMESPACE
);
name
=
new
HashMap
<
NameProperty
,
String
>();
properties
=
new
HashMap
<
VCardProperty
,
String
>();
photos
=
new
ArrayList
<
Photo
>();
addresses
=
new
ArrayList
<
Address
>();
labels
=
new
ArrayList
<
Label
>();
telephones
=
new
ArrayList
<
Telephone
>();
emails
=
new
ArrayList
<
Email
>();
logos
=
new
ArrayList
<
Logo
>();
geos
=
new
ArrayList
<
Geo
>();
organizations
=
new
ArrayList
<
Organization
>();
categories
=
new
ArrayList
<
String
>();
sounds
=
new
ArrayList
<
Sound
>();
keys
=
new
ArrayList
<
Key
>();
}
private
boolean
isEmpty
()
{
return
version
==
null
&&
name
.
isEmpty
()
&&
properties
.
isEmpty
()
&&
photos
.
isEmpty
()
&&
addresses
.
isEmpty
()
&&
labels
.
isEmpty
()
&&
telephones
.
isEmpty
()
&&
emails
.
isEmpty
()
&&
logos
.
isEmpty
()
&&
sounds
.
isEmpty
()
&&
geos
.
isEmpty
()
&&
categories
.
isEmpty
()
&&
keys
.
isEmpty
()
&&
classification
==
null
;
}
public
String
getVersion
()
{
return
version
;
}
public
void
setVersion
(
String
version
)
{
this
.
version
=
version
;
}
public
List
<
Geo
>
getGeos
()
{
return
geos
;
}
public
Classification
getClassification
()
{
return
classification
;
}
public
void
setClassification
(
Classification
classification
)
{
this
.
classification
=
classification
;
}
public
List
<
Key
>
getKeys
()
{
return
keys
;
}
public
Map
<
NameProperty
,
String
>
getName
()
{
return
name
;
}
public
Map
<
VCardProperty
,
String
>
getProperties
()
{
return
properties
;
}
public
List
<
Photo
>
getPhotos
()
{
return
photos
;
}
public
List
<
Address
>
getAddresses
()
{
return
addresses
;
}
public
List
<
Label
>
getLabels
()
{
return
labels
;
}
public
List
<
Telephone
>
getTelephones
()
{
return
telephones
;
}
public
List
<
Email
>
getEmails
()
{
return
emails
;
}
public
List
<
Logo
>
getLogos
()
{
return
logos
;
}
public
List
<
Organization
>
getOrganizations
()
{
return
organizations
;
}
public
List
<
String
>
getCategories
()
{
return
categories
;
}
public
List
<
Sound
>
getSounds
()
{
return
sounds
;
}
public
String
getFormattedName
()
{
String
value
=
properties
.
get
(
VCardProperty
.
FN
);
if
(
value
==
null
)
{
StringBuilder
builder
=
new
StringBuilder
();
append
(
builder
,
name
.
get
(
NameProperty
.
PREFIX
));
append
(
builder
,
name
.
get
(
NameProperty
.
GIVEN
));
append
(
builder
,
name
.
get
(
NameProperty
.
MIDDLE
));
append
(
builder
,
name
.
get
(
NameProperty
.
FAMILY
));
append
(
builder
,
name
.
get
(
NameProperty
.
SUFFIX
));
return
builder
.
toString
();
}
return
value
;
}
public
byte
[]
getAvatar
()
{
BinaryPhoto
binaryPhoto
=
null
;
for
(
Photo
photo
:
photos
)
if
(
photo
instanceof
BinaryPhoto
)
{
binaryPhoto
=
(
BinaryPhoto
)
photo
;
break
;
}
if
(
binaryPhoto
==
null
)
return
null
;
return
binaryPhoto
.
getData
();
}
public
String
getAvatarHash
()
{
byte
[]
data
=
getAvatar
();
if
(
data
==
null
)
return
null
;
MessageDigest
digest
;
try
{
digest
=
MessageDigest
.
getInstance
(
"SHA-1"
);
}
catch
(
NoSuchAlgorithmException
e
)
{
e
.
printStackTrace
();
return
null
;
}
digest
.
update
(
data
);
return
StringUtils
.
encodeHex
(
digest
.
digest
());
}
public
String
getField
(
VCardProperty
property
)
{
return
properties
.
get
(
property
);
}
public
String
getField
(
NameProperty
property
)
{
return
name
.
get
(
property
);
}
public
String
getNickName
()
{
return
getField
(
VCardProperty
.
NICKNAME
);
}
public
String
getFirstName
()
{
return
getField
(
NameProperty
.
GIVEN
);
}
public
String
getMiddleName
()
{
return
getField
(
NameProperty
.
MIDDLE
);
}
public
String
getLastName
()
{
return
getField
(
NameProperty
.
FAMILY
);
}
private
void
append
(
StringBuilder
builder
,
String
value
)
{
if
(
value
==
null
||
""
.
equals
(
value
))
return
;
if
(
builder
.
length
()
!=
0
)
builder
.
append
(
" "
);
builder
.
append
(
value
);
}
public
void
setFormattedName
(
String
formattedName
)
{
properties
.
put
(
VCardProperty
.
FN
,
formattedName
);
}
@Override
public
String
getElementName
()
{
return
ELEMENT_NAME
;
}
@Override
public
String
getNamespace
()
{
return
NAMESPACE
;
}
@Override
public
void
serializeContent
(
XmlSerializer
serializer
)
throws
IOException
{
if
(
isEmpty
())
return
;
SerializerUtils
.
addTextTag
(
serializer
,
VCardProperty
.
FN
.
toString
(),
getFormattedName
());
serializer
.
startTag
(
null
,
N_NAME
);
for
(
Entry
<
NameProperty
,
String
>
entry
:
name
.
entrySet
())
SerializerUtils
.
addTextTag
(
serializer
,
entry
.
getKey
().
toString
(),
entry
.
getValue
());
serializer
.
endTag
(
null
,
N_NAME
);
for
(
Entry
<
VCardProperty
,
String
>
entry
:
properties
.
entrySet
())
if
(
entry
.
getKey
()
!=
VCardProperty
.
FN
)
SerializerUtils
.
addTextTag
(
serializer
,
entry
.
getKey
()
.
toString
(),
entry
.
getValue
());
for
(
Photo
photo
:
photos
)
photo
.
serialize
(
serializer
);
for
(
Address
address
:
addresses
)
address
.
serialize
(
serializer
);
for
(
Label
label
:
labels
)
label
.
serialize
(
serializer
);
for
(
Telephone
telephone
:
telephones
)
telephone
.
serialize
(
serializer
);
for
(
Email
email
:
emails
)
email
.
serialize
(
serializer
);
for
(
Logo
logo
:
logos
)
logo
.
serialize
(
serializer
);
for
(
Sound
sound
:
sounds
)
sound
.
serialize
(
serializer
);
for
(
Geo
geo
:
geos
)
geo
.
serialize
(
serializer
);
for
(
Organization
organization
:
organizations
)
organization
.
serialize
(
serializer
);
if
(!
categories
.
isEmpty
())
{
serializer
.
startTag
(
null
,
CATEGORIES_NAME
);
for
(
String
keyword
:
categories
)
SerializerUtils
.
addTextTag
(
serializer
,
KEYWORD_NAME
,
keyword
);
serializer
.
endTag
(
null
,
CATEGORIES_NAME
);
}
if
(
classification
!=
null
)
SerializerUtils
.
addTextTag
(
serializer
,
CLASS_NAME
,
classification
.
toString
());
for
(
Key
key
:
keys
)
key
.
serialize
(
serializer
);
}
@Override
public
boolean
isValid
()
{
return
true
;
}
@Override
protected
IQChildElementXmlStringBuilder
getIQChildElementBuilder
(
IQChildElementXmlStringBuilder
xml
)
{
xml
.
setEmptyElement
();
return
xml
;
}
}
app/src/main/java/com/xabber/xmpp/vcard/VCardProvider.java
deleted
100644 → 0
View file @
1866beba
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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 this program. If not, see http://www.gnu.org/licenses/.
*/
package
com
.
xabber
.
xmpp
.
vcard
;
import
org.jivesoftware.smack.SmackException
;
import
org.xmlpull.v1.XmlPullParser
;
import
org.xmlpull.v1.XmlPullParserException
;
import
com.xabber.xmpp.AbstractIQProvider
;
import
com.xabber.xmpp.ProviderUtils
;
import
java.io.IOException
;
public
class
VCardProvider
extends
AbstractIQProvider
<
VCard
>
{
@Override
protected
VCard
createInstance
(
XmlPullParser
parser
)
{
return
new
VCard
();
}
@Override
protected
boolean
parseInner
(
XmlPullParser
parser
,
VCard
instance
)
throws
XmlPullParserException
,
IOException
,
SmackException
{
if
(
super
.
parseInner
(
parser
,
instance
))
return
true
;
String
name
=
parser
.
getName
();
if
(
VCard
.
N_NAME
.
equals
(
name
))
{
NameInflater
.
getInstance
().
parseTag
(
parser
,
instance
);
}
else
if
(
Photo
.
ELEMENT_NAME
.
equals
(
name
))
{
DataHolder
<
Photo
>
holder
=
PhotoHolderProvider
.
getInstance
()
.
provideInstance
(
parser
);
if
(
holder
.
getPayload
()
!=
null
&&
holder
.
getPayload
().
isValid
())
instance
.
getPhotos
().
add
(
holder
.
getPayload
());
}
else
if
(
Logo
.
ELEMENT_NAME
.
equals
(
name
))
{
DataHolder
<
Logo
>
holder
=
LogoHolderProvider
.
getInstance
()
.
provideInstance
(
parser
);
if
(
holder
.
getPayload
()
!=
null
&&
holder
.
getPayload
().
isValid
())
instance
.
getLogos
().
add
(
holder
.
getPayload
());
}
else
if
(
Sound
.
ELEMENT_NAME
.
equals
(
name
))
{
DataHolder
<
Sound
>
holder
=
SoundHolderProvider
.
getInstance
()
.
provideInstance
(
parser
);
if
(
holder
.
getPayload
()
!=
null
&&
holder
.
getPayload
().
isValid
())
instance
.
getSounds
().
add
(
holder
.
getPayload
());
}
else
if
(
Address
.
ELEMENT_NAME
.
equals
(
name
))
{
Address
value
=
AddressProvider
.
getInstance
().
provideInstance
(
parser
);
if
(
value
.
isValid
())
instance
.
getAddresses
().
add
(
value
);
}
else
if
(
Label
.
ELEMENT_NAME
.
equals
(
name
))
{
Label
value
=
LabelProvider
.
getInstance
().
provideInstance
(
parser
);
if
(
value
.
isValid
())
instance
.
getLabels
().
add
(
value
);
}
else
if
(
Telephone
.
ELEMENT_NAME
.
equals
(
name
))
{
Telephone
value
=
TelephoneProvider
.
getInstance
().
provideInstance
(
parser
);
if
(
value
.
isValid
())
instance
.
getTelephones
().
add
(
value
);
}
else
if
(
Email
.
ELEMENT_NAME
.
equals
(
name
))
{
Email
value
=
EmailProvider
.
getInstance
().
provideInstance
(
parser
);
if
(
value
.
isValid
())
instance
.
getEmails
().
add
(
value
);
}
else
if
(
Geo
.
ELEMENT_NAME
.
equals
(
name
))
{
Geo
value
=
GeoProvider
.
getInstance
().
provideInstance
(
parser
);
if
(
value
.
isValid
())
instance
.
getGeos
().
add
(
value
);
}
else
if
(
Organization
.
ELEMENT_NAME
.
equals
(
name
))
{
Organization
value
=
OrganizationProvider
.
getInstance
()
.
provideInstance
(
parser
);
if
(
value
.
isValid
())
instance
.
getOrganizations
().
add
(
value
);
}
else
if
(
VCard
.
CATEGORIES_NAME
.
equals
(
name
))
{
CategoriesInflater
.
getInstance
().
parseTag
(
parser
,
instance
);
}
else
if
(
VCard
.
CLASS_NAME
.
equals
(
name
))
{
ClassificationInflater
.
getInstance
().
parseTag
(
parser
,
instance
);
}
else
if
(
Key
.
ELEMENT_NAME
.
equals
(
name
))
{
Key
value
=
KeyProvider
.
getInstance
().
provideInstance
(
parser
);
if
(
value
.
isValid
())
instance
.
getKeys
().
add
(
value
);
}
else
{
for
(
VCardProperty
key
:
VCardProperty
.
values
())
if
(
key
.
toString
().
equals
(
name
))
{
instance
.
getProperties
().
put
(
key
,
ProviderUtils
.
parseText
(
parser
));
return
true
;
}
return
false
;
}
return
true
;
}
}
app/src/main/res/raw/smack.providers
View file @
93a98040
...
...
@@ -2,13 +2,6 @@
<!-- Providers file for default Smack extensions -->
<smackProviders>
<!-- VCard -->
<iqProvider>
<elementName>
vCard
</elementName>
<namespace>
vcard-temp
</namespace>
<className>
com.xabber.xmpp.vcard.VCardProvider
</className>
</iqProvider>
<!-- vCardUpdate -->
<extensionProvider>
<elementName>
x
</elementName>
...
...
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