mirror of
https://github.com/moparisthebest/Yaaic
synced 2024-11-26 02:42:16 -05:00
First simple channel model
This commit is contained in:
parent
98eb8a36cf
commit
3c8e02c9dd
66
src/org/yaaic/model/Channel.java
Normal file
66
src/org/yaaic/model/Channel.java
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -20,6 +20,8 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
*/
|
*/
|
||||||
package org.yaaic.model;
|
package org.yaaic.model;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.yaaic.R;
|
import org.yaaic.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,6 +36,8 @@ public class Server
|
|||||||
private String host;
|
private String host;
|
||||||
private int port;
|
private int port;
|
||||||
|
|
||||||
|
private ArrayList<Channel> channels = new ArrayList<Channel>();
|
||||||
|
|
||||||
private int status = Status.DISCONNECTED;
|
private int status = Status.DISCONNECTED;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -139,7 +143,7 @@ public class Server
|
|||||||
/**
|
/**
|
||||||
* Is disconnected?
|
* Is disconnected?
|
||||||
*
|
*
|
||||||
* @return
|
* @return true if the user is disconnected, false if the user is connected or currently connecting
|
||||||
*/
|
*/
|
||||||
public boolean isDisconnected()
|
public boolean isDisconnected()
|
||||||
{
|
{
|
||||||
@ -148,13 +152,39 @@ public class Server
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Is connected?
|
* Is connected?
|
||||||
* @return
|
*
|
||||||
|
* @return true if the user is (successfully) connected to this server, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean isConnected()
|
public boolean isConnected()
|
||||||
{
|
{
|
||||||
return status == Status.CONNECTED;
|
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()
|
public int getStatusIcon()
|
||||||
{
|
{
|
||||||
switch (status) {
|
switch (status) {
|
||||||
|
Loading…
Reference in New Issue
Block a user