1
0
mirror of https://github.com/moparisthebest/Yaaic synced 2024-11-22 00:42:16 -05:00

First simple channel model

This commit is contained in:
Sebastian Kaspari 2010-03-02 19:27:35 +01:00
parent 98eb8a36cf
commit 3c8e02c9dd
2 changed files with 98 additions and 2 deletions

View File

@ -0,0 +1,66 @@
/*
Yaaic - Yet Another Android IRC Client
Copyright 2009 Sebastian Kaspari
This file is part of Yaaic.
Yaaic is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Yaaic 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 Yaaic. If not, see <http://www.gnu.org/licenses/>.
*/
package org.yaaic.model;
import java.util.LinkedList;
/**
* An IRC channel
*
* @author Sebastian Kaspari <sebastian@yaaic.org>
*/
public class Channel
{
private static final int BUFFER_SIZE = 30;
private String name;
private LinkedList<String> messages = new LinkedList<String>();
/**
* Create a new channel object
*
* @param name of the channel
*/
public Channel(String name)
{
this.name = name;
}
/**
* Get name of channel
*/
public String getName()
{
return name;
}
/**
* Add a message to the channel
*/
public void addMessage(String message)
{
messages.add(message);
if (messages.size() > BUFFER_SIZE) {
messages.removeFirst();
}
}
}

View File

@ -20,6 +20,8 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
*/
package org.yaaic.model;
import java.util.ArrayList;
import org.yaaic.R;
/**
@ -34,6 +36,8 @@ public class Server
private String host;
private int port;
private ArrayList<Channel> channels = new ArrayList<Channel>();
private int status = Status.DISCONNECTED;
/**
@ -139,7 +143,7 @@ public class Server
/**
* Is disconnected?
*
* @return
* @return true if the user is disconnected, false if the user is connected or currently connecting
*/
public boolean isDisconnected()
{
@ -148,13 +152,39 @@ public class Server
/**
* Is connected?
* @return
*
* @return true if the user is (successfully) connected to this server, false otherwise
*/
public boolean isConnected()
{
return status == Status.CONNECTED;
}
/**
* Get all (joined) channels
*
* @return
*/
public ArrayList<Channel> getChannels()
{
return channels;
}
/**
* Add a new (joined) channel
*
* @param channel
*/
public void addChannel(Channel channel)
{
channels.add(channel);
}
/**
* Get icon for current server status
*
* @return int Status icon ressource
*/
public int getStatusIcon()
{
switch (status) {