1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-09 09:09:38 +02:00

Create smack-im subproject for XMPP-IM

Move Roster and Chat(Manager) code into their own packages within the
new smack-im subproject.

Apply Manager pattern to Roster.

Fixes SMACK-637.
This commit is contained in:
Florian Schmaus 2015-01-22 13:53:50 +01:00
parent e722018808
commit d5b8647d9d
47 changed files with 392 additions and 271 deletions

View file

@ -39,7 +39,7 @@ XMPPConnection conn1 = …
// Create a new roster exchange manager on conn1
RosterExchangeManager rosterExchangeManager = new RosterExchangeManager(conn1);
// Send user1's roster to user2
rosterExchangeManager.send(conn1.getRoster(), user2);
rosterExchangeManager.send(Roster.getInstanceFor(conn1), user2);
```
Send a roster group
@ -67,7 +67,7 @@ XMPPConnection conn1 = …
// Create a new roster exchange manager on conn1
RosterExchangeManager rosterExchangeManager = new RosterExchangeManager(conn1);
// Send user1's RosterGroups to user2
for (Iterator it = conn1.getRoster().getGroups(); it.hasNext(); )
for (Iterator it = Roster.getInstanceFor(conn1).getGroups(); it.hasNext(); )
rosterExchangeManager.send((RosterGroup)it.next(), user2);
```
@ -96,7 +96,7 @@ XMPPConnection conn1 = …
// Create a new roster exchange manager on conn1
RosterExchangeManager rosterExchangeManager = new RosterExchangeManager(conn1);
// Send a roster entry (any) to user2
rosterExchangeManager1.send((RosterEntry)conn1.getRoster().getEntries().next(), user2);
rosterExchangeManager1.send((RosterEntry)Roster.getInstanceFor(conn1).getEntries().next(), user2);
```
Receive roster entries
@ -124,7 +124,7 @@ adds the received entries to his roster.
XMPPConnection conn1 = …
XMPPConnection conn2 = …
final Roster user2_roster = conn2.getRoster();
final Roster user2_roster = Roster.getInstanceFor(conn2);
// Create a RosterExchangeManager that will help user2 to listen and accept
the entries received
@ -156,5 +156,5 @@ rosterExchangeManager2.addRosterListener(rosterExchangeListener);
// Create a RosterExchangeManager that will help user1 to send his roster
RosterExchangeManager rosterExchangeManager1 = new RosterExchangeManager(conn1);
// Send user1's roster to user2
rosterExchangeManager1.send(conn1.getRoster(), user2);
rosterExchangeManager1.send(Roster.getInstanceFor(conn1), user2);
```

View file

@ -79,7 +79,7 @@ The roster lets you keep track of the availability (presence) of other users.
Users can be organized into groups such as "Friends" and "Co-workers", and
then you discover whether each user is online or offline.
Retrieve the roster using the `XMPPConnection.getRoster()` method. The roster
Retrieve the roster using the `Roster.getInstanceFor(XMPPConnection)` method. The roster
class allows you to find all the roster entries, the groups they belong to,
and the current presence status of each entry.

View file

@ -8,7 +8,7 @@ users. A roster also allows you to organize users into groups such as
"Friends" and "Co-workers". Other IM systems refer to the roster as the buddy
list, contact list, etc.
A `Roster` instance is obtained using the `XMPPConnection.getRoster()` method.
A `Roster` instance is obtained using the `Roster.getInstanceFor(XMPPConnection)` method.
Roster Entries
--------------
@ -20,7 +20,7 @@ Every user in a roster is represented by a RosterEntry, which consists of:
* The list of groups in the roster that the entry belongs to. If the roster entry belongs to no groups, it's called an "unfiled entry". The following code snippet prints all entries in the roster:
```
Roster roster = connection.getRoster();
Roster roster = Roster.getInstanceFor(connection);
Collection<RosterEntry> entries = roster.getEntries();
for (RosterEntry entry : entries) {
System.out.println(entry);
@ -63,7 +63,7 @@ out. A normal client would use similar code to update the roster UI with the
changing information.
```
Roster roster = con.getRoster();
Roster roster = Roster.getInstanceFor(con);
roster.addRosterListener(new RosterListener() {
// Ignored events public void entriesAdded(Collection<String> addresses) {}
public void entriesDeleted(Collection<String> addresses) {}