1
0
mirror of https://github.com/moparisthebest/Yaaic synced 2024-11-16 22:15:08 -05:00
Yaaic/src/org/yaaic/model/Server.java

202 lines
3.2 KiB
Java
Raw Normal View History

2009-12-17 15:27:57 -05:00
/*
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;
2010-03-02 13:27:35 -05:00
import java.util.ArrayList;
2009-12-17 15:27:57 -05:00
import org.yaaic.R;
/**
* A server as we know it
*
* @author Sebastian Kaspari <sebastian@yaaic.org>
*/
public class Server
{
private int id;
private String title;
private String host;
private int port;
2010-03-02 13:27:35 -05:00
private ArrayList<Channel> channels = new ArrayList<Channel>();
2009-12-17 15:27:57 -05:00
private int status = Status.DISCONNECTED;
/**
* Get unique id of server
*
* @return id
*/
public int getId()
{
return id;
}
/**
* Set unique id of server
*
* @param id
*/
public void setId(int id)
{
this.id = id;
}
/**
* Get title of server
*
* @return
*/
public String getTitle()
{
return title;
}
/**
* Set title of server
*
* @param title
*/
public void setTitle(String title)
{
this.title = title;
}
/**
* Get hostname of server
*
* @return
*/
public String getHost()
{
return host;
}
/**
* Set hostname of server
*
* @param host
*/
public void setHost(String host)
{
this.host = host;
}
/**
* Get port of server
*
* @return
*/
public int getPort()
{
return port;
}
/**
* Set port of server
*
* @param port
*/
public void setPort(int port)
{
this.port = port;
}
/**
* Set connection status of server
*
* @status See constants Status.*
*/
public void setStatus(int status)
{
this.status = status;
}
/**
* Get connection status of server
*
* @return See constants Status.*
*/
public int getStatus()
{
return status;
}
/**
* Is disconnected?
*
2010-03-02 13:27:35 -05:00
* @return true if the user is disconnected, false if the user is connected or currently connecting
2009-12-17 15:27:57 -05:00
*/
public boolean isDisconnected()
{
return status == Status.DISCONNECTED;
}
/**
* Is connected?
2010-03-02 13:27:35 -05:00
*
* @return true if the user is (successfully) connected to this server, false otherwise
2009-12-17 15:27:57 -05:00
*/
public boolean isConnected()
{
return status == Status.CONNECTED;
}
2010-03-02 13:27:35 -05:00
/**
* 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
*/
2009-12-17 15:27:57 -05:00
public int getStatusIcon()
{
switch (status) {
case Status.CONNECTED:
return R.drawable.connected;
case Status.DISCONNECTED:
return R.drawable.disconnected;
case Status.CONNECTING:
return R.drawable.connecting;
}
return R.drawable.connecting;
}
}