Skip to content

Commit

Permalink
adding in patches and CHANGELOG to the repo
Browse files Browse the repository at this point in the history
  • Loading branch information
otr4j-travis-ci authored and eighthave committed Jan 5, 2011
1 parent f0042da commit 204cb3d
Show file tree
Hide file tree
Showing 6 changed files with 360 additions and 1 deletion.
11 changes: 11 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@


2010-11-23
- added "General" contact list on loadContacts() call to the mContactList array
- added notifyPresenceUpdate for "General" contacts list
- Patches 1-3/3 by: Adrian-Ken Rueegsegger <ken@codelabs.ch>
-- Contacts which have no assigned group are put into the default group.
-- Rename default list to General
-- Factor out reading of contacts into container to private fillContacts() function.
- fixed app name and ensured build is working on Android 1.5 and up
- add support for scrollview in Account Activity; final button was getting squished in landscape mode
35 changes: 35 additions & 0 deletions patches/ken.1of3.11202010.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@@ -640,10 +640,8 @@ public class XmppConnection extends ImConnection {
Roster roster = mConnection.getRoster();
roster.setSubscriptionMode(Roster.SubscriptionMode.manual);
listenToRoster(roster);
- boolean haveGroup = false;
Set<String> seen = new HashSet<String>();
for (Iterator<RosterGroup> giter = roster.getGroups().iterator(); giter.hasNext();) {
- haveGroup = true;
RosterGroup group = giter.next();
Collection<Contact> contacts = new ArrayList<Contact>();
for (Iterator<RosterEntry> iter = group.getEntries().iterator(); iter.hasNext();) {
@@ -669,9 +667,20 @@ public class XmppConnection extends ImConnection {
notifyContactListLoaded(cl);
notifyContactsPresenceUpdated(contacts.toArray(new Contact[0]));
}
- if (!haveGroup) {
+ if (roster.getUnfiledEntryCount() > 0) {
roster.createGroup("Friends");
- ContactList cl = new ContactList(mUser.getAddress(), "Friends" , true, new ArrayList<Contact>(), this);
+ Collection<Contact> contacts = new ArrayList<Contact>();
+ for (Iterator<RosterEntry> iter = roster.getUnfiledEntries().iterator(); iter.hasNext();) {
+ RosterEntry entry = iter.next();
+ String address = parseAddressBase(entry.getUser());
+ String name = entry.getName();
+ if (name == null)
+ name = address;
+ XmppAddress xaddress = new XmppAddress(name, address);
+ Contact contact = new Contact(xaddress, name);
+ contacts.add(contact);
+ }
+ ContactList cl = new ContactList(mUser.getAddress(), "Friends" , true, contacts, this);
mDefaultContactList = cl;
notifyContactListLoaded(cl);
}

19 changes: 19 additions & 0 deletions patches/ken.2of3.11202010.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@@ -668,7 +668,7 @@ public class XmppConnection extends ImConnection {
notifyContactsPresenceUpdated(contacts.toArray(new Contact[0]));
}
if (roster.getUnfiledEntryCount() > 0) {
- roster.createGroup("Friends");
+ roster.createGroup("General");
Collection<Contact> contacts = new ArrayList<Contact>();
for (Iterator<RosterEntry> iter = roster.getUnfiledEntries().iterator(); iter.hasNext();) {
RosterEntry entry = iter.next();
@@ -680,7 +680,7 @@ public class XmppConnection extends ImConnection {
Contact contact = new Contact(xaddress, name);
contacts.add(contact);
}
- ContactList cl = new ContactList(mUser.getAddress(), "Friends" , true, contacts, this);
+ ContactList cl = new ContactList(mUser.getAddress(), "General" , true, contacts, this);
mDefaultContactList = cl;
notifyContactListLoaded(cl);
}

81 changes: 81 additions & 0 deletions patches/ken.3of3.11202010.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
@@ -634,7 +634,34 @@ public class XmppConnection extends ImConnection {
}
});
}
-
+
+ /**
+ * Create new list of contacts from roster entries.
+ *
+ * @param entryIter iterator of roster entries to add to contact list
+ * @param skipList list of contacts which should be omitted; new contacts are added to this list automatically
+ * @return contacts from roster which were not present in skiplist.
+ */
+ private Collection<Contact> fillContacts(Iterator<RosterEntry> entryIter, Set<String> skipList) {
+ Collection<Contact> contacts = new ArrayList<Contact>();
+ for (; entryIter.hasNext();) {
+ RosterEntry entry = entryIter.next();
+ String address = parseAddressBase(entry.getUser());
+
+ /* Skip entries present in the skip list */
+ if (skipList != null && !skipList.add(address))
+ continue;
+
+ String name = entry.getName();
+ if (name == null)
+ name = address;
+ XmppAddress xaddress = new XmppAddress(name, address);
+ Contact contact = new Contact(xaddress, name);
+ contacts.add(contact);
+ }
+ return contacts;
+ }
+
private void do_loadContactLists() {
Log.d(TAG, "load contact lists");
Roster roster = mConnection.getRoster();
@@ -643,23 +670,7 @@ public class XmppConnection extends ImConnection {
Set<String> seen = new HashSet<String>();
for (Iterator<RosterGroup> giter = roster.getGroups().iterator(); giter.hasNext();) {
RosterGroup group = giter.next();
- Collection<Contact> contacts = new ArrayList<Contact>();
- for (Iterator<RosterEntry> iter = group.getEntries().iterator(); iter.hasNext();) {
- RosterEntry entry = iter.next();
- String address = parseAddressBase(entry.getUser());
- if (seen.add(address)) {
-
- String name = entry.getName();
- if (name == null)
- name = address;
- XmppAddress xaddress = new XmppAddress(name, address);
- Contact contact = new Contact(xaddress, name);
- contacts.add(contact);
- }
- else {
- Log.d(TAG, "skipped duplicate contact");
- }
- }
+ Collection<Contact> contacts = fillContacts(group.getEntries().iterator(), seen);
ContactList cl = new ContactList(mUser.getAddress(), group.getName(), true, contacts, this);
mContactLists.add(cl);
if (mDefaultContactList == null)
@@ -669,17 +680,7 @@ public class XmppConnection extends ImConnection {
}
if (roster.getUnfiledEntryCount() > 0) {
roster.createGroup("General");
- Collection<Contact> contacts = new ArrayList<Contact>();
- for (Iterator<RosterEntry> iter = roster.getUnfiledEntries().iterator(); iter.hasNext();) {
- RosterEntry entry = iter.next();
- String address = parseAddressBase(entry.getUser());
- String name = entry.getName();
- if (name == null)
- name = address;
- XmppAddress xaddress = new XmppAddress(name, address);
- Contact contact = new Contact(xaddress, name);
- contacts.add(contact);
- }
+ Collection<Contact> contacts = fillContacts(roster.getUnfiledEntries().iterator(), null);
ContactList cl = new ContactList(mUser.getAddress(), "General" , true, contacts, this);
mDefaultContactList = cl;
notifyContactListLoaded(cl);

158 changes: 158 additions & 0 deletions patches/n8fr8.112310.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
diff --git a/src/org/gitian/android/im/plugin/xmpp/XmppConnection.java b/src/org/gitian/android/im/plugin/xmpp/XmppConnection.java
index a248d0d..f2283c4 100755
--- a/src/org/gitian/android/im/plugin/xmpp/XmppConnection.java
+++ b/src/org/gitian/android/im/plugin/xmpp/XmppConnection.java
@@ -83,7 +83,6 @@ public class XmppConnection extends ImConnection {
mExecutor = Executors.newSingleThreadExecutor();
xmppConnection = this;

-
}

public void sendMessage(org.jivesoftware.smack.packet.Message msg) {
@@ -102,10 +101,14 @@ public class XmppConnection extends ImConnection {

@Override
protected void doUpdateUserPresenceAsync(Presence presence) {
+
+ //android.os.Debug.waitForDebugger();
+
String statusText = presence.getStatusText();
Type type = Type.available;
Mode mode = Mode.available;
int priority = 20;
+
if (presence.getStatus() == Presence.AWAY) {
priority = 10;
mode = Mode.away;
@@ -123,6 +126,7 @@ public class XmppConnection extends ImConnection {
type = Type.unavailable;
statusText = "Offline";
}
+
org.jivesoftware.smack.packet.Presence packet =
new org.jivesoftware.smack.packet.Presence(type, statusText, priority, mode);
mConnection.sendPacket(packet);
@@ -305,6 +309,9 @@ public class XmppConnection extends ImConnection {

@Override
public void processPacket(Packet packet) {
+
+ //android.os.Debug.waitForDebugger();
+
org.jivesoftware.smack.packet.Presence presence = (org.jivesoftware.smack.packet.Presence)packet;
if (presence.getType() == Type.subscribe) {
String address = parseAddressBase(presence.getFrom());
@@ -312,6 +319,19 @@ public class XmppConnection extends ImConnection {
Contact contact = findOrCreateContact(address);
mContactListManager.getSubscriptionRequestListener().onSubScriptionRequest(contact);
}
+ else if (presence.getType() == Type.available)
+ {
+ String address = parseAddressBase(presence.getFrom());
+ Log.i(TAG, "got 'available' from " + address);
+
+
+ }
+ else if (presence.getType() == Type.unavailable)
+ {
+ String address = parseAddressBase(presence.getFrom());
+ Log.i(TAG, "got 'unavailable' from " + address);
+ }
+
}
}, new PacketTypeFilter(org.jivesoftware.smack.packet.Presence.class));

@@ -386,7 +406,9 @@ public class XmppConnection extends ImConnection {

org.jivesoftware.smack.packet.Presence presence =
new org.jivesoftware.smack.packet.Presence(org.jivesoftware.smack.packet.Presence.Type.available);
+
mConnection.sendPacket(presence);
+
}

void disconnected(ImErrorInfo info) {
@@ -667,8 +689,10 @@ public class XmppConnection extends ImConnection {
Roster roster = mConnection.getRoster();
roster.setSubscriptionMode(Roster.SubscriptionMode.manual);
listenToRoster(roster);
+
Set<String> seen = new HashSet<String>();
for (Iterator<RosterGroup> giter = roster.getGroups().iterator(); giter.hasNext();) {
+
RosterGroup group = giter.next();
Collection<Contact> contacts = fillContacts(group.getEntries().iterator(), seen);
ContactList cl = new ContactList(mUser.getAddress(), group.getName(), true, contacts, this);
@@ -678,37 +702,61 @@ public class XmppConnection extends ImConnection {
notifyContactListLoaded(cl);
notifyContactsPresenceUpdated(contacts.toArray(new Contact[0]));
}
+
if (roster.getUnfiledEntryCount() > 0) {
+
roster.createGroup("General");
Collection<Contact> contacts = fillContacts(roster.getUnfiledEntries().iterator(), null);
ContactList cl = new ContactList(mUser.getAddress(), "General" , true, contacts, this);
+
+ //n8fr8: adding this contact list to the master list manager seems like the righ thing to do
+ mContactLists.add(cl);
mDefaultContactList = cl;
notifyContactListLoaded(cl);
+
+ //n8fr8: also needs to ping the presence status change, too!
+ notifyContactsPresenceUpdated(contacts.toArray(new Contact[0]));
+
}
notifyContactListsLoaded();
+
+
}

private void listenToRoster(final Roster roster) {
+
roster.addRosterListener(new RosterListener() {

@Override
public void presenceChanged(org.jivesoftware.smack.packet.Presence presence) {
+
+ //android.os.Debug.waitForDebugger(); //this is for debugging a service
+
String user = parseAddressBase(presence.getFrom());
+
Contact contact = mContactListManager.getContact(user);
+
if (contact == null)
+ {
+ Log.d(TAG, "Got present update for NULL user: " + user);
return;
+ }
+
Contact []contacts = new Contact[] { contact };
// Get it from the roster - it handles priorities, etc.
presence = roster.getPresence(user);
+
int type = Presence.AVAILABLE;
Mode rmode = presence.getMode();
Type rtype = presence.getType();
+
if (rmode == Mode.away || rmode == Mode.xa)
type = Presence.AWAY;
if (rmode == Mode.dnd)
type = Presence.DO_NOT_DISTURB;
if (rtype == Type.unavailable)
type = Presence.OFFLINE;
+
contact.setPresence(new Presence(type, presence.getStatus(), null, null, Presence.CLIENT_TYPE_DEFAULT));
notifyContactsPresenceUpdated(contacts);
}
@@ -717,6 +765,9 @@ public class XmppConnection extends ImConnection {
public void entriesUpdated(Collection<String> addresses) {
// TODO update contact list entries from remote
Log.d(TAG, "roster entries updated");
+
+
+
}

@Override
Loading

0 comments on commit 204cb3d

Please sign in to comment.