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
2cc0fb51
Commit
2cc0fb51
authored
May 12, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CarbonManager: code format (indent)
parent
797bf743
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
183 additions
and
181 deletions
+183
-181
CarbonManager.java
app/src/main/java/com/xabber/xmpp/carbon/CarbonManager.java
+183
-181
No files found.
app/src/main/java/com/xabber/xmpp/carbon/CarbonManager.java
View file @
2cc0fb51
package
com
.
xabber
.
xmpp
.
carbon
;
import
org.jivesoftware.smack.Connection
;
import
org.jivesoftware.smack.ConnectionCreationListener
;
import
org.jivesoftware.smack.PacketListener
;
import
org.jivesoftware.smack.XMPPConnection
;
import
org.jivesoftware.smack.filter.PacketIDFilter
;
import
org.jivesoftware.smack.packet.IQ
;
import
org.jivesoftware.smack.packet.Message
;
import
org.jivesoftware.smack.packet.Packet
;
import
org.jivesoftware.smack.packet.PacketExtension
;
import
org.jivesoftware.smackx.ServiceDiscoveryManager
;
import
com.xabber.android.data.Application
;
import
com.xabber.android.data.LogManager
;
import
com.xabber.android.data.SettingsManager
;
...
...
@@ -26,22 +15,30 @@ import com.xabber.android.data.message.AbstractChat;
import
com.xabber.android.data.message.MessageItem
;
import
com.xabber.android.data.message.MessageManager
;
import
org.jivesoftware.smack.Connection
;
import
org.jivesoftware.smack.ConnectionCreationListener
;
import
org.jivesoftware.smack.PacketListener
;
import
org.jivesoftware.smack.XMPPConnection
;
import
org.jivesoftware.smack.filter.PacketIDFilter
;
import
org.jivesoftware.smack.packet.IQ
;
import
org.jivesoftware.smack.packet.Message
;
import
org.jivesoftware.smack.packet.Packet
;
import
org.jivesoftware.smack.packet.PacketExtension
;
import
org.jivesoftware.smackx.ServiceDiscoveryManager
;
/**
* Packet extension for XEP-0280: Message Carbons. This class implements
* the manager for registering {@link Carbon} support, enabling and disabling
* message carbons.
*
*
<p/>
* You should call enableCarbons() before sending your first undirected
* presence.
*
* @author Georg Lukas, Semyon Baranov
*/
public
class
CarbonManager
implements
OnServerInfoReceivedListener
,
OnPacketListener
{
private
final
static
CarbonManager
instance
;
private
Connection
connection
;
private
volatile
boolean
enabled_state
=
false
;
public
class
CarbonManager
implements
OnServerInfoReceivedListener
,
OnPacketListener
{
public
static
final
String
NAMESPACE
=
"urn:xmpp:carbons:2"
;
private
final
static
CarbonManager
instance
;
static
{
instance
=
new
CarbonManager
();
...
...
@@ -65,12 +62,25 @@ public class CarbonManager implements OnServerInfoReceivedListener, OnPacketList
});
}
private
Connection
connection
;
private
volatile
boolean
enabled_state
=
false
;
private
CarbonManager
()
{
}
public
static
CarbonManager
getInstance
()
{
return
instance
;
}
private
CarbonManager
()
{
/**
* Mark a message as "private", so it will not be carbon-copied.
*
* @param msg Message object to mark private
*/
public
static
void
disableCarbons
(
Message
msg
)
{
msg
.
addExtension
(
new
Private
());
}
private
IQ
carbonsEnabledIQ
(
final
boolean
new_state
)
{
...
...
@@ -118,7 +128,7 @@ public class CarbonManager implements OnServerInfoReceivedListener, OnPacketList
/**
* Notify server to change the carbons state. This method returns
* immediately and changes the variable when the reply arrives.
*
*
<p/>
* You should first check for support using isSupportedByServer().
*
* @param new_state whether carbons should be enabled or disabled
...
...
@@ -134,7 +144,7 @@ public class CarbonManager implements OnServerInfoReceivedListener, OnPacketList
IQ
setIQ
=
carbonsEnabledIQ
(
new_state
);
connection
.
addPacketListener
(
new
PacketListener
()
{
public
void
processPacket
(
Packet
packet
)
{
IQ
result
=
(
IQ
)
packet
;
IQ
result
=
(
IQ
)
packet
;
if
(
result
.
getType
()
==
IQ
.
Type
.
RESULT
)
{
enabled_state
=
new_state
;
}
...
...
@@ -169,16 +179,6 @@ public class CarbonManager implements OnServerInfoReceivedListener, OnPacketList
return
enabled_state
;
}
/**
* Mark a message as "private", so it will not be carbon-copied.
*
* @param msg Message object to mark private
*/
public
static
void
disableCarbons
(
Message
msg
)
{
msg
.
addExtension
(
new
Private
());
}
@Override
public
void
onPacket
(
ConnectionItem
connection
,
String
bareAddress
,
Packet
packet
)
{
...
...
@@ -229,6 +229,7 @@ public class CarbonManager implements OnServerInfoReceivedListener, OnPacketList
MessageManager
.
getInstance
().
displayForwardedMessage
(
connection
,
forwardedMsg
,
dir
);
}
@Override
public
void
onServerInfoReceived
(
ConnectionItem
connection
)
{
...
...
@@ -251,6 +252,7 @@ public class CarbonManager implements OnServerInfoReceivedListener, OnPacketList
* Marks the message as non-carbon-copied in the following cases:
* - Message Carbons is enabled and OTR mode is enabled.
* - Message Carbons is enabled and OTR security level != plain.
*
* @param abstractChat
* @param message the <tt>Message</tt> to be sent
* @param messageItem
...
...
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