Search in sources :

Example 1 with HostedRoom

use of org.jivesoftware.smackx.muc.HostedRoom in project xabber-android by redsolution.

the class ConferenceFilterActivity method restoreConferenceList.

public static List<HostedRoom> restoreConferenceList(Bundle bundleExtra) {
    List<String> conferencesNames = bundleExtra.getStringArrayList(ARG_CONFERENCE_LIST_NAMES);
    List<String> conferencesJids = bundleExtra.getStringArrayList(ARG_CONFERENCE_LIST_JIDS);
    List<HostedRoom> conferences = new ArrayList<>();
    if (conferencesNames != null && conferencesJids != null && conferencesNames.size() == conferencesJids.size()) {
        for (int i = 0; i < conferencesNames.size(); i++) {
            try {
                DiscoverItems.Item item = new DiscoverItems.Item(JidCreate.from(conferencesJids.get(i)));
                item.setName(conferencesNames.get(i));
                conferences.add(new HostedRoom(item));
            } catch (XmppStringprepException e) {
                LogManager.exception(LOG_TAG, e);
            }
        }
    }
    return conferences;
}
Also used : ArrayList(java.util.ArrayList) DiscoverItems(org.jivesoftware.smackx.disco.packet.DiscoverItems) XmppStringprepException(org.jxmpp.stringprep.XmppStringprepException) HostedRoom(org.jivesoftware.smackx.muc.HostedRoom)

Example 2 with HostedRoom

use of org.jivesoftware.smackx.muc.HostedRoom in project xabber-android by redsolution.

the class ConferenceSelectFragment method storeConferenceList.

private void storeConferenceList(Bundle intent) {
    List<HostedRoom> conferencesList = hostedConferencesAdapter.getConferencesList();
    ArrayList<String> names = new ArrayList<>();
    ArrayList<String> jids = new ArrayList<>();
    for (HostedRoom hostedRoom : conferencesList) {
        names.add(hostedRoom.getName());
        jids.add(hostedRoom.getJid().toString());
    }
    intent.putStringArrayList(ConferenceFilterActivity.ARG_CONFERENCE_LIST_NAMES, names);
    intent.putStringArrayList(ConferenceFilterActivity.ARG_CONFERENCE_LIST_JIDS, jids);
}
Also used : ArrayList(java.util.ArrayList) HostedRoom(org.jivesoftware.smackx.muc.HostedRoom)

Example 3 with HostedRoom

use of org.jivesoftware.smackx.muc.HostedRoom in project ecf by eclipse.

the class XMPPChatRoomManager method getChatRooms.

protected ID[] getChatRooms() {
    if (ecfConnection == null)
        return null;
    final XMPPConnection conn = ecfConnection.getXMPPConnection();
    if (conn == null)
        return null;
    final Collection result = new ArrayList();
    try {
        final Collection svcs = MultiUserChat.getServiceNames(conn);
        for (final Iterator svcsi = svcs.iterator(); svcsi.hasNext(); ) {
            final String svc = (String) svcsi.next();
            final Collection rooms = MultiUserChat.getHostedRooms(conn, svc);
            for (final Iterator roomsi = rooms.iterator(); roomsi.hasNext(); ) {
                final HostedRoom room = (HostedRoom) roomsi.next();
                final ID roomID = createIDFromHostedRoom(room);
                if (roomID != null)
                    result.add(roomID);
            }
        }
    } catch (final XMPPException e) {
        return null;
    }
    return (ID[]) result.toArray(new ID[] {});
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) Collection(java.util.Collection) XMPPConnection(org.jivesoftware.smack.XMPPConnection) XMPPID(org.eclipse.ecf.provider.xmpp.identity.XMPPID) XMPPRoomID(org.eclipse.ecf.provider.xmpp.identity.XMPPRoomID) ID(org.eclipse.ecf.core.identity.ID) XMPPException(org.jivesoftware.smack.XMPPException) HostedRoom(org.jivesoftware.smackx.muc.HostedRoom)

Example 4 with HostedRoom

use of org.jivesoftware.smackx.muc.HostedRoom in project xabber-android by redsolution.

the class HostedConferencesAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // A ViewHolder keeps references to children views to avoid unnecessary calls
    // to findViewById() on each row.
    ViewHolder holder;
    // by ListView is null.
    if (convertView == null) {
        convertView = inflater.inflate(android.R.layout.simple_list_item_2, null);
        // Creates a ViewHolder and store references to the two children views
        // we want to bind data to.
        holder = new ViewHolder();
        holder.name = (TextView) convertView.findViewById(android.R.id.text1);
        holder.jid = (TextView) convertView.findViewById(android.R.id.text2);
        // Bind the data efficiently with the holder.
        convertView.setTag(holder);
    } else {
        // Get the ViewHolder back to get fast access to the TextView
        // and the ImageView.
        holder = (ViewHolder) convertView.getTag();
    }
    // If weren't re-ordering this you could rely on what you set last time
    HostedRoom hostedRoom = filteredData.get(position);
    holder.name.setText(hostedRoom.getName());
    holder.jid.setText(hostedRoom.getJid());
    return convertView;
}
Also used : HostedRoom(org.jivesoftware.smackx.muc.HostedRoom)

Example 5 with HostedRoom

use of org.jivesoftware.smackx.muc.HostedRoom in project xabber-android by redsolution.

the class MUCManager method requestHostedRooms.

public static void requestHostedRooms(final String account, final String serviceName, final HostedRoomsListener listener) {
    final XMPPConnection xmppConnection = AccountManager.getInstance().getAccount(account).getConnectionThread().getXMPPConnection();
    final Thread thread = new Thread("Get hosted rooms on server " + serviceName + " for account " + account) {

        @Override
        public void run() {
            Collection<HostedRoom> hostedRooms = null;
            try {
                hostedRooms = MultiUserChatManager.getInstanceFor(xmppConnection).getHostedRooms(serviceName);
            } catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | SmackException.NotConnectedException e) {
                e.printStackTrace();
            }
            final Collection<HostedRoom> finalHostedRooms = hostedRooms;
            Application.getInstance().runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    listener.onHostedRoomsReceived(finalHostedRooms);
                }
            });
        }
    };
    thread.start();
}
Also used : XMPPConnection(org.jivesoftware.smack.XMPPConnection) HostedRoom(org.jivesoftware.smackx.muc.HostedRoom) ConnectionThread(com.xabber.android.data.connection.ConnectionThread)

Aggregations

HostedRoom (org.jivesoftware.smackx.muc.HostedRoom)7 ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)3 XMPPException (org.jivesoftware.smack.XMPPException)3 TimerTask (java.util.TimerTask)2 SmackException (org.jivesoftware.smack.SmackException)2 XMPPConnection (org.jivesoftware.smack.XMPPConnection)2 ChatRoomNotFoundException (org.jivesoftware.spark.ui.ChatRoomNotFoundException)2 ConnectionThread (com.xabber.android.data.connection.ConnectionThread)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 Iterator (java.util.Iterator)1 JOptionPane (javax.swing.JOptionPane)1 JPanel (javax.swing.JPanel)1 ID (org.eclipse.ecf.core.identity.ID)1 XMPPID (org.eclipse.ecf.provider.xmpp.identity.XMPPID)1 XMPPRoomID (org.eclipse.ecf.provider.xmpp.identity.XMPPRoomID)1 DiscoverItems (org.jivesoftware.smackx.disco.packet.DiscoverItems)1 RoomInfo (org.jivesoftware.smackx.muc.RoomInfo)1 TitlePanel (org.jivesoftware.spark.component.TitlePanel)1